[issue9315] The trace module lacks unit tests

Alexander Belopolsky report at bugs.python.org
Sun Jul 25 18:21:24 CEST 2010


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

Eli,

test_trace_module.py is a good start and I would like to commit it soon.  I have a few nitpicks and a suggestion.

1. pprint module is not used in the tests so it should not be imported.
2. It is better to do run_unittest(__name__) in test_main() than list tests explicitly.  run_unittest(__name__) will find all classes that derive from TestCase in the module.  Note that not all test runners use test_main().
3. Please don't start docstrings with a space.
4. test_trace is out of the way in 2.7 now, so you can use proper name.  If you use SVN, please do svn add Lib/test/test_trace.py with your next revision and post the output of svn diff.
5. A suggestion: since we are doing "white-box" testing of the Trace class, I would recommend calling Trace methods such as globaltrace or localtrace directly from unit tests rather than rely on settrace registrations.  That may require faking frames, but I think you can get away with simply passing the current frame with the events. Whether or not sys.settrace is working correctly is tested in the old test_trace (renamed to test_sys_settrace) now.

Thanks for moving this forward.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9315>
_______________________________________


More information about the Python-bugs-list mailing list