[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/master] Add test_Tests.MonkeypatchedOldUnittests class.



commit a618ded894d5f6339303119853161ca5fe6a5faa
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Fri Dec 20 03:26:31 2013 +0000

    Add test_Tests.MonkeypatchedOldUnittests class.
    
    This is precisely the same as `test_Tests.OldUnittests`, except that it
    re-runs all of the old unittests in lib/bridgedb/Tests.py with old code from
    `bridgedb.test.deprecated` to assist in finding regressions.
---
 lib/bridgedb/test/test_Tests.py |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/lib/bridgedb/test/test_Tests.py b/lib/bridgedb/test/test_Tests.py
index d45d27a..4afa0fd 100644
--- a/lib/bridgedb/test/test_Tests.py
+++ b/lib/bridgedb/test/test_Tests.py
@@ -208,3 +208,30 @@ class OldUnittests(unittest.TestCase):
     testResult    = unittest.PyUnitResultAdapter(pyunit.TestResult())
     methodPrefix  = 'test_regressionsNewCode_'
 
+
+class MonkeypatchedOldUnittests(unittest.TestCase):
+    """A wrapper around :mod:`bridgedb.Tests` to produce :mod:`~twisted.trial`
+    compatible output.
+
+    For each test in this ``TestCase``, one of the old unittests in
+    bridgedb/Tests.py is run. For all of the tests, some functions and classes
+    are :func:`monkey.MonkeyPatcher.patch`ed with old, deprecated code from
+    :mod:`bridgedb.test.deprecated` to ensure that any new code has not caused
+    any regressions.
+    """
+    __metaclass__ = DynamicTestCaseMeta
+    testSuites    = Tests.testSuite()
+    testResult    = unittest.PyUnitResultAdapter(pyunit.TestResult())
+    methodPrefix  = 'test_regressionsOldCode_'
+    patcher       = monkeypatchTests()
+
+    def runWithPatches(self, *args):
+        """Replaces :meth:`~twisted.trial.unittest.TestCase.run` as the default
+        methodName to run. This method calls ``run()`` though
+        ``self.patcher.runWithPatches``, using the class **testResult** object.
+        """
+        self.patcher.runWithPatches(self.run, self.testResult)
+        self.patcher.restore()
+
+    def __init__(self, methodName='runWithPatches'):
+        super(MonkeypatchedOldUnittests, self).__init__(methodName=methodName)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits