Skip to content

Commit 3d5ce98

Browse files
committed
use pytest
1 parent 55d49ce commit 3d5ce98

File tree

6 files changed

+24
-11
lines changed

6 files changed

+24
-11
lines changed

.github/workflows/ci.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,14 @@ jobs:
4242
with:
4343
python-version: ${{ matrix.python-version }}
4444

45-
- name: Install tox
46-
run: pip install tox
45+
- name : Install dependencies
46+
run: |
47+
python -m pip install --upgrade pip
48+
python -I -m pip install setuptools>=40.8.0 wheel pytest
49+
python -m pip freeze --all
50+
python -m pip install -r requirements.txt
51+
python -m pip freeze --all
4752
4853
- name: Run tests
49-
run: tox -e py${{ matrix.python-version }}
54+
run: |
55+
python -m pytest -v

pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
testpaths = pytissueoptics
3+
python_files = test*.py

pytissueoptics/rayscattering/opencl/config/CLConfig.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ def save(self):
212212
def _devices(self) -> List[cl.Device]:
213213
devices = []
214214
for platform in cl.get_platforms():
215-
devices += platform.get_devices()
215+
try:
216+
devices += platform.get_devices()
217+
except Exception as e:
218+
warnings.warn(f"Error getting devices from platform {platform.name}: {e}")
219+
continue
216220
return devices
217221

218222
@property

pytissueoptics/scene/tests/intersection/testBoundingBoxIntersect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pytissueoptics.scene.intersection.bboxIntersect import BoxIntersectStrategy, GemsBoxIntersect, ZacharBoxIntersect
66

77

8-
class TestAnyBoxIntersect:
8+
class BaseTestAnyBoxIntersect:
99
@property
1010
def intersectStrategy(self) -> BoxIntersectStrategy:
1111
raise NotImplementedError
@@ -83,7 +83,7 @@ def testGivenRayLengthLongerThanBoxIntersection_shouldReturnIntersection(self):
8383
self.assertEqual(0.0, intersection.z)
8484

8585

86-
class TestGemsBoxIntersect(TestAnyBoxIntersect, unittest.TestCase):
86+
class TestGemsBoxIntersect(BaseTestAnyBoxIntersect, unittest.TestCase):
8787
def testGivenLineIntersectingRayAndBox_shouldReturnClosestIntersectionPoint(self):
8888
box = BoundingBox([1, 2], [1, 2], [-1, 0])
8989
rayOrigin = Vector(-1, -1, 0)
@@ -103,7 +103,7 @@ def intersectStrategy(self) -> BoxIntersectStrategy:
103103
return GemsBoxIntersect()
104104

105105

106-
class TestZacharBoxIntersect(TestAnyBoxIntersect, unittest.TestCase):
106+
class TestZacharBoxIntersect(BaseTestAnyBoxIntersect, unittest.TestCase):
107107
def testGivenLineIntersectingRayAndBox_shouldReturnNone(self):
108108
box = BoundingBox([0, 1], [0, 1], [-1, 0])
109109
rayOrigin = Vector(-1, -1, 0)

pytissueoptics/scene/tests/intersection/testIntersectionFinder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
)
1414

1515

16-
class TestAnyIntersectionFinder:
16+
class BaseTestAnyIntersectionFinder:
1717
def getIntersectionFinder(self, solids) -> IntersectionFinder:
1818
raise NotImplementedError
1919

@@ -227,13 +227,13 @@ def assertVectorEqual(self, expected, actual):
227227
self.assertEqual(expected.z, actual.z)
228228

229229

230-
class TestSimpleIntersectionFinder(TestAnyIntersectionFinder, unittest.TestCase):
230+
class TestSimpleIntersectionFinder(BaseTestAnyIntersectionFinder, unittest.TestCase):
231231
def getIntersectionFinder(self, solids) -> IntersectionFinder:
232232
scene = Scene(solids)
233233
return SimpleIntersectionFinder(scene)
234234

235235

236-
class TestFastIntersectionFinder(TestAnyIntersectionFinder, unittest.TestCase):
236+
class TestFastIntersectionFinder(BaseTestAnyIntersectionFinder, unittest.TestCase):
237237
def getIntersectionFinder(self, solids) -> IntersectionFinder:
238238
scene = Scene(solids)
239239
return FastIntersectionFinder(scene)

pytissueoptics/scene/tests/intersection/testPolygonIntersect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pytissueoptics.scene.intersection.mollerTrumboreIntersect import MollerTrumboreIntersect
66

77

8-
class TestAnyPolygonIntersect(unittest.TestCase):
8+
class BaseTestAnyPolygonIntersect(unittest.TestCase):
99
vertices = [Vertex(0, 0, 0), Vertex(1, 0, 0), Vertex(1, 1, 0), Vertex(0, 1, 0)]
1010
triangle = Triangle(vertices[0], vertices[1], vertices[3])
1111
quad = Quad(vertices[0], vertices[1], vertices[2], vertices[3])

0 commit comments

Comments
 (0)