picogl.tests.test_meshdata
Unit tests for the MeshData class in the PicoGL OpenGL backend.
This module contains a comprehensive suite of unit tests for verifying the correctness,
robustness, and interface of the picogl.renderer.meshdata.MeshData
class, which manages OpenGL mesh data and rendering state.
The tests cover:
Object initialization with various buffer types
from_raw class method with different input scenarios
OpenGL binding/unbinding operations
Drawing operations with various modes and parameters
Context manager functionality
Utility methods and data conversion
Error handling and edge cases
Data validation and type conversion
- Dependencies:
unittest (standard library)
unittest.mock.MagicMock for OpenGL function mocking
numpy for test data
picogl.renderer.meshdata.MeshData
To run the tests:
python -m unittest picogl.tests.test_meshdata
Module Contents
-
class picogl.tests.test_meshdata.TestMeshData(methodName='runTest')[source]
Bases: unittest.TestCase
Test cases for MeshData class.
-
setUp()[source]
Set up test fixtures before each test method.
-
tearDown()[source]
Clean up after each test method.
-
test_initialization_with_all_buffers()[source]
Test MeshData initialization with all buffer types.
-
test_initialization_with_minimal_data()[source]
Test MeshData initialization with only vertices.
-
test_initialization_with_none_vertices()[source]
Test MeshData initialization with None vertices.
-
test_as_ribbon_args()[source]
Test as_ribbon_args method.
-
test_str_representation()[source]
Test string representation of MeshData.
-
test_to_float32_flat_with_valid_array()[source]
Test _to_float32_flat with valid array.
-
test_to_float32_flat_with_none_required()[source]
Test _to_float32_flat with None when required.
-
test_to_float32_flat_with_none_not_required()[source]
Test _to_float32_flat with None when not required.
-
test_to_float32_flat_or_none()[source]
Test _to_float32_flat_or_none method.
-
test_to_int32_flat_with_valid_array()[source]
Test _to_int32_flat with valid array.
-
test_to_int32_flat_with_none_required()[source]
Test _to_int32_flat with None when required.
-
test_default_colors_for_vertices()[source]
Test _default_colors_for_vertices method.
-
test_default_normals_for_vertices()[source]
Test _default_normals_for_vertices method.
-
test_from_raw_with_all_parameters()[source]
Test from_raw with all parameters provided.
-
test_from_raw_with_minimal_parameters()[source]
Test from_raw with only vertices.
-
test_from_raw_with_color_per_vertex_array()[source]
Test from_raw with color_per_vertex array.
-
test_from_raw_with_color_per_vertex_full_array()[source]
Test from_raw with color_per_vertex as full array.
-
test_from_raw_with_invalid_color_per_vertex()[source]
Test from_raw with invalid color_per_vertex.
-
test_from_raw_with_invalid_uvs_length()[source]
Test from_raw with invalid UVs length.
-
test_bind_with_all_buffers()[source]
Test bind method with all buffers present.
-
test_bind_with_minimal_buffers()[source]
Test bind method with only vertices.
-
test_bind_with_none_buffers()[source]
Test bind method with None buffers.
-
test_unbind_with_all_buffers()[source]
Test unbind method with all buffers present.
-
test_unbind_with_none_buffers()[source]
Test unbind method with None buffers.
-
test_context_manager()[source]
Test that MeshData can be used as a context manager.
-
test_draw_with_vertex_colors()[source]
Test draw method with vertex colors.
-
test_draw_with_override_color()[source]
Test draw method with override colour.
-
test_draw_with_fill_mode()[source]
Test draw method with fill mode.
-
test_draw_with_alpha_blending()[source]
Test draw method with alpha blending.
-
test_draw_with_line_width()[source]
Test draw method with custom line width.
-
test_draw_with_custom_mode()[source]
Test draw method with custom drawing mode.
-
test_draw_without_ebo()[source]
Test draw method without EBO.
-
test_vertex_count_calculation()[source]
Test vertex count calculation.
-
test_data_type_conversion()[source]
Test that data is properly converted to correct types.
-
test_array_flattening()[source]
Test that multi-dimensional arrays are properly flattened.
-
test_error_handling_in_from_raw()[source]
Test error handling in from_raw method.
-
test_color_generation_edge_cases()[source]
Test colour generation with edge cases.
-
test_normal_generation()[source]
Test normal generation when not provided.
-
test_repr_string()[source]
Test string representation of MeshData.