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

[tor-commits] [stem/master] Test re-run command broken with python 3.1+



commit 757a61454d1c3be2eb68a9afb481eae1a0ed6130
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Fri Nov 6 15:17:11 2020 -0800

    Test re-run command broken with python 3.1+
    
    Python's unittest module added the first line of our docstrings to the test
    output...
    
      https://docs.python.org/3/library/unittest.html#unittest.TestCase.shortDescription
    
    This broke our code that provides a command to re-run test failures. That is to
    say, rather than presenting...
    
      TESTING FAILED (9 seconds)
        [UNIT TEST] test_download (test.unit.descriptor.remote.TestDescriptorDownloader) ... FAIL
    
      You can re-run just these tests with:
    
        ./run_tests.py --unit --test descriptor.remote
    
    ... we lacked the last line.
---
 stem/util/test_tools.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/stem/util/test_tools.py b/stem/util/test_tools.py
index 96aae590..7343e674 100644
--- a/stem/util/test_tools.py
+++ b/stem/util/test_tools.py
@@ -248,6 +248,14 @@ class TimedTestRunner(unittest.TextTestRunner):
 
           return self.assertRaisesRegexp(exc_type, '^%s$' % re.escape(exc_msg), *args, **kwargs)
 
+        def shortDescription(self):
+          # Python now prints the first line of a test's docstring by default.
+          # This breaks our output parsers so disabling the feature...
+          #
+          #   https://stackoverflow.com/questions/12962772/how-to-stop-python-unittest-from-printing-test-docstring
+
+          return None
+
         def id(self) -> str:
           return '%s.%s.%s' % (original_type.__module__, original_type.__name__, self._testMethodName)
 



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