././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1712327008.3024857 pytest-cython-0.3.1/0000755000175100001770000000000014604004540013747 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/.bumpversion.cfg0000644000175100001770000000061614604004533017064 0ustar00runnerdocker[bumpversion] current_version = 0.3.1 parse = (?P\d+)\.(?P\d+)\.(?P\d+) (?:\.(?Pdev)(?P\d+))? serialize = {major}.{minor}.{micro}.{release}{devnum} {major}.{minor}.{micro} commit = False tag = False [bumpversion:part:release] optional_value = stable values = dev stable [bumpversion:file:setup.py] [bumpversion:file:tests/example-project/setup.py] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/.coveragerc0000644000175100001770000000021514604004533016070 0ustar00runnerdocker[paths] source = cython [run] branch = True parallel = true source = cython [report] precision = 2 show_missing = true omit = *migrations* ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/.editorconfig0000644000175100001770000000032714604004533016430 0ustar00runnerdocker# see http://editorconfig.org root = true [*] end_of_line = lf trim_trailing_whitespace = true insert_final_newline = true indent_style = space indent_size = 4 charset = utf-8 [*.{bat,cmd,ps1}] end_of_line = crlf ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/CHANGELOG.md0000644000175100001770000000313414604004533015563 0ustar00runnerdocker# Changelog ## 0.2.2 Onwards Please see the [GitHub releases](https://github.com/lgpage/pytest-cython/releases) for what has changed ## 0.2.1 The full list of merged changes is: - #26: fix: pytest_collect_file to take into account pytest fspath deprecation in Node constructors - #29: chore: use GitHub workflows in place of Travis - #30: chore: use markdown project files - #31: chore: add renovate bot Special thanks to the following contributors that made this release possible: - @AlenkaF - @shvenkat ## 0.2.0 The full list of merged changes is: - #11: Update tests - #15, #17: Dropped support for Python 2, added support for Python 3.6+ - #18: New patched pyimport implementation, maintaining better compatibility with the installed pytest version - #19: Rework how test collection works, making it possible to directly specify .pyx files to run, and reporting tests as being from the .pyx files as opposed to the compiled extension modules - #20: Fix handling of cython generated autotestdicts; prevents running the same tests repeatedly, and adds better reporting of test line numbers - #21: Add CI job with Windows - #22: Various documentation improvements Special thanks to the following contributors that made this release possible: - @embray ## 0.1.1 The full list of merged changes is: - #5: Fix DoctestModule deprecated error - #6: Fix typo from #5 - #7: Fix support for relative imports - #9: Maintain backwards compatibility for pytest 4.x Special thanks to the following contributors that made this release possible: - @embray - @thrasibule ## 0.1.0 First release on PyPI (2016-04-17) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/CODE_OF_CONDUCT.md0000644000175100001770000001215614604004533016555 0ustar00runnerdocker# Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at pytestcython@gmail.com. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at . Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at . Translations are available at . ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/CONTRIBUTING.md0000644000175100001770000000450314604004533016204 0ustar00runnerdocker# Contributing Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. ## Bug reports When [reporting a bug](https://github.com/lgpage/pytest-cython/issues) please include: - Your operating system name and version. - The `cython` and `pytest` versions you are using - Detailed steps to reproduce the bug. - Any other details about your local setup that might be helpful in troubleshooting. ## Documentation improvements `pytest-cython` could always use more documentation, whether as part of the official `pytest-cython` docs, in docstrings, or even on the web in blog posts, articles, and such. ## Feature requests and feedback The best way to send feedback is to [file an issue](https://github.com/lgpage/pytest-cython/issues). If you are proposing a new feature: - Explain in detail how it would work. - Keep the scope as narrow as possible, to make it easier to implement. - Remember that this is a volunteer-driven project, and that code contributions are welcome :) ## Development To set up `pytest-cython` for local development: 1. Fork [pytest-cython](https://github.com/lgpage/pytest-cython) (look for the \"fork\" button). 2. Clone your fork locally: ```shell git clone git@github.com:your_name_here/pytest-cython.git ``` 3. Create a branch for local development: ```shell git checkout -b name-of-your-bugfix-or-feature ``` 4. When you're done making changes, run all the checks and tests with the [nox](https://tox.wiki/en/latest) command: ```shell nox ``` 5. Commit your changes and push your branch to GitHub: ```shell git add . git commit -m "Your detailed description of your changes." git push origin name-of-your-bugfix-or-feature ``` 6. Submit a pull request through the GitHub website. ## Pull Request Guidelines If you need some code review or feedback while you're developing the code just make the pull request. Before merging, you should: 1. Update the documentation when there's new API, functionality etc. 2. Add a note to `CHANGELOG.rst` about the changes. ## Tips To list all [nox](https://tox.wiki/en/latest) tasks: ```shell nox --list ``` To run a subset of tests use one of the task from the above list, for example: ```shell nox --session "test(cython='0.29', python='3.9', pytest='7')" ``` ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/LICENSE.md0000644000175100001770000000211314604004533015352 0ustar00runnerdockerThe MIT License (MIT) ===================== Copyright (c) 2016 Logan Page Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/MANIFEST.in0000644000175100001770000000077614604004533015521 0ustar00runnerdockergraft docs graft tests include .bumpversion.cfg include .coveragerc include .editorconfig include CHANGELOG.md include CODE_OF_CONDUCT.md include CONTRIBUTING.md include LICENSE.md include README.md include noxfile.py include requirements-dev.txt global-exclude *.py[cod] __pycache__ *.so *.pyd *.dylib exclude renovate.json exclude .github/**/* exclude .vscode/* exclude tests/example-project/build/**/* exclude tests/example-project/src/pypackage/*.c exclude tests/example-project/src/pypackage/*.cpp ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1712327008.3024857 pytest-cython-0.3.1/PKG-INFO0000644000175100001770000000744014604004540015051 0ustar00runnerdockerMetadata-Version: 2.1 Name: pytest-cython Version: 0.3.1 Summary: A plugin for testing Cython extension modules Home-page: https://github.com/lgpage/pytest-cython Author: Logan Page Author-email: page.lg@gmail.com License: MIT Keywords: pytest,py.test,cython,doctest Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Utilities Description-Content-Type: text/markdown License-File: LICENSE.md Requires-Dist: pytest>=8 # Overview [![PyPI Package latest release](https://img.shields.io/pypi/v/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![PyPI Package monthly downloads](https://img.shields.io/pypi/dm/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![PyPI Wheel](https://img.shields.io/pypi/wheel/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![Supported versions](https://img.shields.io/pypi/pyversions/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![Supported implementations](https://img.shields.io/pypi/implementation/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![Conda Version](https://img.shields.io/conda/vn/conda-forge/pytest-cython.svg)](https://anaconda.org/conda-forge/pytest-cython) [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/pytest-cython.svg)](https://anaconda.org/conda-forge/pytest-cython) [![CI Check Status](https://github.com/lgpage/pytest-cython/actions/workflows/python-check.yml/badge.svg?branch=main)](https://github.com/lgpage/pytest-cython/actions/workflows/python-check.yml?query=branch%3Amain) [![CI Tests Status](https://github.com/lgpage/pytest-cython/actions/workflows/python-test.yml/badge.svg?branch=main)](https://github.com/lgpage/pytest-cython/actions/workflows/python-test.yml?query=branch%3Amain) [![Documentation Status](https://readthedocs.org/projects/pytest-cython/badge/?style=flat)](https://readthedocs.org/projects/pytest-cython) This [pytest](https://github.com/pytest-dev/pytest) plugin allows for the doctesting of C extension modules for Python, specifically created through [cython](https://cython.org/). ## Installation You can install "pytest-cython" via [pip](https://pypi.org/project/pip/) from [PyPI](https://pypi.org): ``` shell pip install pytest-cython ``` ## Usage Basic usage: ``` shell pytest --doctest-cython ``` You can also run the doctests for a single `.pyx` file as such: ``` shell pytest --doctest-cython path/to/module.pyx ``` ### Note 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.3.x | 8 | 0.29, 3 | | 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 detailed description. ## Acknowledgements This [pytest](https://github.com/pytest-dev/pytest) plugin was generated with [cookiecutter](https://github.com/cookiecutter/cookiecutter) along with [\@hackebrot](https://github.com/hackebrot)'s [cookiecutter-pytest-plugin](https://github.com/pytest-dev/cookiecutter-pytest-plugin) and [\@ionelmc](https://github.com/ionelmc)'s [cookiecutter-pylibrary](https://github.com/ionelmc/cookiecutter-pylibrary) templates. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/README.md0000644000175100001770000000574714604004533015245 0ustar00runnerdocker# Overview [![PyPI Package latest release](https://img.shields.io/pypi/v/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![PyPI Package monthly downloads](https://img.shields.io/pypi/dm/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![PyPI Wheel](https://img.shields.io/pypi/wheel/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![Supported versions](https://img.shields.io/pypi/pyversions/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![Supported implementations](https://img.shields.io/pypi/implementation/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![Conda Version](https://img.shields.io/conda/vn/conda-forge/pytest-cython.svg)](https://anaconda.org/conda-forge/pytest-cython) [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/pytest-cython.svg)](https://anaconda.org/conda-forge/pytest-cython) [![CI Check Status](https://github.com/lgpage/pytest-cython/actions/workflows/python-check.yml/badge.svg?branch=main)](https://github.com/lgpage/pytest-cython/actions/workflows/python-check.yml?query=branch%3Amain) [![CI Tests Status](https://github.com/lgpage/pytest-cython/actions/workflows/python-test.yml/badge.svg?branch=main)](https://github.com/lgpage/pytest-cython/actions/workflows/python-test.yml?query=branch%3Amain) [![Documentation Status](https://readthedocs.org/projects/pytest-cython/badge/?style=flat)](https://readthedocs.org/projects/pytest-cython) This [pytest](https://github.com/pytest-dev/pytest) plugin allows for the doctesting of C extension modules for Python, specifically created through [cython](https://cython.org/). ## Installation You can install "pytest-cython" via [pip](https://pypi.org/project/pip/) from [PyPI](https://pypi.org): ``` shell pip install pytest-cython ``` ## Usage Basic usage: ``` shell pytest --doctest-cython ``` You can also run the doctests for a single `.pyx` file as such: ``` shell pytest --doctest-cython path/to/module.pyx ``` ### Note 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.3.x | 8 | 0.29, 3 | | 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 detailed description. ## Acknowledgements This [pytest](https://github.com/pytest-dev/pytest) plugin was generated with [cookiecutter](https://github.com/cookiecutter/cookiecutter) along with [\@hackebrot](https://github.com/hackebrot)'s [cookiecutter-pytest-plugin](https://github.com/pytest-dev/cookiecutter-pytest-plugin) and [\@ionelmc](https://github.com/ionelmc)'s [cookiecutter-pylibrary](https://github.com/ionelmc/cookiecutter-pylibrary) templates. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1712327008.2984855 pytest-cython-0.3.1/docs/0000755000175100001770000000000014604004540014677 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/docs/conf.py0000644000175100001770000000276514604004533016212 0ustar00runnerdocker# -*- coding: utf-8 -*- import os import sys import sphinx_py3doc_enhanced_theme from pytest_cython import __version__ as release sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) extensions = [ 'myst_parser', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.coverage', 'sphinx.ext.doctest', 'sphinx.ext.extlinks', 'sphinx.ext.ifconfig', 'sphinx.ext.napoleon', 'sphinx.ext.todo', 'sphinx.ext.viewcode', ] if os.getenv('SPELLCHECK'): extensions += 'sphinxcontrib.spelling', spelling_show_suggestions = True spelling_lang = 'en_US' source_suffix = { '.rst': 'restructuredtext', '.md': 'markdown', } master_doc = 'index' project = 'pytest-cython' year = '2021' author = 'Logan Page' copyright = '{0}, {1}'.format(year, author) pygments_style = 'trac' templates_path = ['.'] extlinks = { 'issue': ('https://github.com/lgpage/pytest-cython/issues/%s', '#%s'), 'pr': ('https://github.com/lgpage/pytest-cython/pull/%s', 'PR #%s'), } html_theme = "sphinx_py3doc_enhanced_theme" html_theme_path = [sphinx_py3doc_enhanced_theme.get_html_theme_path()] html_theme_options = { 'githuburl': 'https://github.com/lgpage/pytest-cython/' } html_use_smartypants = True html_last_updated_fmt = '%b %d, %Y' html_split_index = True html_sidebars = { '**': ['searchbox.html', 'localtoc.html', 'sourcelink.html'], } html_short_title = f'{project}-{release}' napoleon_use_ivar = True napoleon_use_rtype = False napoleon_use_param = False ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/docs/index.rst0000644000175100001770000000040314604004533016537 0ustar00runnerdocker############# pytest-cython ############# .. contents:: :depth: 2 .. include:: ../README.md :parser: myst_parser.sphinx_ .. include:: ../CHANGELOG.md :parser: myst_parser.sphinx_ .. include:: ../CONTRIBUTING.md :parser: myst_parser.sphinx_ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/docs/requirements.txt0000644000175100001770000000012614604004533020164 0ustar00runnerdockermyst-parser pyenchant sphinx-py3doc-enhanced-theme sphinx>=1.3 sphinxcontrib-spelling ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/docs/spelling_wordlist.txt0000644000175100001770000000036414604004533021211 0ustar00runnerdockerAcknowledgements AlenkaF args autotestdicts builtin builtins callstack Changelog classmethod classmethods cython docstrings doctesting doctests embray fspath Indices inplace kwargs pyimport pytest shvenkat staticmethod staticmethods thrasibule ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/noxfile.py0000644000175100001770000000222614604004533015771 0ustar00runnerdockerimport nox @nox.session() def lint(session): session.install("flake8") session.run("flake8", "src", "tests", "setup.py", "noxfile.py", "docs/conf.py") @nox.session() def check(session): session.install("build") session.install("twine") session.install("wheel") session.install("check-manifest") session.run("check-manifest") session.run("python", "-m", "build") session.run("twine", "check", "dist/*.*") @nox.session @nox.parametrize('python', ["3.10", "3.11", "3.12"]) @nox.parametrize('pytest', ["8"]) @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", ".") session.run("pytest", "-vv", "tests", "src") @nox.session() def docs(session): session.install("-r", "docs/requirements.txt") session.install("-e", ".") session.run("sphinx-build", "-b", "spelling", "docs", "dist/docs") session.run("sphinx-build", "-b", "linkcheck", "docs", "dist/docs") session.run("sphinx-build", "-E", "-b", "html", "docs", "dist/docs") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/requirements-dev.txt0000644000175100001770000000007214604004533020010 0ustar00runnerdockerbumpversion check-manifest cython flake8 isort nox pytest ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1712327008.3024857 pytest-cython-0.3.1/setup.cfg0000644000175100001770000000155014604004540015571 0ustar00runnerdocker[bdist_wheel] universal = 1 [aliases] release = register clean --all sdist bdist_wheel [flake8] max-line-length = 120 max-complexity = 15 exclude = tests/*,*/migrations/*,*/south_migrations/* [tool:pytest] norecursedirs = .git .tox .env .venv dist build tests/example-project python_files = test_*.py *_test.py tests.py addopts = -rxEfsw --strict-markers --doctest-modules --doctest-glob=\*.rst --ignore=docs/conf.py --tb=short filterwarnings = ignore:the imp module is deprecated in favour of importlib ignore:Using or importing the ABCs from 'collections' ignore:The TerminalReporter.writer attribute is deprecated ignore:lib2to3 package is deprecated [isort] force_single_line = True line_length = 120 known_first_party = pytest-cython default_section = THIRDPARTY forced_separate = test_pytest_cython [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/setup.py0000755000175100001770000000305414604004533015470 0ustar00runnerdocker#!/usr/bin/env python # -*- encoding: utf-8 -*- from glob import glob from os import path from setuptools import find_packages from setuptools import setup this_directory = path.abspath(path.dirname(__file__)) with open(path.join(this_directory, 'README.md')) as readme_file: long_description = readme_file.read() setup( name='pytest-cython', version='0.3.1', description='A plugin for testing Cython extension modules', long_description=long_description, long_description_content_type='text/markdown', author='Logan Page', author_email='page.lg@gmail.com', license='MIT', url='https://github.com/lgpage/pytest-cython', packages=find_packages('src'), package_dir={'': 'src'}, py_modules=[path.splitext(path.basename(p))[0] for p in glob('src/*.py')], include_package_data=True, zip_safe=False, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Software Development :: Testing', 'Topic :: Utilities', ], keywords=[ 'pytest', 'py.test', 'cython', 'doctest', ], install_requires=[ 'pytest>=8', ], entry_points={ 'pytest11': [ 'pytest_cython = pytest_cython.plugin', ], }, ) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1712327008.2944856 pytest-cython-0.3.1/src/0000755000175100001770000000000014604004540014536 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1712327008.2984855 pytest-cython-0.3.1/src/pytest_cython/0000755000175100001770000000000014604004540017452 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/src/pytest_cython/__init__.py0000644000175100001770000000051514604004533021566 0ustar00runnerdockertry: from pkg_resources import get_distribution __version__ = get_distribution('pytest-cython').version del get_distribution except Exception: import warnings warnings.warn('could not get pytest-cython version; pkg_resources ' 'not available or package not installed') __version__ = '0.0.0' ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/src/pytest_cython/plugin.py0000644000175100001770000001275314604004533021334 0ustar00runnerdocker""" discover and run doctests in Cython extension modules.""" import os import pathlib import re import sysconfig import pytest from typing import Any, Iterable, Union from _pytest.nodes import Collector from _pytest.doctest import skip, DoctestModule, DoctestItem from _pytest.pathlib import resolve_package_path, ImportMode CYTHON_SUFFIXES = ['.py', '.pyx'] EXT_SUFFIX = sysconfig.get_config_var("EXT_SUFFIX") IGNORE_IMPORTMISMATCH_KEY = "PY_IGNORE_IMPORTMISMATCH" IGNORE_IMPORTMISMATCH = os.environ.get(IGNORE_IMPORTMISMATCH_KEY, "") def pytest_addoption(parser: pytest.Parser): group = parser.getgroup("cython") group.addoption( "--doctest-cython", action="store_true", default=False, help="run doctests in all .so and .pyd modules", dest="doctest_cython", ) def pytest_collect_file(file_path: pathlib.Path, path, parent: pytest.Collector) -> pytest.Module: config = parent.config if file_path.suffix not in CYTHON_SUFFIXES or not config.getoption('--doctest-cython'): return bin_path = file_path.with_suffix(EXT_SUFFIX) if not bin_path.exists(): return # only run test if matching .so and .pyx files exist return _PatchedDoctestModule.from_parent(parent, path=file_path) class _PatchedDoctestModule(DoctestModule): def collect(self) -> Iterable[DoctestItem]: mode = ImportMode(self.config.getoption("importmode")) if mode is not ImportMode.importlib and IGNORE_IMPORTMISMATCH != "1": # we know we will get an import file mismatch error so ignore it for now, # we will double check the import paths after import. os.environ[IGNORE_IMPORTMISMATCH_KEY] = "1" try: items = list(super().collect()) # import the module and collect tests finally: # set ignore variable back to its original value os.environ[IGNORE_IMPORTMISMATCH_KEY] = IGNORE_IMPORTMISMATCH module = self.obj # module already imported try: _check_module_import(module, self.path, mode) except Collector.CollectError: if self.config.getvalue("doctest_ignore_import_errors"): skip("unable to import module %r" % self.path) else: raise return _add_line_numbers(module, items) def _without_suffixes(path: Union[str, pathlib.Path]) -> pathlib.Path: path = pathlib.Path(path) return path.with_name(path.name.split('.')[0]).with_suffix('') def _get_module_name(path: pathlib.Path) -> str: pkg_path = resolve_package_path(path) if pkg_path is not None: pkg_root = pkg_path.parent names = list(path.with_suffix("").relative_to(pkg_root).parts) if names[-1] == "__init__": names.pop() module_name = ".".join(names) else: pkg_root = path.parent module_name = path.stem return module_name def _check_module_import(module: Any, path: pathlib.Path, mode: ImportMode) -> None: # double check that the only difference is the extension else raise an exception if mode is ImportMode.importlib or IGNORE_IMPORTMISMATCH == "1": return module_name = _get_module_name(path) module_file = _without_suffixes(module.__file__) import_file = _without_suffixes(path) if module_file == import_file: return raise Collector.CollectError( "import file mismatch:\n" "imported module %r has this __file__ attribute:\n" " %s\n" "which is not the same as the test file we want to collect:\n" " %s\n" "HINT: remove __pycache__ / .pyc files and/or use a " "unique basename for your test file modules" % (module_name, module_file, import_file) ) def _add_line_numbers(module: Any, items: Iterable[DoctestItem]) -> Iterable[DoctestItem]: # handle tests from Cython's internal __test__ dict generated by # the autotestdict directive; we exclude the tests from __test__, # though they do give us a little bonus if they exist: we can extract # the line number of the test lineno_re = re.compile(r'\(line (\d+)\)') test_dict = module.__name__ + '.__test__' test_items = {x.name: x for x in items} for test_name in list(test_items.keys()): if not test_name.startswith(test_dict + '.'): continue match = lineno_re.search(test_name) lineno = int(match.group(1)) if match else None # If somehow the equivalent test does not already exist, we # keep the __test__ test (maybe it is something else not # generated by autotestdict) equiv_test_name = test_name.split()[0].replace(test_dict, module.__name__) if (equiv_test_name not in test_items or not test_items[equiv_test_name].dtest.examples): # for some reason the equivalent test was not found (e.g. # the module was compiled with docstrings stripped) so keep # the __test__ test but hide the fact that it came from the # __test__ dict test_items[test_name].name = equiv_test_name # set lineno on the __test__ test as well, since normally # it is not set by doctest test_items[test_name].dtest.lineno = lineno continue # Delete the __test__ test, but try to update the lineno of the # equivalent test del test_items[test_name] test_items[equiv_test_name].dtest.lineno = lineno for test in sorted(test_items.values(), key=lambda x: x.name): yield test ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1712327008.3024857 pytest-cython-0.3.1/src/pytest_cython.egg-info/0000755000175100001770000000000014604004540021144 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327008.0 pytest-cython-0.3.1/src/pytest_cython.egg-info/PKG-INFO0000644000175100001770000000744014604004540022246 0ustar00runnerdockerMetadata-Version: 2.1 Name: pytest-cython Version: 0.3.1 Summary: A plugin for testing Cython extension modules Home-page: https://github.com/lgpage/pytest-cython Author: Logan Page Author-email: page.lg@gmail.com License: MIT Keywords: pytest,py.test,cython,doctest Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Utilities Description-Content-Type: text/markdown License-File: LICENSE.md Requires-Dist: pytest>=8 # Overview [![PyPI Package latest release](https://img.shields.io/pypi/v/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![PyPI Package monthly downloads](https://img.shields.io/pypi/dm/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![PyPI Wheel](https://img.shields.io/pypi/wheel/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![Supported versions](https://img.shields.io/pypi/pyversions/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![Supported implementations](https://img.shields.io/pypi/implementation/pytest-cython.svg?style=flat)](https://pypi.org/project/pytest-cython) [![Conda Version](https://img.shields.io/conda/vn/conda-forge/pytest-cython.svg)](https://anaconda.org/conda-forge/pytest-cython) [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/pytest-cython.svg)](https://anaconda.org/conda-forge/pytest-cython) [![CI Check Status](https://github.com/lgpage/pytest-cython/actions/workflows/python-check.yml/badge.svg?branch=main)](https://github.com/lgpage/pytest-cython/actions/workflows/python-check.yml?query=branch%3Amain) [![CI Tests Status](https://github.com/lgpage/pytest-cython/actions/workflows/python-test.yml/badge.svg?branch=main)](https://github.com/lgpage/pytest-cython/actions/workflows/python-test.yml?query=branch%3Amain) [![Documentation Status](https://readthedocs.org/projects/pytest-cython/badge/?style=flat)](https://readthedocs.org/projects/pytest-cython) This [pytest](https://github.com/pytest-dev/pytest) plugin allows for the doctesting of C extension modules for Python, specifically created through [cython](https://cython.org/). ## Installation You can install "pytest-cython" via [pip](https://pypi.org/project/pip/) from [PyPI](https://pypi.org): ``` shell pip install pytest-cython ``` ## Usage Basic usage: ``` shell pytest --doctest-cython ``` You can also run the doctests for a single `.pyx` file as such: ``` shell pytest --doctest-cython path/to/module.pyx ``` ### Note 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.3.x | 8 | 0.29, 3 | | 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 detailed description. ## Acknowledgements This [pytest](https://github.com/pytest-dev/pytest) plugin was generated with [cookiecutter](https://github.com/cookiecutter/cookiecutter) along with [\@hackebrot](https://github.com/hackebrot)'s [cookiecutter-pytest-plugin](https://github.com/pytest-dev/cookiecutter-pytest-plugin) and [\@ionelmc](https://github.com/ionelmc)'s [cookiecutter-pylibrary](https://github.com/ionelmc/cookiecutter-pylibrary) templates. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327008.0 pytest-cython-0.3.1/src/pytest_cython.egg-info/SOURCES.txt0000644000175100001770000000222114604004540023025 0ustar00runnerdocker.bumpversion.cfg .coveragerc .editorconfig CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md LICENSE.md MANIFEST.in README.md noxfile.py requirements-dev.txt setup.cfg setup.py docs/conf.py docs/index.rst docs/requirements.txt docs/spelling_wordlist.txt src/pytest_cython/__init__.py src/pytest_cython/plugin.py src/pytest_cython.egg-info/PKG-INFO src/pytest_cython.egg-info/SOURCES.txt src/pytest_cython.egg-info/dependency_links.txt src/pytest_cython.egg-info/entry_points.txt src/pytest_cython.egg-info/not-zip-safe src/pytest_cython.egg-info/requires.txt src/pytest_cython.egg-info/top_level.txt tests/conftest.py tests/test_pytest_cython.py tests/example-project/.gitignore tests/example-project/setup.py tests/example-project/src/clib/CMakeLists.txt tests/example-project/src/clib/sqrc.c tests/example-project/src/clib/sqrcpp.cpp tests/example-project/src/pypackage/__init__.py tests/example-project/src/pypackage/cython_ext_module.pxd tests/example-project/src/pypackage/cython_ext_module.pyx tests/example-project/src/pypackage/pure_py_module.py tests/example-project/src/pypackage/wrap_c_ext_module.pyx tests/example-project/src/pypackage/wrap_cpp_ext_module.pyx././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327008.0 pytest-cython-0.3.1/src/pytest_cython.egg-info/dependency_links.txt0000644000175100001770000000000114604004540025212 0ustar00runnerdocker ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327008.0 pytest-cython-0.3.1/src/pytest_cython.egg-info/entry_points.txt0000644000175100001770000000006014604004540024436 0ustar00runnerdocker[pytest11] pytest_cython = pytest_cython.plugin ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327008.0 pytest-cython-0.3.1/src/pytest_cython.egg-info/not-zip-safe0000644000175100001770000000000114604004540023372 0ustar00runnerdocker ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327008.0 pytest-cython-0.3.1/src/pytest_cython.egg-info/requires.txt0000644000175100001770000000001214604004540023535 0ustar00runnerdockerpytest>=8 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327008.0 pytest-cython-0.3.1/src/pytest_cython.egg-info/top_level.txt0000644000175100001770000000001614604004540023673 0ustar00runnerdockerpytest_cython ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1712327008.2984855 pytest-cython-0.3.1/tests/0000755000175100001770000000000014604004540015111 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/conftest.py0000644000175100001770000000003414604004533017307 0ustar00runnerdockerpytest_plugins = "pytester" ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1712327008.2984855 pytest-cython-0.3.1/tests/example-project/0000755000175100001770000000000014604004540020210 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/example-project/.gitignore0000644000175100001770000000010314604004533022174 0ustar00runnerdocker # Ignore Cython build files src/pypackage/*.c src/pypackage/*.cpp ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/example-project/setup.py0000644000175100001770000000140414604004533021723 0ustar00runnerdocker#!/usr/bin/env python # -*- encoding: utf-8 -*- if __name__ == "__main__": import sys from setuptools import setup from setuptools import Extension from Cython.Build import cythonize directives = { 'autotestdict': True, 'embedsignature': False, 'language_level': sys.version_info[0], 'linetrace': False, 'profile': False, } extensions = [ Extension('*', ['src/pypackage/*.pyx']) ] setup( name='pytest-cython', version='0.3.1', description="Example Cython project for pytest-cython tests", package_dir={'': 'src'}, packages=['pypackage'], zip_safe=False, ext_modules=cythonize(extensions, compiler_directives=directives) ) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1712327008.2944856 pytest-cython-0.3.1/tests/example-project/src/0000755000175100001770000000000014604004540020777 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1712327008.3024857 pytest-cython-0.3.1/tests/example-project/src/clib/0000755000175100001770000000000014604004540021710 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/example-project/src/clib/CMakeLists.txt0000644000175100001770000000021214604004533024445 0ustar00runnerdocker cmake_minimum_required(VERSION 2.8) project (cython_example_clib) add_library(sqrc SHARED sqrc.c) add_library(sqrcpp SHARED sqrcpp.cpp) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/example-project/src/clib/sqrc.c0000644000175100001770000000012614604004533023025 0ustar00runnerdocker int isqr(int a){ return (a * a); } double dsqr(double a){ return (a * a); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/example-project/src/clib/sqrcpp.cpp0000644000175100001770000000016014604004533023723 0ustar00runnerdocker template T vsqr(T a){ return (a * a); } template int vsqr(int); template double vsqr(double); ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1712327008.3024857 pytest-cython-0.3.1/tests/example-project/src/pypackage/0000755000175100001770000000000014604004540022743 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/example-project/src/pypackage/__init__.py0000644000175100001770000000000014604004533025044 0ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/example-project/src/pypackage/cython_ext_module.pxd0000644000175100001770000000056714604004533027223 0ustar00runnerdocker cdef int cfoo(int a, int b) except? -1 cdef int cbar(int a, int b) except? -1 nogil cdef inline int cspam(int a, int b) except? -1 nogil cdef class Eggs: cdef: readonly int a readonly int b cdef int foo(Eggs self) except? -1 cdef int bar(Eggs self) except? -1 nogil cdef int spam(Eggs self) except? -1 nogil cpdef int fubar(Eggs self) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/example-project/src/pypackage/cython_ext_module.pyx0000644000175100001770000000266514604004533027251 0ustar00runnerdocker cdef int cfoo(int a, int b) except? -1: """ >>> cfoo(1, 1) 2 """ return a + b cdef int cbar(int a, int b) except? -1 nogil: """ >>> cbar(1, 1) 2 """ return a + b cdef inline int cspam(int a, int b) except? -1 nogil: """ >>> cspam(1, 1) 2 """ return (a + b) cdef class Eggs: def __init__(self, a, b): """ >>> eggs = Eggs(1, 1) >>> eggs.a 1 >>> eggs.b 1 """ self.a = a self.b = b cdef int foo(Eggs self) except? -1: """ >>> eggs = Eggs(1, 1) >>> eggs.foo() 2 """ return self.a + self.b cdef int bar(Eggs self) except? -1 nogil: """ >>> eggs = Eggs(1, 1) >>> eggs.bar() 2 """ return self.a + self.b cdef int spam(Eggs self) except? -1 nogil: """ >>> eggs = Eggs(1, 1) >>> eggs.spam() 2 """ return cspam(self.a, self.b) cpdef int fubar(Eggs self): """ >>> eggs = Eggs(1, 1) >>> eggs.fubar() 2 """ return self.a + self.b def blarg(self): """ >>> eggs = Eggs(1, 1) >>> eggs.blarg() 2 """ return self.a + self.b def failing_test(self): """ >>> eggs = Eggs(1, 1) >>> eggs.failing_test() False """ return True ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/example-project/src/pypackage/pure_py_module.py0000644000175100001770000000062714604004533026354 0ustar00runnerdocker def foo(a, b): """ >>> foo(1, 1) 2 """ return a + b class Eggs: def __init__(self, a, b): """ >>> eggs = Eggs(1, 1) >>> eggs.a 1 >>> eggs.b 1 """ self.a = a self.b = b def foo(self): """ >>> eggs = Eggs(1, 1) >>> eggs.foo() 2 """ return self.a + self.b ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/example-project/src/pypackage/wrap_c_ext_module.pyx0000644000175100001770000000074014604004533027210 0ustar00runnerdocker cdef extern from "../clib/sqrc.c": int isqr(int a) double dsqr(double a) def sqr(a): """ >>> sqr(2) 4 >>> '%.3g' % round(sqr(2.2), 2) '4.84' >>> sqr("asd") Traceback (most recent call last): ... TypeError: Expected int or float type input. """ if isinstance(a, (int, )): return isqr(a) elif isinstance(a, (float, )): return dsqr(a) else: raise TypeError("Expected int or float type input.") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/example-project/src/pypackage/wrap_cpp_ext_module.pyx0000644000175100001770000000076214604004533027554 0ustar00runnerdocker# distutils: language = c++ cdef extern from "../clib/sqrcpp.cpp": T vsqr[T](T a) def sqr(a): """ >>> sqr(2) 4 >>> '%.3g' % round(sqr(2.2), 2) '4.84' >>> sqr("asd") Traceback (most recent call last): ... TypeError: Expected int or float type input. """ if isinstance(a, (int, )): return vsqr(a) elif isinstance(a, (float, )): return vsqr(a) else: raise TypeError("Expected int or float type input.") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1712327003.0 pytest-cython-0.3.1/tests/test_pytest_cython.py0000644000175100001770000000563714604004533021453 0ustar00runnerdockerfrom __future__ import absolute_import import pathlib import pytest import shutil from setuptools.sandbox import run_setup # import pytest_cython as a quite check to ensure it was installed before running tests import pytest_cython.plugin ROOT_PATH = pathlib.Path(__file__).parent PROJECT_PATH = ROOT_PATH.joinpath('example-project') PACKAGE_PATH = PROJECT_PATH.joinpath('src', 'pypackage') IMPORT_MODES = ["append", "prepend", "importlib"] def get_module(basename: str, suffix='.pyx') -> pathlib.Path: return PACKAGE_PATH.joinpath(basename + suffix) def run_pytest(pytester: pytest.Pytester, module: pathlib.Path, import_mode) -> pytest.RunResult: return pytester.runpytest('-vv', '--doctest-cython', '--import-mode', import_mode, str(module)) @pytest.fixture(scope='module', autouse=True) def build_example_project(): 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(pytester, import_mode): module = get_module('cython_ext_module') assert module.exists() result = run_pytest(pytester, module, import_mode) result.stdout.fnmatch_lines([ "*Eggs.__init__*PASSED*", "*Eggs.blarg*PASSED*", "*Eggs.failing_test*FAILED*", "*Eggs.fubar*PASSED*", "*", "*FAILURES*", "*pypackage.cython_ext_module.Eggs.failing_test*", "078*", "079 >>> eggs = Eggs(1, 1)*", "080 >>> eggs.failing_test()*", "Expected:*", " False*", "Got:*", " True*" ]) assert result.ret == 1 @pytest.mark.parametrize('import_mode', IMPORT_MODES) def test_wrap_c_ext_module(pytester, import_mode): module = get_module('wrap_c_ext_module') assert module.exists() result = run_pytest(pytester, module, import_mode) result.stdout.fnmatch_lines([ "*sqr*PASSED*", ]) assert result.ret == 0 @pytest.mark.parametrize('import_mode', IMPORT_MODES) def test_wrap_cpp_ext_module(pytester, import_mode): module = get_module('wrap_cpp_ext_module') assert module.exists() result = run_pytest(pytester, module, import_mode) result.stdout.fnmatch_lines([ "*sqr*PASSED*", ]) assert result.ret == 0 @pytest.mark.parametrize('import_mode', IMPORT_MODES) def test_pure_py_module(pytester, import_mode): module = get_module('pure_py_module', suffix='.py') assert module.exists() result = run_pytest(pytester, module, import_mode) result.stdout.fnmatch_lines([ "*Eggs.__init__*PASSED*", "*Eggs.foo*PASSED*", "*foo*PASSED*", ]) assert result.ret == 0