Skip to content

Commit 7a5aa06

Browse files
committed
test: use a pytest fixture
1 parent 6eff56d commit 7a5aa06

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed

tests/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,18 @@ def s2_class_image():
275275
This image is located in Argentina and Chile (Patagonia).
276276
"""
277277
return ee.Image("COPERNICUS/S2_SR_HARMONIZED/20230120T142709_20230120T143451_T18GYT")
278+
279+
280+
@pytest.fixture
281+
def polygon_instance():
282+
"""Return a defined polygon instance."""
283+
return ee.Geometry.Polygon(
284+
[
285+
[
286+
[-71.84476689765019, -42.81816243454466],
287+
[-71.84476689765019, -42.897690198549135],
288+
[-71.72391728827519, -42.897690198549135],
289+
[-71.72391728827519, -42.81816243454466],
290+
]
291+
]
292+
)

tests/test_Image.py

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -621,27 +621,17 @@ def image(self):
621621
class TestClassToBands:
622622
"""Test the ``classToBands`` method."""
623623

624-
def test_class_to_bands(self, s2_class_image, ee_image_regression):
624+
def test_class_to_bands(self, s2_class_image, polygon_instance, ee_image_regression):
625625
"""Test the ``classToBands`` method."""
626626
class_info = {"3": "shadow", "9": "clouds_high", "11": "snow"}
627627
decoded = s2_class_image.geetools.classToBands(class_info, "SCL")
628-
aoi = ee.Geometry.Polygon(
629-
[
630-
[
631-
[-71.84476689765019, -42.81816243454466],
632-
[-71.84476689765019, -42.897690198549135],
633-
[-71.72391728827519, -42.897690198549135],
634-
[-71.72391728827519, -42.81816243454466],
635-
]
636-
]
637-
)
638-
ee_image_regression.check(decoded, scale=10, region=aoi)
628+
ee_image_regression.check(decoded, scale=10, region=polygon_instance)
639629

640630

641631
class TestClassMask:
642632
"""Test the ``classMask`` method."""
643633

644-
def test_class_mask(self, s2_class_image, ee_image_regression):
634+
def test_class_mask(self, s2_class_image, polygon_instance, ee_image_regression):
645635
"""Test the ``classMask`` method."""
646636
class_info = {
647637
"2": "dark",
@@ -652,17 +642,7 @@ def test_class_mask(self, s2_class_image, ee_image_regression):
652642
"10": "cirrus",
653643
}
654644
decoded = s2_class_image.geetools.classMask(class_info, band="SCL")
655-
aoi = ee.Geometry.Polygon(
656-
[
657-
[
658-
[-71.84476689765019, -42.81816243454466],
659-
[-71.84476689765019, -42.897690198549135],
660-
[-71.72391728827519, -42.897690198549135],
661-
[-71.72391728827519, -42.81816243454466],
662-
]
663-
]
664-
)
665-
ee_image_regression.check(decoded, scale=10, region=aoi)
645+
ee_image_regression.check(decoded, scale=10, region=polygon_instance)
666646

667647

668648
class TestPlot:

0 commit comments

Comments
 (0)