praekelt/django-setuptest — pull request #14 by kezabelle (2014-01-28 17:46:51+00:00)
Title: Provide stacktrace information when building tests

When an ImportError (or ImproperlyConfigured) is raised as part of a package's dependencies, print the traceback that generated it to stdout, so that the error location is discoverable (because for whatever reason, ImportError and ImproperlyConfigured aren't currently considered reasons to fail the test suite.)

Original sample output:
```Warning: No module named 'urlparse'```

Revised sample output:
```
Warning: Traceback (most recent call last):
File "path/.tox/py33-1.6/lib/python3.3/site-packages/setuptest/setuptest.py", line 102, in build_tests
tests.append(build_suite(app))
File "path/.tox/py33-1.6/lib/python3.3/site-packages/django/test/simple.py", line 149, in build_suite
test_module = get_tests(app_module)
File "path/.tox/py33-1.6/lib/python3.3/site-packages/django/test/simple.py", line 101, in get_tests
test_module = import_module('.'.join(prefix + [TEST_MODULE]))
File "path/.tox/py33-1.6/lib/python3.3/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1584, in _gcd_import
File "", line 1565, in _find_and_load
File "", line 1532, in _find_and_load_unlocked
File "", line 584, in _check_name_wrapper
File "", line 1022, in load_module
File "", line 1003, in load_module
File "", line 560, in module_for_loader_wrapper
File "", line 868, in _load_module
File "", line 313, in _call_with_frames_removed
File "path/myapp/tests/__init__.py", line 13, in
from .utils import *
File "path/myapp/tests/utils.py", line 13, in
from myapp.utils import *
File "path/myapp/utils.py", line 2, in
from urlparse import urlparse
ImportError: No module named 'urlparse'
```

The information still goes to stdout via the `distutils.log` method, to avoid any non-zero exit code that might be raised by printing to stderr.