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

Method test_invocation

Lib/test/test_dis.py:2562–2586  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2560 self.assertListEqual(res.splitlines(), expect.splitlines())
2561
2562 def test_invocation(self):
2563 # test various combinations of parameters
2564 base_flags = [
2565 ('-C', '--show-caches'),
2566 ('-O', '--show-offsets'),
2567 ('-P', '--show-positions'),
2568 ('-S', '--specialized'),
2569 ]
2570
2571 self.set_source('''
2572 def f():
2573 print(x)
2574 return None
2575 ''')
2576
2577 for r in range(1, len(base_flags) + 1):
2578 for choices in itertools.combinations(base_flags, r=r):
2579 for args in itertools.product(*choices):
2580 with self.subTest(args=args[1:]):
2581 _ = self.invoke_dis(*args)
2582
2583 with self.assertRaises(SystemExit):
2584 # suppress argparse error message
2585 with contextlib.redirect_stderr(io.StringIO()):
2586 _ = self.invoke_dis('--unknown')
2587
2588 def test_show_cache(self):
2589 # test 'python -m dis -C/--show-caches'

Callers

nothing calls this directly

Calls 4

set_sourceMethod · 0.95
invoke_disMethod · 0.95
subTestMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected