Skip to content

Commit 9f25a68

Browse files
committed
Add tests for from_raw_data near/far validation
* Turn camera_class into a fixture * Add simple inline test for from_raw_data's near/far validation
1 parent b857fe3 commit 9f25a68

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

tests/unit/camera/test_camera2d.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class Camera2DSub2(Camera2DSub1):
1818
ALL_CAMERA2D_TYPES = [Camera2D] + CAMERA2D_SUBS
1919

2020

21+
@pytest.fixture(params=ALL_CAMERA2D_TYPES)
22+
def camera_class(request):
23+
return request.param
24+
25+
2126
AT_LEAST_ONE_EQUAL_VIEWPORT_DIMENSION = [
2227
(-100., -100., -1., 1.),
2328
(100., 100., -1., 1.),
@@ -30,8 +35,7 @@ class Camera2DSub2(Camera2DSub1):
3035

3136

3237
@pytest.mark.parametrize("bad_projection", AT_LEAST_ONE_EQUAL_VIEWPORT_DIMENSION)
33-
@pytest.mark.parametrize("camera_class", ALL_CAMERA2D_TYPES)
34-
def test_camera2d_from_raw_data_bound_validation(
38+
def test_camera2d_from_raw_data_projection_xy_pairs_equal_raises_zeroprojectiondimension(
3539
window: Window,
3640
bad_projection: Tuple[float, float, float, float], # Clarify type for PyCharm
3741
camera_class
@@ -40,6 +44,20 @@ def test_camera2d_from_raw_data_bound_validation(
4044
camera_class.from_raw_data(projection=bad_projection)
4145

4246

47+
48+
def test_camera2d_from_raw_data_equal_near_far_raises_zeroprojectiondimension(
49+
window: Window, camera_class
50+
):
51+
with pytest.raises(ZeroProjectionDimension):
52+
camera_class.from_raw_data(near=-100, far=-100)
53+
54+
with pytest.raises(ZeroProjectionDimension):
55+
camera_class.from_raw_data(near=0, far=0)
56+
57+
with pytest.raises(ZeroProjectionDimension):
58+
camera_class.from_raw_data(near=100, far=100)
59+
60+
4361
@pytest.mark.parametrize("camera_class", CAMERA2D_SUBS)
4462
def test_camera2d_from_raw_data_inheritance_safety(
4563
window: Window,

0 commit comments

Comments
 (0)