diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-20 16:38:05 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-20 16:38:05 (GMT) |
commit | 1f507a81405dd7234dd97465d68fcc8437b5da0e (patch) | |
tree | e3b25316c9538b53bc7e73bb13ac9f1f4a801095 /Lib/test | |
parent | f54bcfb835d49c3f7c61bd9a7637bef1c6890166 (diff) | |
parent | cbfe07e06cb460986b37604bc32dad407cb33f62 (diff) | |
download | cpython-1f507a81405dd7234dd97465d68fcc8437b5da0e.zip cpython-1f507a81405dd7234dd97465d68fcc8437b5da0e.tar.gz cpython-1f507a81405dd7234dd97465d68fcc8437b5da0e.tar.bz2 |
Issue 24215: Added tests for more builtin types in test_pprint.
Made test_pprint and test_trace discoverable.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_pprint.py | 17 | ||||
-rw-r--r-- | Lib/test/test_trace.py | 12 |
2 files changed, 12 insertions, 17 deletions
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py index 9e5309c..357c5cf 100644 --- a/Lib/test/test_pprint.py +++ b/Lib/test/test_pprint.py @@ -91,7 +91,8 @@ class QueryTestCase(unittest.TestCase): def test_basic(self): # Verify .isrecursive() and .isreadable() w/o recursion pp = pprint.PrettyPrinter() - for safe in (2, 2.0, 2j, "abc", [3], (2,2), {3: 3}, "yaddayadda", + for safe in (2, 2.0, 2j, "abc", [3], (2,2), {3: 3}, b"def", + bytearray(b"ghi"), True, False, None, ..., self.a, self.b): # module-level convenience functions self.assertFalse(pprint.isrecursive(safe), @@ -161,21 +162,23 @@ class QueryTestCase(unittest.TestCase): # it sorted a dict display if and only if the display required # multiple lines. For that reason, dicts with more than one element # aren't tested here. - for simple in (0, 0, 0+0j, 0.0, "", b"", + for simple in (0, 0, 0+0j, 0.0, "", b"", bytearray(), (), tuple2(), tuple3(), [], list2(), list3(), set(), set2(), set3(), frozenset(), frozenset2(), frozenset3(), {}, dict2(), dict3(), self.assertTrue, pprint, - -6, -6, -6-6j, -1.5, "x", b"x", (3,), [3], {3: 6}, + -6, -6, -6-6j, -1.5, "x", b"x", bytearray(b"x"), + (3,), [3], {3: 6}, (1,2), [3,4], {5: 6}, tuple2((1,2)), tuple3((1,2)), tuple3(range(100)), [3,4], list2([3,4]), list3([3,4]), list3(range(100)), set({7}), set2({7}), set3({7}), frozenset({8}), frozenset2({8}), frozenset3({8}), dict2({5: 6}), dict3({5: 6}), - range(10, -11, -1) + range(10, -11, -1), + True, False, None, ..., ): native = repr(simple) self.assertEqual(pprint.pformat(simple), native) @@ -1005,9 +1008,5 @@ class DottedPrettyPrinter(pprint.PrettyPrinter): self, object, context, maxlevels, level) -def test_main(): - test.support.run_unittest(QueryTestCase) - - if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py index 2f2c584..03dff84 100644 --- a/Lib/test/test_trace.py +++ b/Lib/test/test_trace.py @@ -1,8 +1,7 @@ import os import io import sys -from test.support import (run_unittest, TESTFN, rmtree, unlink, - captured_stdout) +from test.support import TESTFN, rmtree, unlink, captured_stdout import unittest import trace @@ -301,7 +300,8 @@ class TestCoverage(unittest.TestCase): unlink(TESTFN) def _coverage(self, tracer, - cmd='from test import test_pprint; test_pprint.test_main()'): + cmd='import test.support, test.test_pprint;' + 'test.support.run_unittest(test.test_pprint.QueryTestCase)'): tracer.run(cmd) r = tracer.results() r.write_results(show_missing=True, summary=True, coverdir=TESTFN) @@ -411,9 +411,5 @@ class TestDeprecatedMethods(unittest.TestCase): trace.find_executable_linenos(fd.name) -def test_main(): - run_unittest(__name__) - - if __name__ == '__main__': - test_main() + unittest.main() |