Skip to content

tests: Make tests runnable from anywhere #496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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