[tor-commits] [bridgedb/master] Add test_Tests.TrialAdaptedDoctests class.
isis at torproject.org
isis at torproject.org
Sun Jan 12 06:06:35 UTC 2014
commit fd4aa319c92651f37054e86a0a41db0699eb9010
Author: Isis Lovecruft <isis at torproject.org>
Date: Fri Dec 20 03:28:20 2013 +0000
Add test_Tests.TrialAdaptedDoctests class.
This class uses the dynamic doctest discovery mechanism,
`test_Tests.generateTrialAdaptedDoctestSuite`, to run all discovered
doctests. The generated methodnames in this `TestCase` correspond to
location in the source code where the doctest was discovered.
It also (somewhat) magically manages to print exception/failure
tracebacks for failed doctests in a manner which is compatible with
twisted.trial. The printed tracebacks will tell you:
1. Where the doctest is, and which line caused the exception.
2. What the expected result was supposed to be (according to the
doctest), compared with what it actually was when the doctest code
was run.
---
lib/bridgedb/test/test_Tests.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lib/bridgedb/test/test_Tests.py b/lib/bridgedb/test/test_Tests.py
index 4afa0fd..514e90c 100644
--- a/lib/bridgedb/test/test_Tests.py
+++ b/lib/bridgedb/test/test_Tests.py
@@ -235,3 +235,15 @@ class MonkeypatchedOldUnittests(unittest.TestCase):
def __init__(self, methodName='runWithPatches'):
super(MonkeypatchedOldUnittests, self).__init__(methodName=methodName)
+
+
+class TrialAdaptedDoctests(unittest.TestCase):
+ """Discovers and runs all doctests within the ``bridgedb`` package.
+
+ Finds all doctests from the directory that BridgeDB was installed in, in
+ all Python modules and packages, and runs them with :mod:`twisted.trial`.
+ """
+ __metaclass__ = DynamicTestCaseMeta
+ testSuites = generateTrialAdaptedDoctestsSuite()
+ testResult = unittest.PyUnitResultAdapter(pyunit.TestResult())
+ methodPrefix = 'test_doctestsIn_'
More information about the tor-commits
mailing list