/usr/lib/python2.7/dist-packages/traits/testing/doctest_tools.py is in python-traits 4.6.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | """ Tools for having doctest and unittest work together more nicely.
Eclipse's PyDev plugin will run your unittest files for you very nicely.
The doctest_for_module function allows you to easily run the doctest for a
module along side your standard unit tests within Eclipse.
"""
# Standard library imports
import doctest
from traits.testing.unittest_tools import unittest
import sys
def doctest_for_module(module):
""" Create a TestCase from a module's doctests that will be run by the
standard unittest.main().
Example tests/test_foo.py::
import unittest
import foo
from traits.testing.api import doctest_for_module
class FooTestCase(unittest.TestCase):
...
class FooDocTest(doctest_for_module(foo)):
pass
if __name__ == "__main__":
# This will run and report both FooTestCase and the doctests in
# module foo.
unittest.main()
Alternatively, you can say::
FooDocTest = doctest_for_module(foo)
instead of::
class FooDocTest(doctest_for_module(foo)):
pass
"""
class C(unittest.TestCase):
def test_dummy(self): pass # Make the test case loader find us
def run(self, result=None):
# doctest doesn't like nose.result.TextTestResult objects,
# so we try to determine if thats what we're dealing
# with and use its internal result attribute instead
if hasattr(result, 'result'):
doctest.DocTestSuite(module).run(result.result)
else:
doctest.DocTestSuite(module).run(result)
return C
|