diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_builtin.py | 10 | ||||
-rw-r--r-- | Lib/test/test_pprint.py | 15 | ||||
-rw-r--r-- | Lib/test/test_pyclbr.py | 6 |
3 files changed, 30 insertions, 1 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 52b337c21c7..a74cc84be44 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -499,6 +499,16 @@ class BuiltinTest(unittest.TestCase): self.assertRaises(TypeError, hasattr) self.assertEqual(False, hasattr(sys, chr(sys.maxunicode))) + # Check that hasattr allows SystemExit and KeyboardInterrupts by + class A: + def __getattr__(self, what): + raise KeyboardInterrupt + self.assertRaises(KeyboardInterrupt, hasattr, A(), "b") + class B: + def __getattr__(self, what): + raise SystemExit + self.assertRaises(SystemExit, hasattr, B(), "b") + def test_hash(self): hash(None) self.assertEqual(hash(1), hash(1)) diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py index a0cd01a0d04..ed352877f52 100644 --- a/Lib/test/test_pprint.py +++ b/Lib/test/test_pprint.py @@ -381,6 +381,21 @@ class QueryTestCase(unittest.TestCase): cubo = test.test_set.linegraph(cube) self.assertEqual(pprint.pformat(cubo), cubo_repr_tgt) + def test_depth(self): + nested_tuple = (1, (2, (3, (4, (5, 6))))) + nested_dict = {1: {2: {3: {4: {5: {6: 6}}}}}} + nested_list = [1, [2, [3, [4, [5, [6, []]]]]]] + self.assertEqual(pprint.pformat(nested_tuple), repr(nested_tuple)) + self.assertEqual(pprint.pformat(nested_dict), repr(nested_dict)) + self.assertEqual(pprint.pformat(nested_list), repr(nested_list)) + + lv1_tuple = '(1, (...))' + lv1_dict = '{1: {...}}' + lv1_list = '[1, [...]]' + self.assertEqual(pprint.pformat(nested_tuple, depth=1), lv1_tuple) + self.assertEqual(pprint.pformat(nested_dict, depth=1), lv1_dict) + self.assertEqual(pprint.pformat(nested_list, depth=1), lv1_list) + class DottedPrettyPrinter(pprint.PrettyPrinter): diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py index 64c8f18fa24..57ede896523 100644 --- a/Lib/test/test_pyclbr.py +++ b/Lib/test/test_pyclbr.py @@ -156,10 +156,14 @@ class PyclbrTest(TestCase): # These were once about the 10 longest modules cm('random', ignore=('Random',)) # from _random import Random as CoreGenerator cm('cgi', ignore=('log',)) # set with = in module - cm('urllib', ignore=('getproxies_registry', + cm('urllib', ignore=('_CFNumberToInt32', + '_CStringFromCFString', + 'getproxies_registry', 'proxy_bypass_registry', + 'proxy_bypass_macosx_sysconf', 'open_https', '_https_connection', + 'getproxies_macosx_sysconf', 'getproxies_internetconfig',)) # not on all platforms cm('pickle') cm('aifc', ignore=('openfp',)) # set with = in module |