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

Function test_register_duplicate_class

tests/test_class.py:511–540  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

509
510
511def test_register_duplicate_class():
512 import types
513
514 module_scope = types.ModuleType("module_scope")
515 with pytest.raises(RuntimeError) as exc_info:
516 m.register_duplicate_class_name(module_scope)
517 expected = (
518 'generic_type: cannot initialize type "Duplicate": '
519 "an object with that name is already defined"
520 )
521 assert str(exc_info.value) == expected
522 with pytest.raises(RuntimeError) as exc_info:
523 m.register_duplicate_class_type(module_scope)
524 expected = 'generic_type: type "YetAnotherDuplicate" is already registered!'
525 assert str(exc_info.value) == expected
526
527 class ClassScope:
528 pass
529
530 with pytest.raises(RuntimeError) as exc_info:
531 m.register_duplicate_nested_class_name(ClassScope)
532 expected = (
533 'generic_type: cannot initialize type "DuplicateNested": '
534 "an object with that name is already defined"
535 )
536 assert str(exc_info.value) == expected
537 with pytest.raises(RuntimeError) as exc_info:
538 m.register_duplicate_nested_class_type(ClassScope)
539 expected = 'generic_type: type "YetAnotherDuplicateNested" is already registered!'
540 assert str(exc_info.value) == expected
541
542
543def test_pr4220_tripped_over_this():

Callers

nothing calls this directly

Calls 1

strClass · 0.85

Tested by

no test coverage detected