Skip to content
This repository has been archived by the owner on Jan 14, 2019. It is now read-only.

Failed import in test gives odd test error #14

Closed
birdsarah opened this issue Apr 29, 2013 · 3 comments
Closed

Failed import in test gives odd test error #14

birdsarah opened this issue Apr 29, 2013 · 3 comments

Comments

@birdsarah
Copy link

(First-up, many thanks for this excellent tool).

Here's my basic setup (all tests in one directory with sub directories for each apps tests:

- manage.py
- project/
-- appA/
--- stuff.py
-- tests/
--- appA/
---- test_for_stuff.py

I was writing a new test file, and I had an import error (I'd written from appA import X, instead of from appA.models import X)

When I ran the test by running:

 ./manage.py test project.appA.tests.test_for_stuff

I got the following error:

  File "/home/bird/Dev/aptivate/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/test/simple.py", line 380, in run_tests
    suite = self.build_suite(test_labels, extra_tests)
  File "/home/bird/Dev/aptivate/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/discover_runner/runner.py", line 40, in build_suite
    suite = self.test_loader.loadTestsFromNames(test_labels)
  File "/usr/lib/python2.7/unittest/loader.py", line 128, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  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_for_stuff'

I was a little confused by this because I thoguht it was trying to tell me my test_for_stuff file wasn't there.

I would have expected an ImportError.

@jezdez
Copy link
Owner

jezdez commented Apr 30, 2013

That's indeed odd, hmm. Wait, wouldn't you have to run ./manage.py test project.tests.appA.test_for_stuff? At least that's how I understand the directory structure you wrote above.

@jezdez
Copy link
Owner

jezdez commented Jun 15, 2013

Can you try with the recently released 1.0 version? That should fix the problem.

@jezdez jezdez closed this as completed Jun 15, 2013
@birdsarah
Copy link
Author

Hi,

I'm so sorry for the delay in responding, you're right about my dotted path being wrong above, but my bad on the typo, the bug seems to remain.

I've created an example repo so you can easily see the issue.

https://github.com/birdsarah/django-discover-runner-test

Tracking down the issue a bit, it seems to come from: https://github.com/jezdez/django-discover-runner/blob/master/discover_runner/runner.py#L73

Would love to help further if I can.

(I really hope I'm not doing something epically stupid and I apologize in advance if I am.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants