#11309 closed enhancement (fixed)
Improve error message when executing a functional test module without Twill installed
| Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.0.2 |
| Component: | general | Version: | 1.0-stable |
| Severity: | normal | Keywords: | functional tests |
| Cc: | Branch: | ||
| Release Notes: |
An |
||
| API Changes: | |||
| Internal Changes: | |||
Description
If a functional test module (other than trac.tests.functional) is executed without twill installed, the following error results:
PYTHONPATH=. ./trac/timeline/tests/functional.py Traceback (most recent call last): File "./trac/timeline/tests/functional.py", line 52, in <module> unittest.main(defaultTest='functionalSuite') File "/usr/lib/python2.5/unittest.py", line 767, in __init__ self.parseArgs(argv) File "/usr/lib/python2.5/unittest.py", line 794, in parseArgs self.createTests() File "/usr/lib/python2.5/unittest.py", line 800, in createTests self.module) File "/usr/lib/python2.5/unittest.py", line 565, in loadTestsFromNames suites = [self.loadTestsFromName(name, module) for name in names] File "/usr/lib/python2.5/unittest.py", line 553, in loadTestsFromName test = obj() File "./trac/timeline/tests/functional.py", line 46, in functionalSuite suite = trac.tests.functional.testcases.functionalSuite() File "/home/user/Workspace/t11244/teo-rjollos.git/trac/tests/functional/testcases.py", line 240, in functionalSuite suite = FunctionalTestSuite() NameError: global name 'FunctionalTestSuite' is not defined
After the proposed change, the traceback and exception message will be:
PYTHONPATH=. python ./trac/timeline/tests/functional.py Traceback (most recent call last): File "./trac/timeline/tests/functional.py", line 52, in <module> unittest.main(defaultTest='functionalSuite') File "/usr/lib/python2.5/unittest.py", line 767, in __init__ self.parseArgs(argv) File "/usr/lib/python2.5/unittest.py", line 794, in parseArgs self.createTests() File "/usr/lib/python2.5/unittest.py", line 800, in createTests self.module) File "/usr/lib/python2.5/unittest.py", line 565, in loadTestsFromNames suites = [self.loadTestsFromName(name, module) for name in names] File "/usr/lib/python2.5/unittest.py", line 553, in loadTestsFromName test = obj() File "./trac/timeline/tests/functional.py", line 46, in functionalSuite suite = trac.tests.functional.testcases.functionalSuite() File "/home/user/Workspace/t11244/teo-rjollos.git/trac/tests/functional/testcases.py", line 240, in functionalSuite suite = FunctionalTestSuite() File "trac/tests/functional/__init__.py", line 155, in __init__ raise ImportError("Twill not installed") ImportError: Twill not installed
Attachments (0)
Change History (6)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
| Status: | new → assigned |
|---|
comment:3 by , 12 years ago
I've tested all the cases that I know of. When twill is not installed,
PYTHONPATH=. python setup.py test,PYTHONPATH=. python -m trac.test,PYTHONPATH=. python -m trac.tests.__init__,PYTHONPATH=. ./trac/tests/functional/__init__.py,PYTHONPATH=. python -m trac.tests.functional.__init__result in:SKIP: functional tests (Twill not installed)PYTHONPATH=. ./trac/tests/functional/testcases.py,PYTHONPATH=. python -m trac.tests.functional.testcases,PYTHONPATH=. python ./trac/wiki/tests/functional.pyresult in:Traceback (most recent call last): File "./trac/wiki/tests/functional.py", line 292, in <module> unittest.main(defaultTest='functionalSuite') 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 113, in loadTestsFromName test = obj() File "./trac/wiki/tests/functional.py", line 271, in functionalSuite suite = trac.tests.functional.testcases.functionalSuite() File "/home/user/Workspace/t11309/teo-rjollos.git/trac/tests/functional/testcases.py", line 245, in functionalSuite suite = FunctionalTestSuite() File "/home/user/Workspace/t11309/teo-rjollos.git/trac/tests/functional/__init__.py", line 156, in __init__ raise ImportError("Twill not installed") ImportError: Twill not installed
comment:4 by , 12 years ago
Side note: In [8027], close_fds was moved from trac.tests.functional.compat to trac.util.compat. There are two remaining uses of trac.tests.functional.compat that I'll modify to import from trac.util.compat. I suppose the unused import of close_fds in trac.tests.functional.compat should be left in place in case any plugins are using it, but maybe it should be removed on the trunk now or eventually. I also searched the codebase for close_fds, for cases were it could be utilized from trac.tests.functional.compat due to a wildcard import or similar, and found no additional places that it is used.
$ grep -R "import close_fds" .
./tracopt/versioncontrol/git/tests/PyGIT.py:from trac.util.compat import close_fds
./trac/db/mysql_backend.py:from trac.util.compat import close_fds
./trac/db/postgres_backend.py:from trac.util.compat import close_fds
./trac/notification.py:from trac.util.compat import close_fds
./trac/tests/functional/compat.py:from trac.util.compat import close_fds
./trac/tests/functional/svntestenv.py:from trac.tests.functional.compat import close_fds
./trac/tests/functional/testenv.py:from trac.util.compat import close_fds
./trac/tests/functional/__init__.py:from trac.tests.functional.compat import close_fds, rmtree
The import in trac.tests.function.__init__ is unused in that module.
comment:5 by , 12 years ago
| Release Notes: | modified (diff) |
|---|---|
| Resolution: | → fixed |
| Status: | assigned → closed |
comment:6 by , 12 years ago
Oh, I didn't mean to commit the part in [12124#file2]. I need to pay better attention!
[12124#file2] reverted on 1.0-stable in [12140], and merged to trunk in [12141].



Proposed change can be found in [d28271fd/rjollos.git].