conftest.py 1002 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import pytest
  2. @pytest.fixture
  3. def graphics_pipe(scope='session'):
  4. from panda3d.core import GraphicsPipeSelection
  5. pipe = GraphicsPipeSelection.get_global_ptr().make_default_pipe()
  6. if not pipe.is_valid():
  7. pytest.xfail("GraphicsPipe is invalid")
  8. yield pipe
  9. @pytest.fixture
  10. def graphics_engine(scope='session'):
  11. from panda3d.core import GraphicsEngine
  12. engine = GraphicsEngine.get_global_ptr()
  13. yield engine
  14. @pytest.fixture
  15. def window(graphics_pipe, graphics_engine):
  16. from panda3d.core import GraphicsPipe, FrameBufferProperties, WindowProperties
  17. fbprops = FrameBufferProperties.get_default()
  18. winprops = WindowProperties.get_default()
  19. win = graphics_engine.make_output(
  20. graphics_pipe,
  21. 'window',
  22. 0,
  23. fbprops,
  24. winprops,
  25. GraphicsPipe.BF_require_window
  26. )
  27. graphics_engine.open_windows()
  28. assert win is not None
  29. yield win
  30. if win is not None:
  31. graphics_engine.remove_window(win)