machineghost
machineghost

Reputation: 35790

Django App Tests Won't Run Specifically (But Will Run With All Tests)

I have a Django app called "fstore". It's registered in INSTALLED_APPS as "foo.bar.fstore". When I run all of my django tests via "manage.py test", I see results from its test, eg.:

FAIL: testFilesWithDuplicatePathsDoNotOverwriteEachOther (foo.bar.fstore.tests.fileRecTests.TestFunctionality)

However, when I try to specifically run tests for this app, via "manage.py test fstore", Django tells me:

Ran 0 tests in 0.000s

If I had the app name wrong or something it would give me an error, but it clearly recognizes the app ... it just fails to find the tests for it (even though they're inside a "tests" folder with an __init__.py inside that app's folder). So my basic question is: what gives? Or more specifically, how do I get just the tests from this app to run without running all of the rests?

Oh, and just to rule out the easy answer, yes this app has both a models.py and an __init__.py.

* EDIT *

I just ran "manage.py shell" and it turned out something was fishy:

from django.db.models import get_app, get_apps
get_app("fstore")
<module 'foo.bar.search.models' from '/baz/python/foo/bar/search/models.pyc'>

Which of course was the compiled form of the completely wrong model (no clue how that happened). So I removed the .pyc file, and now I get a more normal error:

django.core.exceptions.ImproperlyConfigured: App with label fstore could not be found

which is progress ... but it still doesn't explain why Django can't find my app.

One more note: even though Django works fine (I can "manage.py runserver", browse around my app, etc.), at the command line I apparently have no apps at all. For instance, trying to run "manage.py test debug_toolbar" gives me a similar ImproperlyConfigured error. Hopefully this means something to someone ...

Upvotes: 2

Views: 689

Answers (1)

machineghost
machineghost

Reputation: 35790

Wow, this was terrible. So I guess I've been editing Django core files in my sleep or something, because there was a file (models/loading.py) which had been modified to have that foo.bar.search app hard-coded in to it. I don't have any bash history of editing this file, nor do I have an Eclipse history, and I would have had no reason to edit the file, but ... since no one else could have done it, I guess I must have (or else there is a REALLY weird django bug that results in it editing source code).

I guess I'll leave this question/answer here on the freak chance that someone else does something similar and this helps them, but this is such a freak occurrence that I doubt it will.

Upvotes: 1

Related Questions