MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_instance_bypass

Method test_instance_bypass

Lib/test/test_contextlib.py:1100–1109  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1098 stack.callback(int)
1099
1100 def test_instance_bypass(self):
1101 class Example(object): pass
1102 cm = Example()
1103 cm.__enter__ = object()
1104 cm.__exit__ = object()
1105 stack = self.exit_stack()
1106 with self.assertRaisesRegex(TypeError, 'the context manager'):
1107 stack.enter_context(cm)
1108 stack.push(cm)
1109 self.assertIs(stack._exit_callbacks[-1][1], cm)
1110
1111 def test_dont_reraise_RuntimeError(self):
1112 # https://bugs.python.org/issue27122

Callers

nothing calls this directly

Calls 5

assertRaisesRegexMethod · 0.80
enter_contextMethod · 0.80
ExampleClass · 0.70
pushMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected