Thursday, January 3, 2013

Re: django_nose failing to discover tests

I think the trick is in the name of the module and/or test case. I can't remember exactly how django-nose modifies test discovery but here's what nose does alone:

https://nose.readthedocs.org/en/latest/finding_tests.html

Try renaming the test class to something that begins with "Test" -- so like "TestAccounts" and then use "test_something", "test_something_else" types of names for methods. I think that this should work.

If all else fails, you can always point to the module directly:

./manage.py test myproject.accounts.tests.test_account.AccountTest

You may also try adding '--all-modules' to NOSE_ARGS in your project settings:

NOSE_ARGS = [
    ...
    '--all-modules'
]

or by passing "--all-modules" directly to ./manage.py:

./manage.py test --all-modules

Hope this helps.

--Evan


On Monday, December 31, 2012 9:41:33 AM UTC-8, Joe Legner wrote:
I am trying to get django_nose to discover tests in my project.  I watched this video which seems to indicate that my project/app/tests/__init__.py should be able to be empty (not contain a bunch of import * statements):


The goal is to have django_nose find my tests by name so I do not have to have import * from ... statements within my tests/__init__.py for every app.  My project is set up like this:

/myproject
    /accounts
        __init__.py
        /tests
            __init__.py
            test_account.py

The __init__.py file is empty.  The test_account.py file contains an AccountTest class derived from unittest.TestCase.

When I run ./manage.py test accounts (with an empty __init__.py), the result is "Ran 0 tests in 0.000s"

Now, if I make accounts/tests/__init__.py contain the line from test_account import *, it works correctly; therefore, I believe I do have django_nose (version 1.1 and nose 1.2.1) installed and working.

I Googled all morning to solve the problem but have failed.  If you have any insight, please reply.  Thank you.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/GUuMIl4BjwMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment