Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[run]
branch = True
source = plugin
source = pytest_remove_stale_bytecode

[report]
precision = 2
Expand Down
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Features

- Update tests to ``pytest >= 7.4``.

Other changes
-------------

- Fix installed module name
(`#7 <https://github.com/minddistrict/pytest-remove-stale-bytecode/issues/7>`_)

- Replace deprecated ``pkg_resources`` with ``importlib.metadata``.


6.0 (2023-07-07)
================
Expand Down
7 changes: 3 additions & 4 deletions plugin.py → pytest_remove_stale_bytecode.py
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ def project_path(*names):

install_requires=[
'pytest',
'setuptools',
],

extras_require={
},

entry_points={
'pytest11': [
'removestalebytecode = plugin',
'removestalebytecode = pytest_remove_stale_bytecode',
],
},

Expand Down Expand Up @@ -64,5 +63,5 @@ def project_path(*names):
)),

zip_safe=False,
py_modules=['plugin'],
py_modules=['pytest_remove_stale_bytecode'],
)
11 changes: 6 additions & 5 deletions test_plugin.py → test_pytest_remove_stale_bytecode.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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'])
Expand Down Expand Up @@ -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()
7 changes: 3 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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