test_typeregistry.py 847 B

1234567891011121314151617181920212223242526
  1. from panda3d.core import TypeRegistry
  2. import pytest
  3. def test_get_type_name():
  4. # We test the get_type_name macro by checking for the existence of a type
  5. # that has been registered using it, and that it has the name we expect
  6. # (without weird extra mangling characters)
  7. # The type we're testing is registered by EggNode.
  8. pytest.importorskip("panda3d.egg")
  9. registry = TypeRegistry.ptr()
  10. found = False
  11. for type in registry.typehandles:
  12. if type.name.startswith('RefCountObj<') and 'LMatrix4d' in type.name:
  13. found = True
  14. break
  15. # This is an assert, not a skip, so that we are sure to change the example
  16. # if it ever becomes invalid
  17. assert found
  18. assert type.name == 'RefCountObj<LMatrix4d>'
  19. assert any(parent.name == 'LMatrix4d' for parent in type.parent_classes)