From 237f92f42df9d3df8934ffb8773eb9b188e5f769 Mon Sep 17 00:00:00 2001 From: Wolfgang Schnerring Date: Fri, 29 Aug 2025 09:12:56 +0200 Subject: [PATCH 1/4] Fix installed module name, closes #7 --- CHANGES.rst | 4 +++- plugin.py => pytest_remove_stale_bytecode.py | 0 setup.py | 4 ++-- test_plugin.py | 10 +++++----- 4 files changed, 10 insertions(+), 8 deletions(-) rename plugin.py => pytest_remove_stale_bytecode.py (100%) diff --git a/CHANGES.rst b/CHANGES.rst index d74840d..76fae30 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,7 +6,9 @@ CHANGES 6.1 (unreleased) ================ -- Nothing changed yet. +- Fix installed module name + (`#7 `_) + 6.0 (2023-07-07) diff --git a/plugin.py b/pytest_remove_stale_bytecode.py similarity index 100% rename from plugin.py rename to pytest_remove_stale_bytecode.py diff --git a/setup.py b/setup.py index 5543355..417472a 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ def project_path(*names): entry_points={ 'pytest11': [ - 'removestalebytecode = plugin', + 'removestalebytecode = pytest_remove_stale_bytecode', ], }, @@ -64,5 +64,5 @@ def project_path(*names): )), zip_safe=False, - py_modules=['plugin'], + py_modules=['pytest_remove_stale_bytecode'], ) diff --git a/test_plugin.py b/test_plugin.py index f07ee4e..569066d 100644 --- a/test_plugin.py +++ b/test_plugin.py @@ -1,5 +1,5 @@ -from plugin import pytest_version -from plugin import python_version +from pytest_remove_stale_bytecode import pytest_version +from pytest_remove_stale_bytecode import python_version from unittest import mock import pytest @@ -8,8 +8,8 @@ def test_version(): - import plugin - assert plugin.__version__ + import pytest_remove_stale_bytecode + assert pytest_remove_stale_bytecode.__version__ @pytest.mark.parametrize("ext", ['.pyc', '.pyo']) @@ -116,6 +116,6 @@ def test_plugin_removes_python3_PYTEST_bytecode_files(testdir, ext): def test_plugin_does_not_break_if_file_is_removed_externally(testdir): bar = testdir.makefile('.pyc', bar='') - with mock.patch('plugin.delete_file', side_effect=FileNotFoundError): + with mock.patch('pytest_remove_stale_bytecode.delete_file', side_effect=FileNotFoundError): testdir.runpytest("-v") assert bar.exists() From 959e79b1403bfe20fa8e315417b7e0be1b37e7f7 Mon Sep 17 00:00:00 2001 From: Wolfgang Schnerring Date: Fri, 29 Aug 2025 09:14:17 +0200 Subject: [PATCH 2/4] Replace deprecated ``pkg_resources`` with ``importlib.metdata`` --- CHANGES.rst | 1 + pytest_remove_stale_bytecode.py | 7 +++---- setup.py | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 76fae30..85ec2e4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,7 @@ CHANGES - Fix installed module name (`#7 `_) +- Replace deprecated ``pkg_resources`` with ``importlib.metdata`` diff --git a/pytest_remove_stale_bytecode.py b/pytest_remove_stale_bytecode.py index 5c63b3c..1825625 100644 --- a/pytest_remove_stale_bytecode.py +++ b/pytest_remove_stale_bytecode.py @@ -1,13 +1,12 @@ +import importlib.metadata import os import os.path -import pkg_resources import sys -__version__ = pkg_resources.get_distribution( - 'pytest-remove-stale-bytecode').version +__version__ = importlib.metadata.version('pytest-remove-stale-bytecode') python_version = '{0.major}{0.minor}'.format(sys.version_info) -pytest_version = pkg_resources.get_distribution('pytest').version +pytest_version = importlib.metadata.version('pytest') compiled_suffixes = '.pyc', '.pyo' diff --git a/setup.py b/setup.py index 417472a..8634cb3 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,6 @@ def project_path(*names): install_requires=[ 'pytest', - 'setuptools', ], extras_require={ From fa16495a7f7b3896ad136c3f92da3c47e0f0ca14 Mon Sep 17 00:00:00 2001 From: Steffen Allner Date: Wed, 19 Nov 2025 12:51:21 +0100 Subject: [PATCH 3/4] Rename the test module to be consistent. --- test_plugin.py => test_pytest_remove_stale_bytecode.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename test_plugin.py => test_pytest_remove_stale_bytecode.py (97%) diff --git a/test_plugin.py b/test_pytest_remove_stale_bytecode.py similarity index 97% rename from test_plugin.py rename to test_pytest_remove_stale_bytecode.py index 569066d..e66d406 100644 --- a/test_plugin.py +++ b/test_pytest_remove_stale_bytecode.py @@ -116,6 +116,7 @@ def test_plugin_removes_python3_PYTEST_bytecode_files(testdir, ext): def test_plugin_does_not_break_if_file_is_removed_externally(testdir): bar = testdir.makefile('.pyc', bar='') - with mock.patch('pytest_remove_stale_bytecode.delete_file', side_effect=FileNotFoundError): + with mock.patch('pytest_remove_stale_bytecode.delete_file', + side_effect=FileNotFoundError): testdir.runpytest("-v") assert bar.exists() From a1578e76d6dd4a264f4a78906c783a8641bcf18e Mon Sep 17 00:00:00 2001 From: Steffen Allner Date: Wed, 19 Nov 2025 13:20:30 +0100 Subject: [PATCH 4/4] Fix the coverage reporting. coverage-python-version did require coveragy < 6 but this old version was not reporting the coverage correctly anymore. We do not need this plugin anymore, so clean it up. --- .coveragerc | 2 +- tox.ini | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.coveragerc b/.coveragerc index db89e7a..835ac51 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,6 @@ [run] branch = True -source = plugin +source = pytest_remove_stale_bytecode [report] precision = 2 diff --git a/tox.ini b/tox.ini index b1a8253..8ad20d3 100644 --- a/tox.ini +++ b/tox.ini @@ -11,15 +11,14 @@ envlist= [testenv] deps = pytest commands = - {envbindir}/pytest {posargs:test_plugin.py} [] + {envbindir}/pytest {posargs:test_pytest_remove_stale_bytecode.py} [] [testenv:coverage] basepython = python3 deps = {[testenv]deps} coverage - coverage-python-version commands = - coverage run {envbindir}/py.test {posargs:test_plugin.py} [] + coverage run {envbindir}/py.test {posargs:test_pytest_remove_stale_bytecode.py} [] coverage html - coverage report + coverage report -m