vendredi 16 février 2018

Unable to run an individual test with Django 1.8

Having followed the advice in these two answers, I'm still unable to run only a single django test in the way it describes. I can run them all, but that takes a long time and makes debugging harder.

My project structure looks like this:

mainapp/mainapp/users/ 
├── __init__.py 
├── tests
│   ├── __init__.py 
│   ├── test_views.py
└── views.py

For example, when the whole test suite is run, one of the failing tests gives this output:

FAIL: test_changepassword (mainapp.users.tests.test_views.ChangePasswordTest)

But when I try to run that Django TestCase with either the Django...

~/mainapp$ python manage.py test mainapp.users.tests.test_views.ChangePasswordTest
File "/usr/lib/python2.7/unittest/loader.py", line 100, in loadTestsFromName
        parent, obj = obj, getattr(obj, part) 
AttributeError: 'module' object has no attribute 'test_views'

or django-nose syntax...

~/mainapp$ python manage.py test mainapp.users.tests.test_views:ChangePasswordTest
File "/usr/lib/python2.7/unittest/loader.py", line 100, in loadTestsFromName
        parent, obj = obj, getattr(obj, part) 
AttributeError: 'module' object has no attribute 'test_views:ChangePasswordTest'

When I run this in PyCharmCE debug mode it confirms that the module object has no attributes, but I don't know why.

I have django-nose (1.4.5) installed and it's in my INSTALLED_APPS, but I don't know if anything else is required to use it.

This works fine down to a certain level. For example this is OK:

~/mainapp$ python manage.py test mainapp.users.tests

What's going on?

Aucun commentaire:

Enregistrer un commentaire