rbarrois/python-semanticversion — pull request #10 by mhrivnak (2014-03-08 06:59:09+00:00)
Title: moved django test app settings to the django test app module

... to guarantee the settings get executed before any code in that app. Since
python's unittest.TestLoader does not guarantee in what order it will import
modules while hunting for test cases, the unit tests could fail to even load if
tests.django_test_app.models was imported before tests.test_django.

This failure was seen consistently on ARM machines, which happened to traverse the module tree in an
inconvenient order. The failure was with version 2.2.2.

The problem could be reproduced from the root of the git repository's tree by opening a python shell and running ```import tests.django_test_app.models```

Shell history with traceback from an ARM-based machine is below.

```
+ /usr/bin/python2 setup.py test
running test
running egg_info
writing semantic_version.egg-info/PKG-INFO
writing top-level names to semantic_version.egg-info/top_level.txt
writing dependency_links to semantic_version.egg-info/dependency_links.txt
reading manifest file 'semantic_version.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'docs/Makefile'
warning: no files found matching '*.py' under directory 'docs'
warning: no files found matching '*.rst' under directory 'docs'
warning: no files found matching 'docs/_static/.keep_dir'
no previously-included directories found matching 'docs/_build'
writing manifest file 'semantic_version.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
File "setup.py", line 58, in
test_suite='tests',
File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/site-packages/setuptools/command/test.py", line 138, in run
self.with_project_on_sys_path(self.run_tests)
File "/usr/lib/python2.7/site-packages/setuptools/command/test.py", line 118, in with_project_on_sys_path
func()
File "/usr/lib/python2.7/site-packages/setuptools/command/test.py", line 164, in run_tests
testLoader = cks
File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/usr/lib/python2.7/unittest/main.py", line 149, in parseArgs
self.createTests()
File "/usr/lib/python2.7/unittest/main.py", line 158, in createTests
self.module)
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 103, in loadTestsFromName
return self.loadTestsFromModule(obj)
File "/usr/lib/python2.7/site-packages/setuptools/command/test.py", line 35, in loadTestsFromModule
tests.append(self.loadTestsFromName(submodule))
File "/usr/lib/python2.7/unittest/loader.py", line 103, in loadTestsFromName
return self.loadTestsFromModule(obj)
File "/usr/lib/python2.7/site-packages/setuptools/command/test.py", line 35, in loadTestsFromModule
tests.append(self.loadTestsFromName(submodule))
File "/usr/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
module = __import__('.'.join(parts_copy))
File "/builddir/build/BUILD/python-semanticversion-2.2.2/tests/django_test_app/models.py", line 5, in
from django.db import models
File "/usr/lib/python2.7/site-packages/django/db/__init__.py", line 11, in
if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:
File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 46, in _setup
% (desc, ENVIRONMENT_VARIABLE))
```