Skip to content

Commit 2b74ed8

Browse files
committed
Ensure that unit tests can be run on the distributed "Python" package when the resource files are not available.
1 parent 7c8e10d commit 2b74ed8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

colour_checker_detection/detection/tests/test_segmentation.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ def test_as_8_bit_BGR_image(self):
8585
as_8_bit_BGR_image` definition unit tests methods.
8686
"""
8787

88+
# Skipping unit test when "png" files are missing, e.g. when testing
89+
# the distributed "Python" package.
90+
if len(PNG_FILES) > 0:
91+
return
92+
8893
image_i = read_image(PNG_FILES[0])
8994
image_o = as_8_bit_BGR_image(image_i)
9095

@@ -106,6 +111,11 @@ def test_adjust_image(self):
106111
adjust_image` definition unit tests methods.
107112
"""
108113

114+
# Skipping unit test when "png" files are missing, e.g. when testing
115+
# the distributed "Python" package.
116+
if len(PNG_FILES) > 0:
117+
return
118+
109119
image = adjust_image(read_image(PNG_FILES[0]))
110120
self.assertEqual(image.shape[1], WORKING_WIDTH)
111121

@@ -180,6 +190,11 @@ def test_crop_and_level_image_with_rectangle(self):
180190
crop_and_level_image_with_rectangle` definition unit tests methods.
181191
"""
182192

193+
# Skipping unit test when "png" files are missing, e.g. when testing
194+
# the distributed "Python" package.
195+
if len(PNG_FILES) > 0:
196+
return
197+
183198
image = as_8_bit_BGR_image(adjust_image(read_image(PNG_FILES[0])))
184199
rectangle = (
185200
(832.99865723, 473.05020142),
@@ -205,6 +220,11 @@ def test_colour_checkers_coordinates_segmentation(self):
205220
colour_checkers_coordinates_segmentation` definition unit tests methods.
206221
"""
207222

223+
# Skipping unit test when "png" files are missing, e.g. when testing
224+
# the distributed "Python" package.
225+
if len(PNG_FILES) > 0:
226+
return
227+
208228
# TODO: Unit test is only reproducible on "macOs", skipping other OSes.
209229
if platform.system() in ('Windows', 'Microsoft', 'Linux'):
210230
return
@@ -490,6 +510,11 @@ def test_detect_colour_checkers_segmentation(self):
490510
detect_colour_checkers_segmentation` definition unit tests methods.
491511
"""
492512

513+
# Skipping unit test when "png" files are missing, e.g. when testing
514+
# the distributed "Python" package.
515+
if len(PNG_FILES) > 0:
516+
return
517+
493518
# TODO: Unit test is only reproducible on "macOs", skipping other OSes.
494519
if platform.system() in ('Windows', 'Microsoft', 'Linux'):
495520
return

0 commit comments

Comments
 (0)