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/CHANGES.rst b/CHANGES.rst index 75c246a..c4282a9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -18,6 +18,14 @@ Features - Update tests to ``pytest >= 7.4``. +Other changes +------------- + +- Fix installed module name + (`#7 `_) + +- Replace deprecated ``pkg_resources`` with ``importlib.metadata``. + 6.0 (2023-07-07) ================ diff --git a/plugin.py b/pytest_remove_stale_bytecode.py similarity index 88% rename from plugin.py rename to pytest_remove_stale_bytecode.py index 5c63b3c..1825625 100644 --- a/plugin.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 3ca3138..73d043c 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,6 @@ def project_path(*names): install_requires=[ 'pytest', - 'setuptools', ], extras_require={ @@ -27,7 +26,7 @@ def project_path(*names): entry_points={ 'pytest11': [ - 'removestalebytecode = plugin', + 'removestalebytecode = pytest_remove_stale_bytecode', ], }, @@ -64,5 +63,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_pytest_remove_stale_bytecode.py similarity index 91% rename from test_plugin.py rename to test_pytest_remove_stale_bytecode.py index f07ee4e..e66d406 100644 --- a/test_plugin.py +++ b/test_pytest_remove_stale_bytecode.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,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('plugin.delete_file', side_effect=FileNotFoundError): + with mock.patch('pytest_remove_stale_bytecode.delete_file', + side_effect=FileNotFoundError): testdir.runpytest("-v") assert bar.exists() 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