Edgewall Software

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#11284 closed enhancement (fixed)

Replace deprecated unittest method aliases — at Version 7

Reported by: Ryan J Ollos Owned by:
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 tests to utilize new methods in trac.tests.compat.

API Changes:

The trac.tests.compat contains unittest.TestCase methods that are available in Python 2.7, such as assertIn and assertIs.

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.

Change History (7)

comment:1 by Ryan J Ollos, 6 years ago

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.

Last edited 6 years ago by Ryan J Ollos (previous) (diff)

comment:2 by Jun Omae, 6 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].

in reply to:  2 comment:3 by Ryan J Ollos, 6 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 Ryan J Ollos, 6 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'

comment:5 by Ryan J Ollos, 6 years ago

Latest proposed changes can be found in rjollos.git:t11284.2.

in reply to:  5 comment:6 by Jun Omae, 6 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 Ryan J Ollos, 6 years ago

API Changes: modified (diff)
Milestone: 1.0.2
Priority: normallow
Release Notes: modified (diff)
Resolution: fixed
Status: newclosed

Committed to 1.0-stable in [12070:12079] and merged to trunk in [12080].

Note: See TracTickets for help on using tickets.