diff --git a/tests/functional/test_error_handling.py b/tests/functional/test_error_handling.py index e79914ba..ab8f873b 100644 --- a/tests/functional/test_error_handling.py +++ b/tests/functional/test_error_handling.py @@ -1,4 +1,4 @@ -import os +from pathlib import Path import pytest # type: ignore @@ -6,9 +6,10 @@ def test_syntax_error_includes_module(): - dirname = os.path.dirname(__file__) - filename = os.path.abspath( - os.path.join(dirname, "..", "assets", "syntaxerrorpackage", "foo", "one.py") + filename = str( + ( + Path(__file__).parent.parent / "assets" / "syntaxerrorpackage" / "foo" / "one.py" + ).resolve() ) with pytest.raises(exceptions.SourceSyntaxError) as excinfo: diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 4c1dc52e..d00899fd 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -1,14 +1,15 @@ import pytest # type: ignore -from grimp.application.config import settings from grimp.application.graph import ImportGraph from grimp.adaptors.modulefinder import ModuleFinder +from tests.config import override_settings @pytest.fixture(scope="module", autouse=True) def configure_unit_tests(): - settings.configure( + with override_settings( IMPORT_GRAPH_CLASS=ImportGraph, MODULE_FINDER=ModuleFinder(), FILE_SYSTEM=None, - ) + ): + yield diff --git a/tests/unit/test_exceptions.py b/tests/unit/test_exceptions.py index 4a2c7186..2ffd8fa5 100644 --- a/tests/unit/test_exceptions.py +++ b/tests/unit/test_exceptions.py @@ -60,5 +60,5 @@ def test_different_texts_are_not_equal(self): class TestNamespacePackageEncountered: def test_deprecated_access(self): - with pytest.warns(DeprecationWarning): + with pytest.warns(DeprecationWarning, match="NamespacePackageEncountered is deprecated"): exceptions.NamespacePackageEncountered