Why doesn't the django test management command / test builder allow
fully-qualified package names instead of just app-relative ones?

At work we've been using the method below to monkey-patch the test
builder, so that

 $ django-admin.py test my_module.my_app.tests.some_test_file

always works as expected.  We'd like to get rid of this monkey-patch,
and since this functionality can be added in such a way that it's
completely backwards compatible, where is the harm?  I'm also willing
to submit a diff that modifies django in-place, but the monkey patch
below should be easy to read and first I wanted to hear if anyone has
any thoughts on why the existing behaviour really is exactly what it
should be.



    def _support_dotpaths():
        """ allows real dotpaths to be used as test labels for
django's test runner
            first we maintain the status quo by doing whatever django
does, then
            just do it the way that they should have done it in the
first place.
        """
        import unittest
        from django.db.models.loading import ImproperlyConfigured
        from django.test import simple
        django_build_test_test = simple.build_test
        def my_build_test(label):
            fallback = lambda:
unittest.TestLoader().loadTestsFromName(label)
            try:
                return django_build_test_test(label)
            except ValueError, v:
                if 'should be of the form' in str(v):
                    return fallback()
                else:
                    raise
            except ImproperlyConfigured,e:
                if 'App with label' in str(e):
                    return fallback()
                else:
                    raise
        simple.build_test = my_build_test
        return my_build_test

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to