diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 969e33e..c99e6f9 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.2.dev0 +current_version = 0.2.2 parse = (?P\d+)\.(?P\d+)\.(?P\d+) (?:\.(?Pdev)(?P\d+))? diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 9c43813..57cc660 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -17,14 +17,9 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, windows-latest] - python-version: ["3.9", "3.10", "3.11", "pypy-3.9"] - pytest-version: ["5", "6", "7"] - cython-version: ["0.29"] - exclude: - - python-version: "3.10" - pytest-version: "5" - - python-version: "3.11" - pytest-version: "5" + python-version: ["3.10", "3.11", "3.12", "pypy3.10"] + pytest-version: ["6", "7"] + cython-version: ["0.29", "3"] steps: - uses: actions/checkout@v4 @@ -37,6 +32,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + python -m pip install --upgrade setuptools + python -m pip install pytest==${{ matrix.pytest-version }}.* python -m pip install cython==${{ matrix.cython-version }}.* python -m pip install -e . diff --git a/README.md b/README.md index ef54e9f..1b04dab 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,15 @@ pytest --doctest-cython path/to/module.pyx It is assumed that the C extension modules have been build in place before running `py.test` and there is a matching Cython `.pyx` file +## Compatibility + +The following table describes the versions of Pytest and Cython the each version of the pytest-cython plugin is +compatible with. + +| Version | Pytest | Cython | +| ------- | ------ | ------- | +| 0.2.x | 6, 7 | 0.29, 3 | + ## Issues If you encounter any problems, please [file an issue](https://github.com/lgpage/pytest-cython/issues) along with a diff --git a/noxfile.py b/noxfile.py index 557cccc..cb8e4a2 100644 --- a/noxfile.py +++ b/noxfile.py @@ -20,17 +20,12 @@ def check(session): @nox.session -@nox.parametrize( - "python,pytest", - [ - (python, pytest) - for python in ("3.9", "3.10", "3.11", "pypy3") - for pytest in ("5", "6", "7") - if (python, pytest) != ("3.10", "5") and (python, pytest) != ("3.11", "5") - ], -) -@nox.parametrize('cython', ["0.29"]) +@nox.parametrize('python', ["3.10", "3.11", "3.12"]) +@nox.parametrize('pytest', ["6", "7"]) +@nox.parametrize('cython', ["0.29", "3"]) def test(session, pytest, cython): + session.install("--upgrade", "setuptools") + session.install(f"pytest=={pytest}.*") session.install(f"cython=={cython}.*") session.install("-e", ".") diff --git a/requirements-dev.txt b/requirements-dev.txt index c45da54..a77fd65 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,7 @@ +bumpversion check-manifest cython flake8 +isort nox pytest diff --git a/setup.py b/setup.py index 7311422..f3ed24c 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name='pytest-cython', - version='0.2.2.dev0', + version='0.2.2', description='A plugin for testing Cython extension modules', long_description=long_description, long_description_content_type='text/markdown', @@ -33,8 +33,6 @@ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', - 'Operating System :: Unix', - 'Operating System :: POSIX', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: Implementation :: CPython', @@ -46,7 +44,7 @@ 'pytest', 'py.test', 'cython', 'doctest', ], install_requires=[ - 'pytest>=4.6.0', + 'pytest>=4.6,<8', ], entry_points={ 'pytest11': [ diff --git a/src/pytest_cython/plugin.py b/src/pytest_cython/plugin.py index 28be1ba..62e0bfd 100644 --- a/src/pytest_cython/plugin.py +++ b/src/pytest_cython/plugin.py @@ -195,7 +195,7 @@ def collect(self): del tests[test_name] tests[equiv_test_name].lineno = lineno - for test in tests.values(): + for test in sorted(tests.values(), key=lambda x: x.name): if test.examples: # skip empty doctests if hasattr(DoctestItem, 'from_parent'): yield DoctestItem.from_parent(self, name=test.name, runner=runner, dtest=test) diff --git a/tests/example-project/setup.py b/tests/example-project/setup.py index 0531960..5071a96 100644 --- a/tests/example-project/setup.py +++ b/tests/example-project/setup.py @@ -3,7 +3,6 @@ if __name__ == "__main__": - import os import sys from setuptools import setup @@ -11,34 +10,20 @@ from Cython.Build import cythonize directives = { - 'profile': True, + 'autotestdict': True, 'embedsignature': False, - 'linetrace': False, 'language_level': sys.version_info[0], - # this is the default, but use it explicitly in case that ever - # changes - 'autotestdict': True + 'linetrace': False, + 'profile': False, } - # Enable code coverage for C code: we can't use CFLAGS=-coverage in - # tox.ini, since that may mess with compiling dependencies (e.g. numpy). - # Therefore we set SETUPPY_CFLAGS=-coverage in tox.ini and copy it to - # CFLAGS here (after deps have been safely installed). - macros = [] - if 'TOXENV' in os.environ and 'SETUPPY_CFLAGS' in os.environ: - os.environ['CFLAGS'] = os.environ['SETUPPY_CFLAGS'] - if '-coverage' in os.environ['SETUPPY_CFLAGS']: - directives['linetrace'] = True - macros = [[('CYTHON_TRACE', '1'), ('CYTHON_TRACE_NOGIL', '1')]] - - extensions = [ - Extension('*', ['src/pypackage/*.pyx'], define_macros=macros) + Extension('*', ['src/pypackage/*.pyx']) ] setup( name='pytest-cython', - version='0.2.2.dev0', + version='0.2.2', description="Example Cython project for pytest-cython tests", package_dir={'': 'src'}, packages=['pypackage'], diff --git a/tests/test_pytest_cython.py b/tests/test_pytest_cython.py index 3d64ebf..da98690 100644 --- a/tests/test_pytest_cython.py +++ b/tests/test_pytest_cython.py @@ -1,14 +1,17 @@ from __future__ import absolute_import -import py +import pathlib import pytest +import shutil + from setuptools.sandbox import run_setup import pytest_cython.plugin -PATH = py.path.local(__file__).dirpath() -PATH = PATH.join('example-project', 'src', 'pypackage') +ROOT_PATH = pathlib.Path(__file__).parent +PROJECT_PATH = ROOT_PATH.joinpath('example-project') +PACKAGE_PATH = PROJECT_PATH.joinpath('src', 'pypackage') PYTEST_MAJOR_VERSION = int(pytest.__version__.split('.')[0]) IMPORT_MODES = ['prepend', 'append'] @@ -17,7 +20,7 @@ def get_module(basename, suffix='.pyx'): - return PATH.join(basename + suffix) + return PACKAGE_PATH.joinpath(basename + suffix) def run_pytest(testdir, module, import_mode): @@ -26,15 +29,24 @@ def run_pytest(testdir, module, import_mode): @pytest.fixture(scope='module', autouse=True) def build_example_project(): - path = py.path.local(__file__).dirpath() - setup_py = path.join('example-project', 'setup.py') + shutil.rmtree(PROJECT_PATH.joinpath('build'), True) + shutil.rmtree(PACKAGE_PATH.joinpath('__pycache__'), True) + + for file in PACKAGE_PATH.glob('*.pyd'): + file.unlink() + + for file in PACKAGE_PATH.glob('*.c'): + file.unlink() + + setup_py = PROJECT_PATH.joinpath('setup.py') run_setup(str(setup_py), ['build_ext', '--inplace']) @pytest.mark.parametrize('import_mode', IMPORT_MODES) def test_cython_ext_module(testdir, import_mode): module = get_module('cython_ext_module') - assert module.check() + assert module.exists() + result = run_pytest(testdir, module, import_mode) result.stdout.fnmatch_lines([ "*Eggs.__init__ *PASSED*", @@ -58,7 +70,8 @@ def test_cython_ext_module(testdir, import_mode): @pytest.mark.parametrize('import_mode', IMPORT_MODES) def test_wrap_c_ext_module(testdir, import_mode): module = get_module('wrap_c_ext_module') - assert module.check() + assert module.exists() + result = run_pytest(testdir, module, import_mode) result.stdout.fnmatch_lines([ "*sqr*PASSED*", @@ -69,7 +82,8 @@ def test_wrap_c_ext_module(testdir, import_mode): @pytest.mark.parametrize('import_mode', IMPORT_MODES) def test_wrap_cpp_ext_module(testdir, import_mode): module = get_module('wrap_cpp_ext_module') - assert module.check() + assert module.exists() + result = run_pytest(testdir, module, import_mode) result.stdout.fnmatch_lines([ "*sqr*PASSED*", @@ -80,7 +94,8 @@ def test_wrap_cpp_ext_module(testdir, import_mode): @pytest.mark.parametrize('import_mode', IMPORT_MODES) def test_pure_py_module(testdir, import_mode): module = get_module('pure_py_module', suffix='.py') - assert module.check() + assert module.exists() + result = run_pytest(testdir, module, import_mode) result.stdout.fnmatch_lines([ "*Eggs.__init__*PASSED*",