Skip to content

Commit

Permalink
chore: Add new flag for gtfs_kit tests -> sanitycheck
Browse files Browse the repository at this point in the history
  • Loading branch information
r-leyshon committed Sep 20, 2023
1 parent c4fad11 commit c97b2d4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
20 changes: 20 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ def pytest_addoption(parser):
default=False,
help="run expensive tests",
)
parser.addoption(
"--sanitycheck",
action="store_true",
default=False,
help="run sanity checks",
)


def pytest_configure(config):
Expand All @@ -39,6 +45,10 @@ def pytest_configure(config):
config.addinivalue_line(
"markers", "runexpensive: mark test to run expensive tests"
)
config.addinivalue_line(
"markers",
"sanitycheck: mark test to run checks in dependencies' code.",
)


def pytest_collection_modifyitems(config, items): # noqa:C901
Expand All @@ -47,6 +57,7 @@ def pytest_collection_modifyitems(config, items): # noqa:C901
config.getoption("--runsetup")
& config.getoption("--runinteg")
& config.getoption("--runexpensive")
& config.getoption("--sanitycheck")
):
# do full test suite when all flags are given
return
Expand Down Expand Up @@ -75,3 +86,12 @@ def pytest_collection_modifyitems(config, items): # noqa:C901
for item in items:
if "runexpensive" in item.keywords:
item.add_marker(skip_runexpensive)

# do not add sanitycheck marks when the sanitycheck flag is given
if not config.getoption("--sanitycheck"):
skip_sanitycheck = pytest.mark.skip(
reason="need --sanitycheck option to run"
)
for item in items:
if "sanitycheck" in item.keywords:
item.add_marker(skip_sanitycheck)
6 changes: 3 additions & 3 deletions tests/gtfs/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_is_valid(self, gtfs_fixture):
found_cols == exp_cols
).all(), f"Expected columns {exp_cols}. Found: {found_cols}"

@pytest.mark.runinteg
@pytest.mark.sanitycheck
def test_trips_unmatched_ids(self, gtfs_fixture):
"""Tests to evaluate gtfs-klt's reaction to invalid IDs in trips.
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_trips_unmatched_ids(self, gtfs_fixture):
), "gtfs-kit failed to recognise invalid service_id"
assert len(new_valid) == 10, "Validation table not expected size"

@pytest.mark.runinteg
@pytest.mark.sanitycheck
def test_routes_unmatched_ids(self, gtfs_fixture):
"""Tests to evaluate gtfs-klt's reaction to invalid IDs in routes.
Expand Down Expand Up @@ -206,7 +206,7 @@ def test_routes_unmatched_ids(self, gtfs_fixture):
), "gtfs-kit failed to recognise that there are routes with no trips"
assert len(new_valid) == 9, "Validation table not expected size"

@pytest.mark.runinteg
@pytest.mark.sanitycheck
def test_unmatched_service_id_behaviour(self, gtfs_fixture):
"""Tests to evaluate gtfs-klt's reaction to invalid IDs in calendar.
Expand Down

0 comments on commit c97b2d4

Please sign in to comment.