diff --git a/pytest_ruff/_pytest_compat.py b/pytest_ruff/_pytest_compat.py index 2d2db7d..ab9f839 100644 --- a/pytest_ruff/_pytest_compat.py +++ b/pytest_ruff/_pytest_compat.py @@ -6,7 +6,7 @@ import pytest try: - from pytest import Stash, StashKey + from pytest import Stash as Stash, StashKey except ImportError: import _pytest.store @@ -36,10 +36,7 @@ def get_stash_object(config): def get_stash(config): - missing = object() - stash = get_stash_object(config).get(_MTIMES_STASH_KEY, default=missing) - assert stash is not missing - return stash + return get_stash_object(config).get(_MTIMES_STASH_KEY, default=None) def set_stash(config, value): diff --git a/tests/assets/broken_config/empty.py b/tests/assets/config_broken/empty.py similarity index 100% rename from tests/assets/broken_config/empty.py rename to tests/assets/config_broken/empty.py diff --git a/tests/assets/broken_config/ruff.toml b/tests/assets/config_broken/ruff.toml similarity index 100% rename from tests/assets/broken_config/ruff.toml rename to tests/assets/config_broken/ruff.toml diff --git a/tests/assets/ok.py b/tests/assets/ok.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_plugin.py b/tests/test_plugin.py index fd1c8c2..a3facd8 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -88,7 +88,7 @@ def test_broken_ruff_config(): "-m", "pytest", "--ruff", - "tests/assets/broken_config/empty.py", + "tests/assets/config_broken/empty.py", ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -96,3 +96,21 @@ def test_broken_ruff_config(): out, err = process.communicate() assert err.decode() == "" assert "unknown field `broken`" in out.decode() + + +def test_without_pytest_cache(): + process = subprocess.Popen( + [ + sys.executable, + "-m", + "pytest", + "--ruff", + "-pno:cacheprovider", + "tests/assets/ok.py", + ], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + out, err = process.communicate() + assert err.decode() == "" + assert "tests/assets/ok.py ." in out.decode() diff --git a/tox.ini b/tox.ini index 6c5de3c..1428482 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] isolated_build = true -envlist = py{38,39,310,311,312}-pytest{5,6,7,8,810,81},lint +envlist = py{38,39,310,311,312}-pytest{5,6,7,8,810,latest},lint [testenv] allowlist_externals = poetry @@ -9,10 +9,10 @@ commands = pytest5: pip install "pytest<6" pytest6: pip install "pytest>=6,<7" pytest7: pip install "pytest>=7,<8" - pytest8: pip install "pytest>=8,<8.1" + pytest8: pip install "pytest>=8,<9" # pytest 8.1.0 was yanked, but their "broken behaviour" will comeback soon pytest810: pip install "pytest==8.1.0" - pytest81: pip install "pytest>=8.1,<9" + pytestlatest: pip install pytest # Disable ruff plugin to generate better coverage results poetry run pytest -p no:ruff -vvv --cov --cov-append --cov-report term --cov-report xml {posargs}