On Mon, Jul 14, 2008 at 9:28 AM, jawspeak <[EMAIL PROTECTED]> wrote: > > I'm not experienced in python but coming from Java I'm having a hard > time being forced to put all my tests for an app in one file. ... > It really bothers me that I don't know how to automatically include > every file under my tests directory, to run automatically. What's the > right way to create a suite?
I don't think your statement that testing has 'second class' status is accurate. Django contains a testing module; that testing module contains some default behaviours and assumptions. Those defaults are not useful for every project, so you will sometimes need to step outside the defaults. That doesn't mean testing has second-class status - just that the defaults don't suit your application. You have discovered one way to work around the defaults: import the unit tests you need into tests/__init__.py. However, there are at least 2 other options: Firstly, you can define a suite() function in tests.py (or models.py). This approach is documented as part of the Python unittest framework [1]. That suite function can use whatever discovery approach you find helpful. Secondly, you can override Django's test discovery behaviour. You do this by writing a custom test runner [2] that employs a different approach to finding and building the test suite. The default test runner can be found in django.test.simple. This method is fairly straight forward; writing a replacement isn't a difficult task. Of course, we are always open to suggestions for how to make the defaults more useful. If you have a suggestion for a better set of default behaviours, feel free to make the suggestion. However, keep in mind that your suggestion needs to be appropriate for _every_ Django project - not just your project. [1] http://docs.python.org/lib/organizing-tests.html [2] http://www.djangoproject.com/documentation/testing/#defining-a-test-runner Yours Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---