From 4c4668cbc11fc3cb8631c0207fcb8a419ee3c6a1 Mon Sep 17 00:00:00 2001 From: ikappaki Date: Wed, 30 Apr 2025 06:57:15 +0100 Subject: [PATCH 1/3] 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 092d9c10..50875d91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] + * 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 d7bfe23c0b3418e3aa4917caf8ab5fa2bf7e703f Mon Sep 17 00:00:00 2001 From: ikappaki Date: Sun, 12 Oct 2025 09:47:26 +0100 Subject: [PATCH 2/3] 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 c5cae99532ef618563d34019045e93bba6303733 Mon Sep 17 00:00:00 2001 From: ikappaki Date: Sun, 12 Oct 2025 09:56:13 +0100 Subject: [PATCH 3/3] 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 983e902b..ab4791bd 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