Skip to content

Commit bf842fb

Browse files
committed
adding more test coverage and excluding some pass statments
1 parent 080de31 commit bf842fb

File tree

7 files changed

+62
-19
lines changed

7 files changed

+62
-19
lines changed

run_coverage_nogpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def main():
6767
"tests/test_base_mesh.py",
6868
"tests/test_primitives.py",
6969
"tests/test_obj.py",
70-
"tests/test_webgpu_widget.py",
7170
]
7271

7372
# Qt widget tests (require pytest-qt)
@@ -79,6 +78,7 @@ def main():
7978
"tests/test_rgba_colour_widget.py",
8079
"tests/test_lookat_widget.py",
8180
"tests/test_transform_widget.py",
81+
"tests/test_webgpu_widget.py",
8282
]
8383

8484
print("PyNGL Coverage without GPU")

src/ncca/ngl/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
from importlib.metadata import PackageNotFoundError, version
33

44
try:
5-
__version__ = version("ncca-ngl")
6-
except PackageNotFoundError:
5+
__version__ = version("ncca-ngl") # pragma: no cover
6+
except PackageNotFoundError: # pragma: no cover
77
__version__ = "0.0.0"
8-
98
__author__ = "Jon Macey jmacey@bournemouth.ac.uk"
109
__license__ = "MIT"
1110

src/ncca/ngl/vector_base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def cross(self, rhs: Self) -> Self | float:
421421
Returns:
422422
Union[VectorBase, float]: The cross product (scalar for 2D, vector for 3D/4D).
423423
"""
424-
pass
424+
pass # pragma: no cover
425425

426426
@abstractmethod
427427
def reflect(self, n: Self) -> Self:
@@ -434,7 +434,7 @@ def reflect(self, n: Self) -> Self:
434434
Returns:
435435
VectorBase: A new vector that is the result of reflecting this vector about the normal.
436436
"""
437-
pass
437+
pass # pragma: no cover
438438

439439
@abstractmethod
440440
def outer(self, rhs: Self) -> Any:
@@ -447,7 +447,7 @@ def outer(self, rhs: Self) -> Any:
447447
Returns:
448448
Any: A matrix that is the result of the outer product.
449449
"""
450-
pass
450+
pass # pragma: no cover
451451

452452
@abstractmethod
453453
def __matmul__(self, rhs: Any) -> Self:
@@ -460,7 +460,7 @@ def __matmul__(self, rhs: Any) -> Self:
460460
Returns:
461461
VectorBase: A new vector that is the result of multiplying this vector by the matrix.
462462
"""
463-
pass
463+
pass # pragma: no cover
464464

465465
@abstractmethod
466466
def set(self, *args: float) -> None:
@@ -473,17 +473,17 @@ def set(self, *args: float) -> None:
473473
Raises:
474474
ValueError: If wrong number of arguments is provided or they are not floats.
475475
"""
476-
pass
476+
pass # pragma: no cover
477477

478478
@abstractmethod
479479
def __repr__(self) -> str:
480480
"""Object representation for debugging."""
481-
pass
481+
pass # pragma: no cover
482482

483483
@abstractmethod
484484
def __str__(self) -> str:
485485
"""String representation of the vector."""
486-
pass
486+
pass # pragma: no cover
487487

488488
def __getattr__(self, name: str):
489489
"""

src/ncca/ngl/webgpu/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from importlib.metadata import PackageNotFoundError, version
22

33
try:
4-
__version__ = version("ncca-ngl")
4+
__version__ = version("ncca-ngl") # pragma: no cover
55
except PackageNotFoundError:
6-
__version__ = "0.0.0"
6+
__version__ = "0.0.0" # pragma: no cover
77

88
__author__ = "Jon Macey jmacey@bournemouth.ac.uk"
99
__license__ = "MIT"

src/ncca/ngl/widgets/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from importlib.metadata import PackageNotFoundError, version
22

33
try:
4-
__version__ = version("ncca-ngl")
5-
except PackageNotFoundError:
4+
__version__ = version("ncca-ngl") # pragma: no cover
5+
except PackageNotFoundError: # pragma: no cover
66
__version__ = "0.0.0"
77

88
__author__ = "Jon Macey jmacey@bournemouth.ac.uk"

tests/test_rgba_colour_widget.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ def test_rgb_widget_initial_value(qtbot):
2121

2222
def test_rgba_widget_constructor_initial_value_and_name(qtbot):
2323
start_val = Vec4(0.5, 0.6, 0.7, 1.0)
24-
w = RGBAColourWidget(
25-
name="InitName", r=start_val.x, g=start_val.y, b=start_val.z, a=start_val.w
26-
)
24+
w = RGBAColourWidget(name="InitName", r=start_val.x, g=start_val.y, b=start_val.z, a=start_val.w)
2725
qtbot.addWidget(w)
2826

2927
assert w.colour() == start_val
@@ -66,6 +64,10 @@ def test_value_signals_for_each_component(qtbot):
6664
w.b_spinbox.setValue(0.75)
6765
assert sig_b.args == [pytest.approx(0.75)]
6866

67+
with qtbot.waitSignal(w.aValueChanged, timeout=1000) as sig_a:
68+
w.a_spinbox.setValue(0.75)
69+
assert sig_a.args == [pytest.approx(0.75)]
70+
6971

7072
def test_set_colour_blocks_channel_signals_but_emits_colour_changed(qtbot):
7173
w = RGBAColourWidget()

tests/test_vec3.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import copy
22
import ctypes
3+
from typing import cast
34

45
import numpy as np
56
import pytest
67

7-
from ncca.ngl import Mat3, Vec3
8+
from ncca.ngl import Mat3, Vec3, Vec2, Vec4
89

910

1011
def test_properties():
@@ -345,3 +346,44 @@ def test_to_metods():
345346
a = Vec3(1, 2, 3)
346347
assert a.to_list() == [1, 2, 3]
347348
assert np.array_equal(a.to_numpy(), np.array([1, 2, 3]))
349+
assert a.to_tuple() == (1, 2, 3)
350+
351+
352+
def test_unknown_component_kwarg():
353+
with pytest.raises(ValueError, match="Unknown component name"):
354+
Vec3(invalid_component=1.0)
355+
356+
357+
def test_add_incompatible_type():
358+
a = Vec3(1, 2, 3)
359+
b = cast(Vec3, Vec2(1, 2))
360+
with pytest.raises(ValueError, match="Can only add Vec3 to Vec3"):
361+
_ = a + b
362+
363+
364+
def test_iadd_incompatible_type():
365+
a = Vec3(1, 2, 3)
366+
b = cast(Vec3, Vec2(1, 2))
367+
with pytest.raises(ValueError, match="Can only add Vec3 to Vec3"):
368+
a += b
369+
370+
371+
def test_sub_incompatible_type():
372+
a = Vec3(1, 2, 3)
373+
b = cast(Vec3, Vec2(1, 2))
374+
with pytest.raises(ValueError, match="Can only subtract Vec3 from Vec3"):
375+
_ = a - b
376+
377+
378+
def test_isub_incompatible_type():
379+
a = Vec3(1, 2, 3)
380+
b = cast(Vec3, Vec2(1, 2))
381+
with pytest.raises(ValueError, match="Can only subtract Vec3 from Vec3"):
382+
a -= b
383+
384+
385+
def test_dot_incompatible_type():
386+
a = Vec3(1, 2, 3)
387+
b = cast(Vec3, Vec2(1, 2))
388+
with pytest.raises(ValueError, match="Can only compute dot product with Vec3"):
389+
_ = a.dot(b)

0 commit comments

Comments
 (0)