Peter Bengtsson
unread,Oct 17, 2010, 12:12:20 PM10/17/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Tornado Web Server
I've had to change my test runner slightly because if I get any
ImportErrors raised anywhere in the running code it will raise an
AttributeError. Example:
Traceback (most recent call last):
File "_run_tests.py", line 28, in <module>
tornado.testing.main()
File "/home/peterbe/virtualenvs/worklog/lib/python2.6/site-packages/
tornado/testing.py", line 320, in main
unittest.main(module=None, defaultTest='__main__.all', argv=argv)
File "/usr/lib/python2.6/unittest.py", line 816, in __init__
self.parseArgs(argv)
File "/usr/lib/python2.6/unittest.py", line 843, in parseArgs
self.createTests()
File "/usr/lib/python2.6/unittest.py", line 849, in createTests
self.module)
File "/usr/lib/python2.6/unittest.py", line 613, in
loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib/python2.6/unittest.py", line 598, in
loadTestsFromName
test = obj()
File "_run_tests.py", line 13, in all
return unittest.defaultTestLoader.loadTestsFromNames(TEST_MODULES)
File "/usr/lib/python2.6/unittest.py", line 613, in
loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib/python2.6/unittest.py", line 584, in
loadTestsFromName
parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'test_app'
Below is a necessary hack I had to put in so that I get the right
error exception raised. Is this something we can do anything about in
Tornado or a problem with Python 2.6's unittest?
#!/usr/bin/env python
import unittest
TEST_MODULES = [
'tests.test_app',
'tests.test_api',
'tests.test_models',
'tests.test_utils',
]
def all():
try:
return
unittest.defaultTestLoader.loadTestsFromNames(TEST_MODULES)
except AttributeError, e:
if "'module' object has no attribute 'test_app'" in str(e):
# most likely because of an import error
for m in TEST_MODULES:
__import__(m, globals(), locals())
raise
if __name__ == '__main__':
import tornado.testing
#import cProfile, pstats
#cProfile.run('tornado.testing.main()')
tornado.testing.main()