Skip to content

Commit

Permalink
Merge pull request #496 from l0b0/make-tests-runnable-from-anywhere
Browse files Browse the repository at this point in the history
tests: Make tests runnable from anywhere
  • Loading branch information
Jon Duckworth authored Jun 29, 2021
2 parents 86f12b6 + a7c0e43 commit 802e931
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ def test_collections_cache_correctly(self) -> None:

def test_reading_iterating_and_writing_works_as_expected(self) -> None:
"""Test case to cover issue #88"""
stac_uri = "tests/data-files/catalogs/test-case-6/catalog.json"
stac_uri = TestCases.get_path("data-files/catalogs/test-case-6/catalog.json")
cat = Catalog.from_file(stac_uri)

# Iterate over the items. This was causing failure in
Expand Down
8 changes: 7 additions & 1 deletion tests/test_item_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import json
from pystac.item_collection import ItemCollection
import unittest
from os.path import relpath

import pystac

from tests.utils import TestCases
Expand Down Expand Up @@ -101,7 +103,11 @@ def test_raise_error_for_invalid_object(self) -> None:

def test_from_relative_path(self) -> None:
_ = pystac.ItemCollection.from_file(
"./tests/data-files/item-collection/sample-item-collection.json"
relpath(
TestCases.get_path(
"data-files/item-collection/sample-item-collection.json"
)
)
)

def test_from_list_of_dicts(self) -> None:
Expand Down
5 changes: 4 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pystac import utils

from pystac.utils import make_relative_href, make_absolute_href, is_absolute_href
from tests.utils import TestCases


class UtilsTest(unittest.TestCase):
Expand Down Expand Up @@ -273,7 +274,9 @@ def test_datetime_to_str(self) -> None:

def test_geojson_bbox(self) -> None:
# Use sample Geojson from https://en.wikipedia.org/wiki/GeoJSON
with open("tests/data-files/geojson/sample.geojson") as sample_geojson:
with open(
TestCases.get_path("data-files/geojson/sample.geojson")
) as sample_geojson:
all_features = json.load(sample_geojson)
geom_dicts = [f["geometry"] for f in all_features["features"]]
for geom in geom_dicts:
Expand Down

0 comments on commit 802e931

Please sign in to comment.