From c4e5f9d8a29a2b54a59b8bcfb9d4baff7b72666f Mon Sep 17 00:00:00 2001 From: ikappaki Date: Wed, 30 Apr 2025 06:57:15 +0100 Subject: [PATCH 1/5] suppress pytest rewrite assertion warning --- CHANGELOG.md | 2 ++ src/basilisp/cli.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94efd8db..ddb4b879 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed * Removed support for Python 3.9 (#1283) + * Suppress pytest assertion rewrite warning for basilisp when running `basilisp test` (#1252) + ## [v0.4.0] ### Added * Added support for referring imported Python names as by `from ... import ...` (#1154) diff --git a/src/basilisp/cli.py b/src/basilisp/cli.py index d761d6ed..b609db98 100644 --- a/src/basilisp/cli.py +++ b/src/basilisp/cli.py @@ -745,6 +745,15 @@ def test( "Cannot run tests without dependency PyTest. Please install PyTest and try again.", ) else: + # `basilisp` declares the testrunner as a pytest plugin, so + # pytest tries to import it for assertion rewriting. Since + # it's already imported, pytest emits a warning. As rewriting + # isn't needed, we ignore it. + extra = [ + "-W", + "ignore:Module already imported so cannot be rewritten:pytest.PytestAssertRewriteWarning", + ] + extra + sys.exit(pytest.main(args=list(extra))) From dd688a63d9c79811e167f1df436866c0b7d49b50 Mon Sep 17 00:00:00 2001 From: ikappaki Date: Sun, 12 Oct 2025 09:47:26 +0100 Subject: [PATCH 2/5] Use the new `;` format in the message to specify basilisp in warning --- src/basilisp/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basilisp/cli.py b/src/basilisp/cli.py index b609db98..8f91156e 100644 --- a/src/basilisp/cli.py +++ b/src/basilisp/cli.py @@ -751,7 +751,7 @@ def test( # isn't needed, we ignore it. extra = [ "-W", - "ignore:Module already imported so cannot be rewritten:pytest.PytestAssertRewriteWarning", + "ignore:Module already imported so cannot be rewritten; basilisp:pytest.PytestAssertRewriteWarning", ] + extra sys.exit(pytest.main(args=list(extra))) From ce4d6c83ce836d02653eb662a2003542d251fb0a Mon Sep 17 00:00:00 2001 From: ikappaki Date: Sun, 12 Oct 2025 09:56:13 +0100 Subject: [PATCH 3/5] Upgrade Pytest version to min 8.4.0 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 38b5f691..dadb3d95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ prompt-toolkit = ">=3.0.0,<4.0.0" pyrsistent = ">=0.18.0,<1.0.0" typing-extensions = ">=4.7.0,<5.0.0" -pytest = { version = ">=7.0.0,<9.0.0", optional = true } +pytest = { version = ">=8.4.0,<9.0.0", optional = true } pygments = { version = ">=2.9.0,<3.0.0", optional = true } [tool.poetry.group.dev.dependencies] @@ -45,7 +45,7 @@ black = ">=24.0.0" docutils = "*" isort = "*" pygments = "*" -pytest = ">=7.0.0,<9.0.0" +pytest = ">=8.4.0,<9.0.0" pytest-pycharm = "*" # Ensure the Sphinx version remains synchronized with docs/requirements.txt # to maintain consistent output during both development and publishing on From 78926592858c932b3c7055bd062bb9c9c15148e4 Mon Sep 17 00:00:00 2001 From: ikappaki Date: Wed, 29 Oct 2025 07:31:50 +0000 Subject: [PATCH 4/5] realign changelog entry [skip ci] --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddb4b879..aa3a569d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,12 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed * Fix a bug where `import` refers would incorrectly be applied to all import modules in the same form (#1274) + * Suppress pytest assertion rewrite warning for basilisp when running `basilisp test` (#1252) ### Removed * Removed support for Python 3.9 (#1283) - * Suppress pytest assertion rewrite warning for basilisp when running `basilisp test` (#1252) - ## [v0.4.0] ### Added * Added support for referring imported Python names as by `from ... import ...` (#1154) From eae96dd0095d54c61a073dd0d1adec6838e41f65 Mon Sep 17 00:00:00 2001 From: ikappaki Date: Wed, 29 Oct 2025 20:34:28 +0000 Subject: [PATCH 5/5] Restore the original pytest version range --- pyproject.toml | 4 ++-- src/basilisp/cli.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dadb3d95..38b5f691 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ prompt-toolkit = ">=3.0.0,<4.0.0" pyrsistent = ">=0.18.0,<1.0.0" typing-extensions = ">=4.7.0,<5.0.0" -pytest = { version = ">=8.4.0,<9.0.0", optional = true } +pytest = { version = ">=7.0.0,<9.0.0", optional = true } pygments = { version = ">=2.9.0,<3.0.0", optional = true } [tool.poetry.group.dev.dependencies] @@ -45,7 +45,7 @@ black = ">=24.0.0" docutils = "*" isort = "*" pygments = "*" -pytest = ">=8.4.0,<9.0.0" +pytest = ">=7.0.0,<9.0.0" pytest-pycharm = "*" # Ensure the Sphinx version remains synchronized with docs/requirements.txt # to maintain consistent output during both development and publishing on diff --git a/src/basilisp/cli.py b/src/basilisp/cli.py index 8f91156e..833f0b90 100644 --- a/src/basilisp/cli.py +++ b/src/basilisp/cli.py @@ -748,7 +748,8 @@ def test( # `basilisp` declares the testrunner as a pytest plugin, so # pytest tries to import it for assertion rewriting. Since # it's already imported, pytest emits a warning. As rewriting - # isn't needed, we ignore it. + # isn't needed, we ignore it. (Requires pytest >=8.4.0 to take + # effect) extra = [ "-W", "ignore:Module already imported so cannot be rewritten; basilisp:pytest.PytestAssertRewriteWarning",