From 0d312d3bdf0f8af384f397346e2ca60b2d0c4c16 Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Fri, 19 Dec 2025 10:14:54 +1300 Subject: [PATCH 1/3] Use more robust path handling in `test_syntax_error_includes_module` to avoid flakiness when running via VS Code GUI --- tests/functional/test_error_handling.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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: From 89e10392417cafbf9f1a4e0d8d46bb6e5d40bb19 Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Fri, 19 Dec 2025 10:47:12 +1300 Subject: [PATCH 2/3] Use context manager for settings in `configure_unit_tests` fixture --- tests/unit/conftest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 From 94e442118169dd83ea6693ea0410cf9e7be6a97c Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Sat, 20 Dec 2025 09:41:32 +1300 Subject: [PATCH 3/3] Add `match` arg in `pytest.warns` for `DeprecationWarning` of `NamespacePackageEncountered` --- tests/unit/test_exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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