MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_local_translator

Function test_local_translator

tests/test_exceptions.py:278–293  ·  view source on GitHub ↗

Tests that a local translator works and that the local translator from the cross module is not applied

(msg)

Source from the content-addressed store, hash-verified

276
277
278def test_local_translator(msg):
279 """Tests that a local translator works and that the local translator from
280 the cross module is not applied"""
281 with pytest.raises(RuntimeError) as excinfo:
282 m.throws6()
283 assert msg(excinfo.value) == "MyException6 only handled in this module"
284
285 with pytest.raises(RuntimeError) as excinfo:
286 m.throws_local_error()
287 assert not isinstance(excinfo.value, KeyError)
288 assert msg(excinfo.value) == "never caught"
289
290 with pytest.raises(Exception) as excinfo:
291 m.throws_local_simple_error()
292 assert not isinstance(excinfo.value, cm.LocalSimpleException)
293 assert msg(excinfo.value) == "this mod"
294
295
296def test_error_already_set_message_with_unicode_surrogate(): # Issue #4288

Callers

nothing calls this directly

Calls 2

msgFunction · 0.85
isinstanceFunction · 0.85

Tested by

no test coverage detected