Be able to run django tests in pyunit view
Brought to you by:
fabioz
Currently django tests won't run in pyunit view (probably with what look like circular imports kind of problem, traceback attached).
Would be very good if they could.
steps to reproduce:
from a django project with a new app 'quick_test':
You can run the (automaticlaly generated) tests for the app from the command line with:
python manage.py test quick_test
But running from the pyunit view gives a traceback (attached)
Using pydev 1.6.5 and django release version under python 2.6 (on OSX 10.6.6)
traceback
Fixed for 1.7.0 (please check if it works for you in the latest nightly build).
Git
0e3411d 1300888061 2011-03-23 fabioz Adding DJANGO_SETTINGS_MODULE environment var when making a launch (so that the test runners work accordingly).
Doesn't seem to work for me -- gives very similar traceback ( ImportError: cannot import name signals)
I tried adding the DJANGO_SETTINGS_MODULE environment variable manually (${resource_loc:/blah//settings.py} but same result no difference.
Tried using 1.7.0.2011032302 in latest nightly of Aptana3.
I have a zip file of the project I used, but can't seem to attach it to this (because it is closed?)
Probably... changed to accepted so that you can try to attach it.
django project with src/newapp/tests.py that fails
Note that the DJANGO_SETTINGS_MODULE is the name of the module (i.e.: just quickdjangotest.settings, not using the resource location).
Can you recheck again with the latest nightly (it could be just a timing issue) -- also note that in your example there were some things I had to fix for it to work for me, like removing django.contrib.staticfiles because it wasn't available here, recreating the database and adding 'SUPPORTS_TRANSACTIONS' as False to the settings, but those would give different tracebacks when running the unit-test.
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 15 days (the time period specified by
the administrator of this Tracker).
I've tried this with an existing project (not with my super simple test case, but it gave the same problems before) and two issues:
1) I'm still just manually adding the DJANGO_SETTINGS_MODULE in the environment of each test configuration - is that what I'm meant to do (I don't see anywhere else to specify it)
2) I'm still getting a traceback (but a different (and later) traceback from before):
Finding files... done.
Importing test modules ... done.
Traceback (most recent call last):
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_1.7.0.2011032302/pysrc/runfiles.py", line 154, in <module>
main()
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_1.7.0.2011032302/pysrc/runfiles.py", line 68, in main
pydev_runfiles.main(configuration)
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_1.7.0.2011032302/pysrc/pydev_runfiles.py", line 581, in main
PydevTestRunner(configuration).run_tests()
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_1.7.0.2011032302/pysrc/pydev_runfiles.py", line 568, in run_tests
runner.run(test_suite)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 753, in run
test(result)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 464, in __call__
return self.run(*args, **kwds)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 460, in run
test(result)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 464, in __call__
return self.run(*args, **kwds)
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_1.7.0.2011032302/pysrc/pydev_runfiles_unittest.py", line 111, in run
test(result)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 464, in __call__
return self.run(*args, **kwds)
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_1.7.0.2011032302/pysrc/pydev_runfiles_unittest.py", line 111, in run
test(result)
File "/Users/tim/tech/python/environments/imevq/lib/python2.6/site-packages/django/test/testcases.py", line 297, in __call__
result.addError(self, sys.exc_info())
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_1.7.0.2011032302/pysrc/pydev_runfiles_unittest.py", line 92, in addError
self._current_errors_stack.append(self.errors[-1])
AttributeError: 'PydevTestResult' object has no attribute '_current_errors_stack'
The last stack trace you gave should be already fixed, can you try to rerun it with the latest nightly and see if there's still something failing?
django test runs now working for me within pydev