Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: pin pytest<8 #62

Merged
merged 8 commits into from
Mar 16, 2024
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 .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.2.dev0
current_version = 0.2.2
parse =
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<micro>\d+)
(?:\.(?P<release>dev)(?P<devnum>\d+))?
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 .
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 5 additions & 10 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", ".")
Expand Down
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
bumpversion
check-manifest
cython
flake8
isort
nox
pytest
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -46,7 +44,7 @@
'pytest', 'py.test', 'cython', 'doctest',
],
install_requires=[
'pytest>=4.6.0',
'pytest>=4.6,<8',
],
entry_points={
'pytest11': [
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_cython/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 5 additions & 20 deletions tests/example-project/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,27 @@


if __name__ == "__main__":
import os
import sys

from setuptools import setup
from setuptools import Extension
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'],
Expand Down
35 changes: 25 additions & 10 deletions tests/test_pytest_cython.py
Original file line number Diff line number Diff line change
@@ -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']
Expand All @@ -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):
Expand All @@ -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*",
Expand All @@ -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*",
Expand All @@ -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*",
Expand All @@ -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*",
Expand Down