#11284 closed enhancement (fixed)
Replace deprecated unittest method aliases
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | low | Milestone: | 1.0.2 |
Component: | general | Version: | 1.0-stable |
Severity: | normal | Keywords: | unit tests |
Cc: | Branch: | ||
Release Notes: |
Replaced deprecated unit test method aliases, and refactored unit tests to utilize new methods in |
||
API Changes: |
The |
||
Internal Changes: |
Description
Several unittest method aliases are deprecated since Python 2.7. Although it is not necessary to make the changes now, it seems like a good step toward making the codebase more readable, and better to make all the changes at once.
Attachments (0)
Change History (16)
follow-up: 3 comment:2 by , 11 years ago
Additionally, it would be good to add trac.tests.compat
module rather than adding test functions in each testcase class. The module provides test functions since 2.7 for backwards-compatibility with 2.5-2.6. The changes is in [f8a7f571/jomae.git].
comment:3 by , 11 years ago
Replying to jomae:
… The changes is in [f8a7f571/jomae.git].
That looks great! I was hoping there was a nice way to accomplish that without subclassing unittest.TestCase
, but I didn't see the way until you showed me.
If you decide to push those change to the trunk soon that would work fine, otherwise I can push them after I finish refactoring some of the unit tests this coming weekend.
comment:4 by , 11 years ago
Not sure what is going on yet, but trac.mimeview.tests.pygments
can't be executed in isolation:
user@ubuntu:~/Workspace/trac-1.0-stable$ PYTHONPATH=. python trac/mimeview/tests/pygments.py Traceback (most recent call last): File "trac/mimeview/tests/pygments.py", line 21, in <module> pygments = __import__('pygments', {}, {}, []) File "/home/user/Workspace/trac-1.0-stable/trac/mimeview/tests/pygments.py", line 28, in <module> from trac.mimeview.pygments import PygmentsRenderer File "/home/user/Workspace/trac-1.0-stable/trac/mimeview/pygments.py", line 35, in <module> get_all_lexers = pygments.lexers.get_all_lexers AttributeError: 'module' object has no attribute 'lexers'
follow-up: 6 comment:5 by , 11 years ago
Latest proposed changes can be found in rjollos.git:t11284.2.
comment:6 by , 11 years ago
Replying to rjollos:
Not sure what is going on yet, but
trac.mimeview.tests.pygments
can't be executed in isolation:
Try like this:
$ PYTHONPATH=. ~/venv/py25/bin/python -m trac.mimeview.tests.pygments ..... ---------------------------------------------------------------------- Ran 5 tests in 0.427s OK
Replying to rjollos:
Latest proposed changes can be found in rjollos.git:t11284.2.
LGTM, verified with Python 2.5-2.7.
comment:7 by , 11 years ago
API Changes: | modified (diff) |
---|---|
Milestone: | → 1.0.2 |
Priority: | normal → low |
Release Notes: | modified (diff) |
Resolution: | → fixed |
Status: | new → closed |
Committed to 1.0-stable in [12070:12079] and merged to trunk in [12080].
comment:8 by , 11 years ago
Owner: | set to |
---|
comment:9 by , 11 years ago
comment:10 by , 11 years ago
I've found missing use of trac.tests.compat
in tracopt/versioncontrol/svn/tests/svn_fs.py
. Fixed in [12104] and merged into trunk in [12105].
$ PYTHONPATH=. ~/venv/py25/bin/python ./tracopt/versioncontrol/svn/tests/svn_fs.py .........................E........EE..............EE.........................E........EE..............EE..........E................E..........E.................EE.... ====================================================================== ERROR: test_get_dir_content (__main__.SubversionRepositoryNormalTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "./tracopt/versioncontrol/svn/tests/svn_fs.py", line 200, in test_get_dir_content self.assertIsNone(node.content_length) AttributeError: 'SubversionRepositoryNormalTests' object has no attribute 'assertIsNone' ... ---------------------------------------------------------------------- Ran 166 tests in 35.618s FAILED (errors=15)
comment:11 by , 11 years ago
comment:12 by , 11 years ago
Keywords: | unit tests added |
---|
comment:13 by , 11 years ago
Keywords: | unittest removed |
---|
follow-up: 15 comment:14 by , 11 years ago
I've ended up with a mix of the following two statements in the codebase:
from trac.tests import compat
import trac.tests.compat
The latter seems to be better in order to emphasize that we are importing a module but not using any specific functions from it. The former could be confused with the import of a function.
comment:15 by , 11 years ago
import trac.tests.compatThe latter seems to be better in order to emphasize that we are importing a module but not using any specific functions from it. The former could be confused with the import of a function.
Yes. I agreed.
Changes prepared in rjollos.git:t11284. I'll probably make another pass through and try to clean up some of the logic, like what was done in 237f3ea8/rjollos.git.