[tor-commits] [bridgedb/master] Add trial runner/report class adapter for old unittests.

isis at torproject.org isis at torproject.org
Sun Jan 12 06:06:34 UTC 2014


commit 127087eef72df5f052638bf8a770728800c15fb1
Author: Isis Lovecruft <isis at torproject.org>
Date:   Thu Nov 21 07:45:04 2013 +0000

    Add trial runner/report class adapter for old unittests.
    
    This adds a new unittest file, `lib/bridgedb/test/test_Tests.py`, which
    runs the old unittests in `lib/bridgedb/Tests.py` with a unittest report
    adapter that is compatible with twisted.trial. It uses the underlying
    SynchronousTestCase wrapper for the stdlib `unittest.TestCase` (which
    the tests in `lib/bridgedb/Tests.py` use).
    
     * ADDS a trial runner for BridgeDB's old unittests.
     * FIXES #9873
---
 lib/bridgedb/test/test_Tests.py |   44 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/lib/bridgedb/test/test_Tests.py b/lib/bridgedb/test/test_Tests.py
new file mode 100644
index 0000000..6801565
--- /dev/null
+++ b/lib/bridgedb/test/test_Tests.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of BridgeDB, a Tor bridge distribution system.
+#
+# :authors: Isis Lovecruft 0xA3ADB67A2CDB8B35 <isis at torproject.org>
+#           please also see AUTHORS file
+# :copyright: (c) 2013, Isis Lovecruft
+#             (c) 2007-2013, The Tor Project, Inc.
+#             (c) 2007-2013, all entities within the AUTHORS file
+# :license: 3-Clause BSD, see LICENSE for licensing information
+
+"""Class wrappers to adapt BridgeDB old unittests in :mod:`bridgedb.Tests` to
+be compatible with the newer :mod:`twisted.trial` unittests in this directory.
+"""
+
+from __future__ import print_function
+
+import logging
+import warnings
+
+from twisted.trial import unittest
+
+from bridgedb import Tests
+from bridgedb.Tests import EmailBridgeDistTests
+from bridgedb.Tests import IPBridgeDistTests
+from bridgedb.Tests import DictStorageTests
+from bridgedb.Tests import SQLStorageTests
+from bridgedb.Tests import ParseDescFileTests
+from bridgedb.Tests import BridgeStabilityTests
+
+logging.warnings.filterwarnings('ignore', module="Tests")
+pyunit = __import__('unittest')
+
+
+class TrialAdaptedOldUnittests(unittest.TestCase):
+    """A wrapper around :mod:`bridgedb.Tests` to produce :mod:`~twisted.trial`
+    compatible output.
+    """
+
+    def test_allOldUnittests(self):
+        testSuite = Tests.testSuite()
+        testResult = pyunit.TestResult()
+        testSuite.run(testResult, debug=True)
+        return unittest.PyUnitResultAdapter(testResult)





More information about the tor-commits mailing list