diff --git a/conftest.py b/conftest.py index 6f644831..191d886e 100644 --- a/conftest.py +++ b/conftest.py @@ -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): @@ -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 @@ -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 @@ -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) diff --git a/tests/gtfs/test_validation.py b/tests/gtfs/test_validation.py index 038d988f..54dff447 100644 --- a/tests/gtfs/test_validation.py +++ b/tests/gtfs/test_validation.py @@ -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. @@ -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. @@ -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.