#11332 closed enhancement (fixed)
Allow test cases in `trac.tests.functional.testcases` to be run in isolation
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.2 |
Component: | general | Version: | |
Severity: | normal | Keywords: | functional tests |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: |
Reorganized tests cases so that |
||
Internal Changes: |
Description (last modified by )
It is currently not possible to execute the test cases in trac.tests.functional.testcases
in isolation since trac.tests.functional.testcases:suite
adds all of the functional test cases in the project to the functionalSuite
. The only workaround is to comment out addTest
calls. It should be possible resolve this issue by instead building the suite for the entire project in trac.tests.functional.__init__
.
Attachments (0)
Change History (5)
follow-up: 4 comment:1 by , 11 years ago
comment:2 by , 11 years ago
Status: | new → assigned |
---|
comment:3 by , 11 years ago
comment:4 by , 11 years ago
Replying to rjollos:
With the changes in log:rjollos.git:t11332,
python -m trac.tests.functional.__init__
executes the entire functional test suite andpython -m trac.tests.functional.testcases
executes just the test cases in that module.
I'm not sure why I haven't encountered this error until just now, but I'm seeing:
$ python --version Python 2.5.6 $ PYTHONPATH=. python -m trac.tests.functional.__init__ SKIP: validation of XHTML output in functional tests (no lxml installed) SKIP: fine-grained permission tests. ConfigObj not installed. Traceback (most recent call last): File "/usr/lib/python2.5/runpy.py", line 95, in run_module filename, loader, alter_sys) File "/usr/lib/python2.5/runpy.py", line 52, in _run_module_code mod_name, mod_fname, mod_loader) File "/usr/lib/python2.5/runpy.py", line 32, in _run_code exec code in run_globals File "/home/user/Workspace/t11329/teo-rjollos.git/trac/tests/functional/__init__.py", line 78, in <module> from better_twill import twill, b, tc, ConnectError ImportError: No module named better_twill
The issue is fixed by:
-
trac/tests/functional/__init__.py
diff --git a/trac/tests/functional/__init__.py b/trac/tests/functional/__init__. index 9166e74..5d436ed 100755
a b from trac.util.compat import close_fds 75 75 # is allowed to load first, its (unmodified) copy will always be loaded. 76 76 import subprocess 77 77 78 from better_twill import twill, b, tc, ConnectError78 from trac.tests.functional.better_twill import twill, b, tc, ConnectError 79 79 80 80 try: 81 81 # This is the first indicator of whether the subversion bindings are
Here is a brief description of what I see, in order to provide justification for the proposed changes.
trac/tests
contains unit test modules for each module located directly intrac/
(e.g. the test module fortrac/attachments.py
istrac/tests/attachment.py
). For each package that has functional tests, the tests are located infunctional.py
within thetests
directory. There is one exception - since there is a directorytrac/tests/functional
, rather than having a functional tests moduletrac/tests/functional.py
, the tests reside intrac/tests/functional/testcases.py
. I assume it was done this was to avoid possible ambiguity when importing fromtrac.tests.functional
.The changes proposed in log:rjollos.git:t11332 make
trac/tests/functional/testcases.py
a standalone functional test module just like, e.g.,trac/admin/tests/functional.py
ortrac/ticket/tests/functional.py
, andtrac/tests/functional/__init__.py
becomes the test runner for all of the functional tests.Previously, both
python -m trac.tests.functional.__init__
andpython -m trac.tests.functional.testcases
execute the entire functional test suite. With the changes in log:rjollos.git:t11332,python -m trac.tests.functional.__init__
executes the entire functional test suite andpython -m trac.tests.functional.testcases
executes just the test cases in that module.