Changes between Initial Version and Version 1 of Ticket #12658, comment 1


Ignore:
Timestamp:
Jun 11, 2011, 11:00:29 AM (13 years ago)
Author:
Ramiro Morales

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #12658, comment 1

    initial v1  
    11More information: it only occurs if both the tests file and the models file have been split into folders.  This is due to the line in django.test.simple.get_tests that tries again to find the module:
    2 
     2{{{
    33mod = find_module(TEST_MODULE, [os.path.dirname(app_module.__file__)])
    4 
    5 At this point, if the models file has been split, then app_module.__file__ is the __init__.py file in the models directory, so os.path.dirname() of this gets the model directory, not the app directory.  Thus, no tests module can be found (unless there was one in the models directory).
     4}}}
     5At this point, if the models file has been split, then `app_module.__file__` is the `__init__.py` file in the models directory, so `os.path.dirname()` of this gets the model directory, not the app directory.  Thus, no tests module can be found (unless there was one in the models directory).
    66
    77A really hacky solution is to capture the internal exception, and compare the arguments of the two exceptions. If they match, then it is the tests module that is missing. If it isn't then the problem is an import. I'm sure there is a much nicer solution, though. I'm not really even game to submit a patch for mine!
Back to Top