MCPcopy Index your code
hub / github.com/python/cpython / test_enums

Method test_enums

Lib/test/test_signal.py:28–65  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

26class GenericTests(unittest.TestCase):
27
28 def test_enums(self):
29 for name in dir(signal):
30 sig = getattr(signal, name)
31 if name in {'SIG_DFL', 'SIG_IGN'}:
32 self.assertIsInstance(sig, signal.Handlers)
33 elif name in {'SIG_BLOCK', 'SIG_UNBLOCK', 'SIG_SETMASK'}:
34 self.assertIsInstance(sig, signal.Sigmasks)
35 elif name.startswith('SIG') and not name.startswith('SIG_'):
36 self.assertIsInstance(sig, signal.Signals)
37 elif name.startswith('CTRL_'):
38 self.assertIsInstance(sig, signal.Signals)
39 self.assertEqual(sys.platform, "win32")
40
41 CheckedSignals = enum._old_convert_(
42 enum.IntEnum, 'Signals', 'signal',
43 lambda name:
44 name.isupper()
45 and (name.startswith('SIG') and not name.startswith('SIG_'))
46 or name.startswith('CTRL_'),
47 source=signal,
48 )
49 enum._test_simple_enum(CheckedSignals, signal.Signals)
50
51 CheckedHandlers = enum._old_convert_(
52 enum.IntEnum, 'Handlers', 'signal',
53 lambda name: name in ('SIG_DFL', 'SIG_IGN'),
54 source=signal,
55 )
56 enum._test_simple_enum(CheckedHandlers, signal.Handlers)
57
58 Sigmasks = getattr(signal, 'Sigmasks', None)
59 if Sigmasks is not None:
60 CheckedSigmasks = enum._old_convert_(
61 enum.IntEnum, 'Sigmasks', 'signal',
62 lambda name: name in ('SIG_BLOCK', 'SIG_UNBLOCK', 'SIG_SETMASK'),
63 source=signal,
64 )
65 enum._test_simple_enum(CheckedSigmasks, Sigmasks)
66
67 def test_functions_module_attr(self):
68 # Issue #27718: If __all__ is not defined all non-builtin functions

Callers

nothing calls this directly

Calls 4

assertIsInstanceMethod · 0.80
isupperMethod · 0.80
startswithMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected