pytest-cython-0.1.0/0000775000175000017500000000000012704735065014577 5ustar loganlogan00000000000000pytest-cython-0.1.0/setup.cfg0000664000175000017500000000131112704735065016414 0ustar loganlogan00000000000000[bdist_wheel] universal = 1 [aliases] release = register clean --all sdist bdist_wheel [flake8] max-line-length = 140 exclude = tests/*,*/migrations/*,*/south_migrations/* [pytest] norecursedirs = .git .tox .env dist build south_migrations migrations example python_files = test_*.py *_test.py tests.py addopts = -rxEfsw --strict --ignore=docs/conf.py --ignore=setup.py --ignore=src --ignore=ci --ignore=.eggs --doctest-modules --doctest-glob=\*.rst --tb=short -p pytester [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 tag_svn_revision = 0 pytest-cython-0.1.0/AUTHORS.rst0000664000175000017500000000007312704714674016461 0ustar loganlogan00000000000000 Authors ======= * Logan Page - https://github.com/lgpage pytest-cython-0.1.0/ci/0000775000175000017500000000000012704735065015172 5ustar loganlogan00000000000000pytest-cython-0.1.0/ci/appveyor-download.py0000775000175000017500000000735012700257223021215 0ustar loganlogan00000000000000#!/usr/bin/env python """ Use the AppVeyor API to download Windows artifacts. Taken from: https://bitbucket.org/ned/coveragepy/src/tip/ci/download_appveyor.py # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt """ from __future__ import unicode_literals import argparse import os import requests import zipfile def make_auth_headers(): """Make the authentication headers needed to use the Appveyor API.""" path = os.path.expanduser("~/.appveyor.token") if not os.path.exists(path): raise RuntimeError( "Please create a file named `.appveyor.token` in your home directory. " "You can get the token from https://ci.appveyor.com/api-token" ) with open(path) as f: token = f.read().strip() headers = { 'Authorization': 'Bearer {}'.format(token), } return headers def download_latest_artifacts(account_project, build_id): """Download all the artifacts from the latest build.""" if build_id is None: url = "https://ci.appveyor.com/api/projects/{}".format(account_project) else: url = "https://ci.appveyor.com/api/projects/{}/build/{}".format(account_project, build_id) build = requests.get(url, headers=make_auth_headers()).json() jobs = build['build']['jobs'] print(u"Build {0[build][version]}, {1} jobs: {0[build][message]}".format(build, len(jobs))) for job in jobs: name = job['name'] print(u" {0}: {1[status]}, {1[artifactsCount]} artifacts".format(name, job)) url = "https://ci.appveyor.com/api/buildjobs/{}/artifacts".format(job['jobId']) response = requests.get(url, headers=make_auth_headers()) artifacts = response.json() for artifact in artifacts: is_zip = artifact['type'] == "Zip" filename = artifact['fileName'] print(u" {0}, {1} bytes".format(filename, artifact['size'])) url = "https://ci.appveyor.com/api/buildjobs/{}/artifacts/{}".format(job['jobId'], filename) download_url(url, filename, make_auth_headers()) if is_zip: unpack_zipfile(filename) os.remove(filename) def ensure_dirs(filename): """Make sure the directories exist for `filename`.""" dirname, _ = os.path.split(filename) if dirname and not os.path.exists(dirname): os.makedirs(dirname) def download_url(url, filename, headers): """Download a file from `url` to `filename`.""" ensure_dirs(filename) response = requests.get(url, headers=headers, stream=True) if response.status_code == 200: with open(filename, 'wb') as f: for chunk in response.iter_content(16 * 1024): f.write(chunk) else: print(u" Error downloading {}: {}".format(url, response)) def unpack_zipfile(filename): """Unpack a zipfile, using the names in the zip.""" with open(filename, 'rb') as fzip: z = zipfile.ZipFile(fzip) for name in z.namelist(): print(u" extracting {}".format(name)) ensure_dirs(name) z.extract(name) parser = argparse.ArgumentParser(description='Download artifacts from AppVeyor.') parser.add_argument('--id', metavar='PROJECT_ID', default='lgpage/pytest-cython', help='Project ID in AppVeyor.') parser.add_argument('build', nargs='?', metavar='BUILD_ID', help='Build ID in AppVeyor. Eg: master-123') if __name__ == "__main__": # import logging # logging.basicConfig(level="DEBUG") args = parser.parse_args() download_latest_artifacts(args.id, args.build) pytest-cython-0.1.0/ci/appveyor-bootstrap.py0000664000175000017500000001053412704714674021432 0ustar loganlogan00000000000000""" AppVeyor will at least have few Pythons around so there's no point of implementing a bootstrapper in PowerShell. This is a port of https://github.com/pypa/python-packaging-user-guide/blob/master/source/code/install.ps1 with various fixes and improvements that just weren't feasible to implement in PowerShell. """ from __future__ import print_function from os import environ from os.path import exists from subprocess import check_call try: from urllib.request import urlretrieve except ImportError: from urllib import urlretrieve BASE_URL = "https://www.python.org/ftp/python/" GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py" GET_PIP_PATH = "C:\get-pip.py" URLS = { ("2.6", "64"): BASE_URL + "2.6.6/python-2.6.6.amd64.msi", ("2.6", "32"): BASE_URL + "2.6.6/python-2.6.6.msi", ("2.7", "64"): BASE_URL + "2.7.10/python-2.7.10.amd64.msi", ("2.7", "32"): BASE_URL + "2.7.10/python-2.7.10.msi", # NOTE: no .msi installer for 3.3.6 ("3.3", "64"): BASE_URL + "3.3.3/python-3.3.3.amd64.msi", ("3.3", "32"): BASE_URL + "3.3.3/python-3.3.3.msi", ("3.4", "64"): BASE_URL + "3.4.3/python-3.4.3.amd64.msi", ("3.4", "32"): BASE_URL + "3.4.3/python-3.4.3.msi", ("3.5", "64"): BASE_URL + "3.5.0/python-3.5.0-amd64.exe", ("3.5", "32"): BASE_URL + "3.5.0/python-3.5.0.exe", } INSTALL_CMD = { # Commands are allowed to fail only if they are not the last command. Eg: uninstall (/x) allowed to fail. "2.6": [["msiexec.exe", "/L*+!", "install.log", "/qn", "/x", "{path}"], ["msiexec.exe", "/L*+!", "install.log", "/qn", "/i", "{path}", "TARGETDIR={home}"]], "2.7": [["msiexec.exe", "/L*+!", "install.log", "/qn", "/x", "{path}"], ["msiexec.exe", "/L*+!", "install.log", "/qn", "/i", "{path}", "TARGETDIR={home}"]], "3.3": [["msiexec.exe", "/L*+!", "install.log", "/qn", "/x", "{path}"], ["msiexec.exe", "/L*+!", "install.log", "/qn", "/i", "{path}", "TARGETDIR={home}"]], "3.4": [["msiexec.exe", "/L*+!", "install.log", "/qn", "/x", "{path}"], ["msiexec.exe", "/L*+!", "install.log", "/qn", "/i", "{path}", "TARGETDIR={home}"]], "3.5": [["{path}", "/quiet", "TargetDir={home}"]], } def download_file(url, path): print("Downloading: {} (into {})".format(url, path)) progress = [0, 0] def report(count, size, total): progress[0] = count * size if progress[0] - progress[1] > 1000000: progress[1] = progress[0] print("Downloaded {:,}/{:,} ...".format(progress[1], total)) dest, _ = urlretrieve(url, path, reporthook=report) return dest def install_python(version, arch, home): print("Installing Python", version, "for", arch, "bit architecture to", home) if exists(home): return path = download_python(version, arch) print("Installing", path, "to", home) success = False for cmd in INSTALL_CMD[version]: cmd = [part.format(home=home, path=path) for part in cmd] print("Running:", " ".join(cmd)) try: check_call(cmd) except Exception as exc: print("Failed command", cmd, "with:", exc) if exists("install.log"): with open("install.log") as fh: print(fh.read()) else: success = True if success: print("Installation complete!") else: print("Installation failed") def download_python(version, arch): for _ in range(3): try: return download_file(URLS[version, arch], "installer.exe") except Exception as exc: print("Failed to download:", exc) print("Retrying ...") def install_pip(home): pip_path = home + "/Scripts/pip.exe" python_path = home + "/python.exe" if exists(pip_path): print("pip already installed.") else: print("Installing pip...") download_file(GET_PIP_URL, GET_PIP_PATH) print("Executing:", python_path, GET_PIP_PATH) check_call([python_path, GET_PIP_PATH]) def install_packages(home, *packages): cmd = [home + "/Scripts/pip.exe", "install"] cmd.extend(packages) check_call(cmd) if __name__ == "__main__": install_python(environ['PYTHON_VERSION'], environ['PYTHON_ARCH'], environ['PYTHON_HOME']) install_pip(environ['PYTHON_HOME']) install_packages(environ['PYTHON_HOME'], "setuptools>=18.0.1", "wheel", "tox", "virtualenv>=13.1.0") pytest-cython-0.1.0/ci/templates/0000775000175000017500000000000012704735065017170 5ustar loganlogan00000000000000pytest-cython-0.1.0/ci/templates/.travis.yml0000664000175000017500000000132612704714674021306 0ustar loganlogan00000000000000language: python python: '3.5' sudo: false env: global: - LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so - SEGFAULT_SIGNALS=all matrix: - TOXENV=check {% for env in tox_environments %}{{ '' }} - TOXENV={{ env }}{% if 'cover' in env %},coveralls{% endif -%} {% endfor %} before_install: - python --version - uname -a - lsb_release -a install: - pip install tox - virtualenv --version - easy_install --version - pip --version - tox --version script: - tox -v after_failure: - more .tox/log/* | cat - more .tox/*/log/* | cat before_cache: - rm -rf $HOME/.cache/pip/log cache: directories: - $HOME/.cache/pip notifications: email: on_success: never on_failure: always pytest-cython-0.1.0/ci/templates/appveyor.yml0000664000175000017500000000333112704714674021563 0ustar loganlogan00000000000000version: '{branch}-{build}' build: off cache: - '%LOCALAPPDATA%\pip\Cache' environment: global: WITH_COMPILER: 'cmd /E:ON /V:ON /C .\ci\appveyor-with-compiler.cmd' matrix: - TOXENV: check PYTHON_HOME: C:\Python27 PYTHON_VERSION: '2.7' PYTHON_ARCH: '32' {% for env in tox_environments %}{% if env.startswith(('py27', 'py34', 'py35')) %} - TOXENV: '{{ env }}{% if 'cover' in env %},codecov{% endif %}' TOXPYTHON: C:\Python{{ env[2:4] }}\python.exe PYTHON_HOME: C:\Python{{ env[2:4] }} PYTHON_VERSION: '{{ env[2] }}.{{ env[3] }}' PYTHON_ARCH: '32' - TOXENV: '{{ env }}{% if 'cover' in env %},codecov{% endif %}' TOXPYTHON: C:\Python{{ env[2:4] }}-x64\python.exe {%- if env.startswith(('py2', 'py33', 'py34')) %} WINDOWS_SDK_VERSION: v7.{{ '1' if env.startswith('py3') else '0' }} {%- endif %} PYTHON_HOME: C:\Python{{ env[2:4] }}-x64 PYTHON_VERSION: '{{ env[2] }}.{{ env[3] }}' PYTHON_ARCH: '64' {% endif %}{% endfor %} init: - ps: echo $env:TOXENV - ps: ls C:\Python* install: - python -u ci\appveyor-bootstrap.py - '%PYTHON_HOME%\Scripts\virtualenv --version' - '%PYTHON_HOME%\Scripts\easy_install --version' - '%PYTHON_HOME%\Scripts\pip --version' - '%PYTHON_HOME%\Scripts\tox --version' test_script: - '%WITH_COMPILER% %PYTHON_HOME%\Scripts\tox' on_failure: - ps: dir "env:" - ps: get-content .tox\*\log\* artifacts: - path: dist\* ### To enable remote debugging uncomment this (also, see: http://www.appveyor.com/docs/how-to/rdp-to-build-worker): # on_finish: # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) pytest-cython-0.1.0/ci/appveyor-with-compiler.cmd0000664000175000017500000000307612700257223022302 0ustar loganlogan00000000000000:: To build extensions for 64 bit Python 3, we need to configure environment :: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of: :: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1) :: :: To build extensions for 64 bit Python 2, we need to configure environment :: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of: :: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0) :: :: 32 bit builds do not require specific environment configurations. :: :: Note: this script needs to be run with the /E:ON and /V:ON flags for the :: cmd interpreter, at least for (SDK v7.0) :: :: More details at: :: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows :: http://stackoverflow.com/a/13751649/163740 :: :: Author: Olivier Grisel :: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/ SET COMMAND_TO_RUN=%* SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows SET WIN_WDK="c:\Program Files (x86)\Windows Kits\10\Include\wdf" ECHO SDK: %WINDOWS_SDK_VERSION% ARCH: %PYTHON_ARCH% IF "%PYTHON_VERSION%"=="3.5" ( IF EXIST %WIN_WDK% ( REM See: https://connect.microsoft.com/VisualStudio/feedback/details/1610302/ REN %WIN_WDK% 0wdf ) GOTO main ) IF "%PYTHON_ARCH%"=="32" ( GOTO main ) SET DISTUTILS_USE_SDK=1 SET MSSdk=1 "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION% CALL "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release :main ECHO Executing: %COMMAND_TO_RUN% CALL %COMMAND_TO_RUN% || EXIT 1 pytest-cython-0.1.0/ci/bootstrap.py0000664000175000017500000000351612704714674017571 0ustar loganlogan00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals import os import sys from os.path import exists from os.path import join from os.path import dirname from os.path import abspath if __name__ == "__main__": base_path = dirname(dirname(abspath(__file__))) print("Project path: {0}".format(base_path)) env_path = join(base_path, ".tox", "bootstrap") if sys.platform == "win32": bin_path = join(env_path, "Scripts") else: bin_path = join(env_path, "bin") if not exists(env_path): import subprocess print("Making bootstrap env in: {0} ...".format(env_path)) try: subprocess.check_call(["virtualenv", env_path]) except Exception: subprocess.check_call([sys.executable, "-m", "virtualenv", env_path]) print("Installing `jinja2` into bootstrap environment ...") subprocess.check_call([join(bin_path, "pip"), "install", "jinja2"]) activate = join(bin_path, "activate_this.py") exec(compile(open(activate, "rb").read(), activate, "exec"), dict(__file__=activate)) import jinja2 import subprocess jinja = jinja2.Environment( loader=jinja2.FileSystemLoader(join(base_path, "ci", "templates")), trim_blocks=True, lstrip_blocks=True, keep_trailing_newline=True ) tox_environments = [line.strip() for line in subprocess.check_output(['tox', '--listenvs']).splitlines()] tox_environments = [line for line in tox_environments if line not in ['clean', 'report', 'docs', 'check']] for name in os.listdir(join("ci", "templates")): with open(join(base_path, name), "w") as fh: fh.write(jinja.get_template(name).render(tox_environments=tox_environments)) print("Wrote {}".format(name)) print("DONE.") pytest-cython-0.1.0/tox.ini0000664000175000017500000000315512704725274016117 0ustar loganlogan00000000000000; a generative tox configuration, see: https://testrun.org/tox/latest/config.html#generative-envlist [tox] envlist = check, {py26,py27,py33,py34,py35}-{27,28,29}-{023,024}, {pypy}-{27,28,29}-{024}, docs [testenv] basepython = pypy: pypy py26: {env:TOXPYTHON:python2.6} {py27,docs}: {env:TOXPYTHON:python2.7} py33: {env:TOXPYTHON:python3.3} py34: {env:TOXPYTHON:python3.4} py35: {env:TOXPYTHON:python3.5} {clean,check,report,extension-coveralls,coveralls,spell}: python3.4 setenv = PYTHONPATH = {toxinidir}/tests PYTHONUNBUFFERED = yes passenv = * deps = virtualenv 27: pytest==2.7.3 28: pytest==2.8.7 29: pytest==2.9.1 020: cython==0.20.2 021: cython==0.21.2 022: cython==0.22.1 023: cython==0.23.5 024: cython==0.24 pip_pre = true commands = python tests/example-project/setup.py clean build_ext --inplace --use-cython {posargs:py.test -vv tests/test_pytest_cython.py} [testenv:spell] setenv = SPELLCHECK=1 commands = sphinx-build -b spelling docs dist/docs skip_install = true usedevelop = false deps = -r{toxinidir}/docs/requirements.txt sphinxcontrib-spelling pyenchant [testenv:docs] deps = -r{toxinidir}/docs/requirements.txt commands = sphinx-build {posargs:-E} -b html docs dist/docs sphinx-build -b linkcheck docs dist/docs [testenv:check] deps = docutils check-manifest flake8 readme-renderer pygments skip_install = true usedevelop = false commands = python setup.py check --strict --metadata --restructuredtext check-manifest {toxinidir} flake8 src tests setup.py pytest-cython-0.1.0/.coveragerc0000664000175000017500000000021512704714674016721 0ustar loganlogan00000000000000[paths] source = cython [run] branch = True parallel = true source = cython [report] precision = 2 show_missing = true omit = *migrations* pytest-cython-0.1.0/docs/0000775000175000017500000000000012704735065015527 5ustar loganlogan00000000000000pytest-cython-0.1.0/docs/contributing.rst0000664000175000017500000000004112700257223020752 0ustar loganlogan00000000000000.. include:: ../CONTRIBUTING.rst pytest-cython-0.1.0/docs/usage.rst0000664000175000017500000000011612700257223017352 0ustar loganlogan00000000000000===== Usage ===== To use pytest-cython in a project:: import pytest_cython pytest-cython-0.1.0/docs/changelog.rst0000664000175000017500000000003612700257223020176 0ustar loganlogan00000000000000.. include:: ../CHANGELOG.rst pytest-cython-0.1.0/docs/reference/0000775000175000017500000000000012704735065017465 5ustar loganlogan00000000000000pytest-cython-0.1.0/docs/reference/index.rst0000664000175000017500000000010112700257223021305 0ustar loganlogan00000000000000Reference ========= .. toctree:: :glob: pytest_cython* pytest-cython-0.1.0/docs/reference/pytest_cython.rst0000664000175000017500000000017212700311503023112 0ustar loganlogan00000000000000pytest_cython ============= .. testsetup:: from pytest_cython import * .. automodule:: pytest_cython :members: pytest-cython-0.1.0/docs/index.rst0000664000175000017500000000036512700257223017363 0ustar loganlogan00000000000000======== Contents ======== .. toctree:: :maxdepth: 2 readme installation usage reference/index contributing authors changelog Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` pytest-cython-0.1.0/docs/installation.rst0000664000175000017500000000013512700257223020750 0ustar loganlogan00000000000000============ Installation ============ At the command line:: pip install pytest-cython pytest-cython-0.1.0/docs/authors.rst0000664000175000017500000000003412700257223017732 0ustar loganlogan00000000000000.. include:: ../AUTHORS.rst pytest-cython-0.1.0/docs/readme.rst0000664000175000017500000000003312700257223017501 0ustar loganlogan00000000000000.. include:: ../README.rst pytest-cython-0.1.0/docs/conf.py0000664000175000017500000000256712700257223017027 0ustar loganlogan00000000000000# -*- coding: utf-8 -*- from __future__ import unicode_literals import os extensions = [ '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' master_doc = 'index' project = u'pytest-cython' year = '2016' author = u'Logan Page' copyright = '{0}, {1}'.format(year, author) version = release = u'0.1.0' pygments_style = 'trac' templates_path = ['.'] extlinks = { 'issue': ('https://github.com/lgpage/pytest-cython/issues/%s', '#'), 'pr': ('https://github.com/lgpage/pytest-cython/pull/%s', 'PR #'), } import sphinx_py3doc_enhanced_theme 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', 'globaltoc.html', 'sourcelink.html'], } html_short_title = '%s-%s' % (project, version) napoleon_use_ivar = True napoleon_use_rtype = False napoleon_use_param = False pytest-cython-0.1.0/docs/spelling_wordlist.txt0000664000175000017500000000015512700257223022024 0ustar loganlogan00000000000000builtin builtins classmethod staticmethod classmethods staticmethods args kwargs callstack Changelog Indices pytest-cython-0.1.0/docs/requirements.txt0000664000175000017500000000005612700257223021003 0ustar loganlogan00000000000000sphinx>=1.3 sphinx-py3doc-enhanced-theme -e . pytest-cython-0.1.0/LICENSE0000664000175000017500000000206512704714674015612 0ustar loganlogan00000000000000The 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. pytest-cython-0.1.0/tests/0000775000175000017500000000000012704735065015741 5ustar loganlogan00000000000000pytest-cython-0.1.0/tests/test_pytest_cython.py0000664000175000017500000000272012704714674022272 0ustar loganlogan00000000000000from __future__ import absolute_import import py import sys import pytest_cython.plugin PATH = py.path.local(__file__).dirpath() PATH = PATH.join('example-project', 'src', 'pypackage') sys.path.insert(0, str(PATH)) def test_cython_ext_module(testdir): module = PATH.listdir(fil='cython_ext_module*.so')[0] assert module.check() result = testdir.runpytest('-vv', '--doctest-cython', str(module)) result.stdout.fnmatch_lines([ "*Eggs.__init__ *PASSED", "*Eggs.blarg*PASSED", "*Eggs.fubar*PASSED", ]) assert result.ret == 0 def test_wrap_c_ext_module(testdir): module = PATH.listdir(fil='wrap_c_ext_module*.so')[0] assert module.check() result = testdir.runpytest('-vv', '--doctest-cython', str(module)) result.stdout.fnmatch_lines([ "*sqr*PASSED", ]) assert result.ret == 0 def test_wrap_cpp_ext_module(testdir): module = PATH.listdir(fil='wrap_cpp_ext_module*.so')[0] assert module.check() result = testdir.runpytest('-vv', '--doctest-cython', str(module)) result.stdout.fnmatch_lines([ "*sqr*PASSED", ]) assert result.ret == 0 def test_pure_py_module(testdir): module = PATH.listdir(fil='pure_py_module*.py')[0] assert module.check() result = testdir.runpytest('-vv', '--doctest-cython', str(module)) result.stdout.fnmatch_lines([ "*Eggs.__init__*PASSED", "*Eggs.foo*PASSED", "*foo*PASSED", ]) assert result.ret == 0 pytest-cython-0.1.0/tests/conftest.py0000664000175000017500000000003412704714674020140 0ustar loganlogan00000000000000pytest_plugins = "pytester" pytest-cython-0.1.0/tests/example-project/0000775000175000017500000000000012704735065021040 5ustar loganlogan00000000000000pytest-cython-0.1.0/tests/example-project/setup.py0000664000175000017500000000655612704714674022571 0ustar loganlogan00000000000000#!/usr/bin/env python # -*- encoding: utf-8 -*- from __future__ import absolute_import if __name__ == "__main__": import os import sys import glob from setuptools import setup from setuptools import Extension root = os.path.dirname(__file__) directives = { 'profile': True, 'embedsignature': True, 'linetrace': 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')]] try: sys.argv.remove("--use-cython") use_cython = True from Cython.Build import cythonize from Cython.Distutils import build_ext except ValueError: use_cython = False from distutils.command.build_ext import build_ext if 'clean' in sys.argv: [os.remove(x) for x in glob.glob(os.path.join(root, 'src/pypackage/*.c'))] [os.remove(x) for x in glob.glob(os.path.join(root, 'src/pypackage/*.so'))] [os.remove(x) for x in glob.glob(os.path.join(root, 'src/pypackage/*.cpp'))] if use_cython: ext_files = glob.glob(os.path.join(root, 'src/pypackage/*.pyx')) ext_files.extend(glob.glob(os.path.join(root, 'src/pypackage/*.py'))) else: ext_files = glob.glob(os.path.join(root, 'src/pypackage/*.c')) ext_files.extend(glob.glob(os.path.join(root, 'src/pypackage/*.cpp'))) extensions = [] exclude_files = ['__init__.py'] include_dirs = [os.path.abspath(os.path.join(root, 'src/clib'))] for file_ in ext_files: if os.path.basename(file_) in exclude_files: continue pyx_file, _ = os.path.splitext(file_) extensions.append(Extension( pyx_file, [file_], define_macros=macros, include_dirs=include_dirs, ) ) if use_cython: extensions = cythonize( extensions, force=True, compiler_directives=directives, ) class optional_build_ext(build_ext): """Allow the building of C extensions to fail.""" def run(self): try: build_ext.run(self) except Exception as e: self._unavailable(e) self.extensions = [] # avoid copying missing files (it would fail). def _unavailable(self, e): print('*' * 80) print('''WARNING: An optional code optimization (C extension) could not be compiled. Optimizations for this package will not be available! ''') print('CAUSE:') print('') print(' ' + repr(e)) print('*' * 80) setup( name='pytest-cython', version='0.1.0', description="Example Cython project for pytest-cython tests", zip_safe=False, cmdclass={'build_ext': optional_build_ext}, ext_modules=extensions, ) pytest-cython-0.1.0/tests/example-project/.gitignore0000664000175000017500000000010312704714674023025 0ustar loganlogan00000000000000 # Ignore Cython build files src/pypackage/*.c src/pypackage/*.cpp pytest-cython-0.1.0/tests/example-project/src/0000775000175000017500000000000012704735065021627 5ustar loganlogan00000000000000pytest-cython-0.1.0/tests/example-project/src/pypackage/0000775000175000017500000000000012704735065023573 5ustar loganlogan00000000000000pytest-cython-0.1.0/tests/example-project/src/pypackage/wrap_cpp_ext_module.pyx0000664000175000017500000000076212704714674030405 0ustar loganlogan00000000000000# 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.") pytest-cython-0.1.0/tests/example-project/src/pypackage/cython_ext_module.pyx0000664000175000017500000000244012704714674030071 0ustar loganlogan00000000000000 cdef int cfoo(int a, int b) except? -1: """ >>> cfoo(1, 1) 2 """ return a + b cdef int cbar(int a, int b) nogil except? -1: """ >>> cbar(1, 1) 2 """ return a + b cdef inline int cspam(int a, int b) nogil except? -1: """ >>> 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) nogil except? -1: """ >>> eggs = Eggs(1, 1) >>> eggs.bar() 2 """ return self.a + self.b cdef int spam(Eggs self) nogil except? -1: """ >>> 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 pytest-cython-0.1.0/tests/example-project/src/pypackage/__init__.py0000664000175000017500000000000012704714674025675 0ustar loganlogan00000000000000pytest-cython-0.1.0/tests/example-project/src/pypackage/pure_py_module.py0000664000175000017500000000062712704714674027205 0ustar loganlogan00000000000000 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 pytest-cython-0.1.0/tests/example-project/src/pypackage/cython_ext_module.pxd0000664000175000017500000000056712704714674030054 0ustar loganlogan00000000000000 cdef int cfoo(int a, int b) except? -1 cdef int cbar(int a, int b) nogil except? -1 cdef inline int cspam(int a, int b) nogil except? -1 cdef class Eggs: cdef: readonly int a readonly int b cdef int foo(Eggs self) except? -1 cdef int bar(Eggs self) nogil except? -1 cdef int spam(Eggs self) nogil except? -1 cpdef int fubar(Eggs self) pytest-cython-0.1.0/tests/example-project/src/pypackage/wrap_c_ext_module.pyx0000664000175000017500000000074012704714674030041 0ustar loganlogan00000000000000 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.") pytest-cython-0.1.0/tests/example-project/src/clib/0000775000175000017500000000000012704735065022540 5ustar loganlogan00000000000000pytest-cython-0.1.0/tests/example-project/src/clib/CMakeLists.txt0000664000175000017500000000021212704714674025276 0ustar loganlogan00000000000000 cmake_minimum_required(VERSION 2.8) project (cython_example_clib) add_library(sqrc SHARED sqrc.c) add_library(sqrcpp SHARED sqrcpp.cpp) pytest-cython-0.1.0/tests/example-project/src/clib/sqrcpp.cpp0000664000175000017500000000016012704714674024554 0ustar loganlogan00000000000000 template T vsqr(T a){ return (a * a); } template int vsqr(int); template double vsqr(double); pytest-cython-0.1.0/tests/example-project/src/clib/sqrc.c0000664000175000017500000000012612704714674023656 0ustar loganlogan00000000000000 int isqr(int a){ return (a * a); } double dsqr(double a){ return (a * a); } pytest-cython-0.1.0/PKG-INFO0000664000175000017500000000756712704735065015713 0ustar loganlogan00000000000000Metadata-Version: 1.1 Name: pytest-cython Version: 0.1.0 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 Description: Overview ======== This `Pytest`_ plugin allows for the doctesting of C extension modules for Python, specifically created through `Cython`_. Installation ============ You can install "pytest-cython" via `pip`_ from `PyPI`_:: pip install pytest-cython Usage ===== Basic usage:: py.test --doctest-cython Note ---- * It is assumed that the C extension modules have been build inplace before running `py.test` and there is a matching Cython `.pyx` file * The `embedsignature` `Cython compiler directive`_ must be set to `True` Contributing ============ Contributions are very welcome. Tests can be run with `tox`_:: tox License ======= * Free software: MIT license Distributed under the terms of the `MIT`_ license, "pytest-cython" is free and open source software Issues ====== If you encounter any problems, please `file an issue`_ along with a detailed description. Acknowledgements ================ This `Pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `Cookiecutter-pytest-plugin`_ and `@ionelmc`_'s `cookiecutter-pylibrary`_ templates. .. _`Cookiecutter`: https://github.com/audreyr/cookiecutter .. _`@hackebrot`: https://github.com/hackebrot .. _`@ionelmc`: https://github.com/ionelmc .. _`MIT`: http://opensource.org/licenses/MIT .. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause .. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt .. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0 .. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin .. _`cookiecutter-pylibrary`: https://github.com/ionelmc/cookiecutter-pylibrary .. _`file an issue`: https://github.com/lgpage/pytest-cython/issues .. _`pytest`: https://github.com/pytest-dev/pytest .. _`tox`: https://tox.readthedocs.org/en/latest/ .. _`pip`: https://pypi.python.org/pypi/pip/ .. _`PyPI`: https://pypi.python.org/pypi .. _`Cython`: http://cython.org/ .. _`Cython compiler directive`: http://docs.cython.org/src/reference/compilation.html#compiler-directives Changelog ========= 0.1.0 (2016-04-17) ----------------------------------------- * First release on PyPI. Keywords: pytest,py.test,cython,doctest Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: Unix Classifier: Operating System :: POSIX Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Utilities pytest-cython-0.1.0/.bumpversion.cfg0000664000175000017500000000026012700257223017674 0ustar loganlogan00000000000000[bumpversion] current_version = 0.1.0 commit = True tag = True [bumpversion:file:setup.py] [bumpversion:file:docs/conf.py] [bumpversion:file:src/pytest_cython/__init__.py] pytest-cython-0.1.0/setup.py0000664000175000017500000000513412704731510016303 0ustar loganlogan00000000000000#!/usr/bin/env python # -*- encoding: utf-8 -*- from __future__ import absolute_import from __future__ import print_function import io import re from glob import glob from os.path import basename from os.path import dirname from os.path import join from os.path import splitext from setuptools import find_packages from setuptools import setup def read(*names, **kwargs): return io.open( join(dirname(__file__), *names), encoding=kwargs.get('encoding', 'utf8') ).read() setup( name='pytest-cython', version='0.1.0', license='MIT', description='A plugin for testing Cython extension modules', long_description='%s\n%s' % ( re.compile('^.. start-badges.*^.. end-badges', re.M | re.S).sub('', read('README.rst')), re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst')) ), author='Logan Page', author_email='page.lg@gmail.com', url='https://github.com/lgpage/pytest-cython', packages=find_packages('src'), package_dir={'': 'src'}, py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')], include_package_data=True, zip_safe=False, classifiers=[ # complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: Unix', 'Operating System :: POSIX', # 'Operating System :: Microsoft :: Windows', 'Programming Language :: Python', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', # uncomment if you test on these interpreters: # 'Programming Language :: Python :: Implementation :: IronPython', # 'Programming Language :: Python :: Implementation :: Jython', # 'Programming Language :: Python :: Implementation :: Stackless', 'Topic :: Software Development :: Testing', 'Topic :: Utilities', ], keywords=[ 'pytest', 'py.test', 'cython', 'doctest', ], install_requires=[ 'pytest>=2.7.3', ], extras_require={ }, cmdclass={ }, entry_points={ 'pytest11': [ 'pytest_cython = pytest_cython.plugin', ], }, ) pytest-cython-0.1.0/.travis.yml0000664000175000017500000000262412704714674016717 0ustar loganlogan00000000000000language: python python: '3.5' sudo: false env: global: - LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so - SEGFAULT_SIGNALS=all matrix: - TOXENV=check - TOXENV=py26-27-023 - TOXENV=py26-27-024 - TOXENV=py26-28-023 - TOXENV=py26-28-024 - TOXENV=py26-29-023 - TOXENV=py26-29-024 - TOXENV=py27-27-023 - TOXENV=py27-27-024 - TOXENV=py27-28-023 - TOXENV=py27-28-024 - TOXENV=py27-29-023 - TOXENV=py27-29-024 - TOXENV=py33-27-023 - TOXENV=py33-27-024 - TOXENV=py33-28-023 - TOXENV=py33-28-024 - TOXENV=py33-29-023 - TOXENV=py33-29-024 - TOXENV=py34-27-023 - TOXENV=py34-27-024 - TOXENV=py34-28-023 - TOXENV=py34-28-024 - TOXENV=py34-29-023 - TOXENV=py34-29-024 - TOXENV=py35-27-023 - TOXENV=py35-27-024 - TOXENV=py35-28-023 - TOXENV=py35-28-024 - TOXENV=py35-29-023 - TOXENV=py35-29-024 - TOXENV=pypy-27-024 - TOXENV=pypy-28-024 - TOXENV=pypy-29-024 before_install: - python --version - uname -a - lsb_release -a install: - pip install tox - virtualenv --version - easy_install --version - pip --version - tox --version script: - tox -v after_failure: - more .tox/log/* | cat - more .tox/*/log/* | cat before_cache: - rm -rf $HOME/.cache/pip/log cache: directories: - $HOME/.cache/pip notifications: email: on_success: never on_failure: always pytest-cython-0.1.0/.editorconfig0000664000175000017500000000032712700315700017240 0ustar loganlogan00000000000000# 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 pytest-cython-0.1.0/appveyor.yml0000664000175000017500000001554312704714674017202 0ustar loganlogan00000000000000version: '{branch}-{build}' build: off cache: - '%LOCALAPPDATA%\pip\Cache' environment: global: WITH_COMPILER: 'cmd /E:ON /V:ON /C .\ci\appveyor-with-compiler.cmd' matrix: - TOXENV: check PYTHON_HOME: C:\Python27 PYTHON_VERSION: '2.7' PYTHON_ARCH: '32' - TOXENV: 'py27-27-023' TOXPYTHON: C:\Python27\python.exe PYTHON_HOME: C:\Python27 PYTHON_VERSION: '2.7' PYTHON_ARCH: '32' - TOXENV: 'py27-27-023' TOXPYTHON: C:\Python27-x64\python.exe WINDOWS_SDK_VERSION: v7.0 PYTHON_HOME: C:\Python27-x64 PYTHON_VERSION: '2.7' PYTHON_ARCH: '64' - TOXENV: 'py27-27-024' TOXPYTHON: C:\Python27\python.exe PYTHON_HOME: C:\Python27 PYTHON_VERSION: '2.7' PYTHON_ARCH: '32' - TOXENV: 'py27-27-024' TOXPYTHON: C:\Python27-x64\python.exe WINDOWS_SDK_VERSION: v7.0 PYTHON_HOME: C:\Python27-x64 PYTHON_VERSION: '2.7' PYTHON_ARCH: '64' - TOXENV: 'py27-28-023' TOXPYTHON: C:\Python27\python.exe PYTHON_HOME: C:\Python27 PYTHON_VERSION: '2.7' PYTHON_ARCH: '32' - TOXENV: 'py27-28-023' TOXPYTHON: C:\Python27-x64\python.exe WINDOWS_SDK_VERSION: v7.0 PYTHON_HOME: C:\Python27-x64 PYTHON_VERSION: '2.7' PYTHON_ARCH: '64' - TOXENV: 'py27-28-024' TOXPYTHON: C:\Python27\python.exe PYTHON_HOME: C:\Python27 PYTHON_VERSION: '2.7' PYTHON_ARCH: '32' - TOXENV: 'py27-28-024' TOXPYTHON: C:\Python27-x64\python.exe WINDOWS_SDK_VERSION: v7.0 PYTHON_HOME: C:\Python27-x64 PYTHON_VERSION: '2.7' PYTHON_ARCH: '64' - TOXENV: 'py27-29-023' TOXPYTHON: C:\Python27\python.exe PYTHON_HOME: C:\Python27 PYTHON_VERSION: '2.7' PYTHON_ARCH: '32' - TOXENV: 'py27-29-023' TOXPYTHON: C:\Python27-x64\python.exe WINDOWS_SDK_VERSION: v7.0 PYTHON_HOME: C:\Python27-x64 PYTHON_VERSION: '2.7' PYTHON_ARCH: '64' - TOXENV: 'py27-29-024' TOXPYTHON: C:\Python27\python.exe PYTHON_HOME: C:\Python27 PYTHON_VERSION: '2.7' PYTHON_ARCH: '32' - TOXENV: 'py27-29-024' TOXPYTHON: C:\Python27-x64\python.exe WINDOWS_SDK_VERSION: v7.0 PYTHON_HOME: C:\Python27-x64 PYTHON_VERSION: '2.7' PYTHON_ARCH: '64' - TOXENV: 'py34-27-023' TOXPYTHON: C:\Python34\python.exe PYTHON_HOME: C:\Python34 PYTHON_VERSION: '3.4' PYTHON_ARCH: '32' - TOXENV: 'py34-27-023' TOXPYTHON: C:\Python34-x64\python.exe WINDOWS_SDK_VERSION: v7.1 PYTHON_HOME: C:\Python34-x64 PYTHON_VERSION: '3.4' PYTHON_ARCH: '64' - TOXENV: 'py34-27-024' TOXPYTHON: C:\Python34\python.exe PYTHON_HOME: C:\Python34 PYTHON_VERSION: '3.4' PYTHON_ARCH: '32' - TOXENV: 'py34-27-024' TOXPYTHON: C:\Python34-x64\python.exe WINDOWS_SDK_VERSION: v7.1 PYTHON_HOME: C:\Python34-x64 PYTHON_VERSION: '3.4' PYTHON_ARCH: '64' - TOXENV: 'py34-28-023' TOXPYTHON: C:\Python34\python.exe PYTHON_HOME: C:\Python34 PYTHON_VERSION: '3.4' PYTHON_ARCH: '32' - TOXENV: 'py34-28-023' TOXPYTHON: C:\Python34-x64\python.exe WINDOWS_SDK_VERSION: v7.1 PYTHON_HOME: C:\Python34-x64 PYTHON_VERSION: '3.4' PYTHON_ARCH: '64' - TOXENV: 'py34-28-024' TOXPYTHON: C:\Python34\python.exe PYTHON_HOME: C:\Python34 PYTHON_VERSION: '3.4' PYTHON_ARCH: '32' - TOXENV: 'py34-28-024' TOXPYTHON: C:\Python34-x64\python.exe WINDOWS_SDK_VERSION: v7.1 PYTHON_HOME: C:\Python34-x64 PYTHON_VERSION: '3.4' PYTHON_ARCH: '64' - TOXENV: 'py34-29-023' TOXPYTHON: C:\Python34\python.exe PYTHON_HOME: C:\Python34 PYTHON_VERSION: '3.4' PYTHON_ARCH: '32' - TOXENV: 'py34-29-023' TOXPYTHON: C:\Python34-x64\python.exe WINDOWS_SDK_VERSION: v7.1 PYTHON_HOME: C:\Python34-x64 PYTHON_VERSION: '3.4' PYTHON_ARCH: '64' - TOXENV: 'py34-29-024' TOXPYTHON: C:\Python34\python.exe PYTHON_HOME: C:\Python34 PYTHON_VERSION: '3.4' PYTHON_ARCH: '32' - TOXENV: 'py34-29-024' TOXPYTHON: C:\Python34-x64\python.exe WINDOWS_SDK_VERSION: v7.1 PYTHON_HOME: C:\Python34-x64 PYTHON_VERSION: '3.4' PYTHON_ARCH: '64' - TOXENV: 'py35-27-023' TOXPYTHON: C:\Python35\python.exe PYTHON_HOME: C:\Python35 PYTHON_VERSION: '3.5' PYTHON_ARCH: '32' - TOXENV: 'py35-27-023' TOXPYTHON: C:\Python35-x64\python.exe PYTHON_HOME: C:\Python35-x64 PYTHON_VERSION: '3.5' PYTHON_ARCH: '64' - TOXENV: 'py35-27-024' TOXPYTHON: C:\Python35\python.exe PYTHON_HOME: C:\Python35 PYTHON_VERSION: '3.5' PYTHON_ARCH: '32' - TOXENV: 'py35-27-024' TOXPYTHON: C:\Python35-x64\python.exe PYTHON_HOME: C:\Python35-x64 PYTHON_VERSION: '3.5' PYTHON_ARCH: '64' - TOXENV: 'py35-28-023' TOXPYTHON: C:\Python35\python.exe PYTHON_HOME: C:\Python35 PYTHON_VERSION: '3.5' PYTHON_ARCH: '32' - TOXENV: 'py35-28-023' TOXPYTHON: C:\Python35-x64\python.exe PYTHON_HOME: C:\Python35-x64 PYTHON_VERSION: '3.5' PYTHON_ARCH: '64' - TOXENV: 'py35-28-024' TOXPYTHON: C:\Python35\python.exe PYTHON_HOME: C:\Python35 PYTHON_VERSION: '3.5' PYTHON_ARCH: '32' - TOXENV: 'py35-28-024' TOXPYTHON: C:\Python35-x64\python.exe PYTHON_HOME: C:\Python35-x64 PYTHON_VERSION: '3.5' PYTHON_ARCH: '64' - TOXENV: 'py35-29-023' TOXPYTHON: C:\Python35\python.exe PYTHON_HOME: C:\Python35 PYTHON_VERSION: '3.5' PYTHON_ARCH: '32' - TOXENV: 'py35-29-023' TOXPYTHON: C:\Python35-x64\python.exe PYTHON_HOME: C:\Python35-x64 PYTHON_VERSION: '3.5' PYTHON_ARCH: '64' - TOXENV: 'py35-29-024' TOXPYTHON: C:\Python35\python.exe PYTHON_HOME: C:\Python35 PYTHON_VERSION: '3.5' PYTHON_ARCH: '32' - TOXENV: 'py35-29-024' TOXPYTHON: C:\Python35-x64\python.exe PYTHON_HOME: C:\Python35-x64 PYTHON_VERSION: '3.5' PYTHON_ARCH: '64' init: - ps: echo $env:TOXENV - ps: ls C:\Python* install: - python -u ci\appveyor-bootstrap.py - '%PYTHON_HOME%\Scripts\virtualenv --version' - '%PYTHON_HOME%\Scripts\easy_install --version' - '%PYTHON_HOME%\Scripts\pip --version' - '%PYTHON_HOME%\Scripts\tox --version' test_script: - '%WITH_COMPILER% %PYTHON_HOME%\Scripts\tox' on_failure: - ps: dir "env:" - ps: get-content .tox\*\log\* artifacts: - path: dist\* ### To enable remote debugging uncomment this (also, see: http://www.appveyor.com/docs/how-to/rdp-to-build-worker): # on_finish: # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) pytest-cython-0.1.0/CONTRIBUTING.rst0000664000175000017500000000531612704714674017250 0ustar loganlogan00000000000000============ 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 `_ please include: * Your operating system name and version. * Any details about your local setup that might be helpful in troubleshooting. * Detailed steps to reproduce the bug. 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 at https://github.com/lgpage/pytest-cython/issues. If you are proposing a 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 `_ (look for the "Fork" button). 2. Clone your fork locally:: git clone git@github.com:your_name_here/pytest-cython.git 3. Create a branch for local development:: git checkout -b name-of-your-bugfix-or-feature Now you can make your changes locally. 4. When you're done making changes, run all the checks, doc builder and spell checker with `tox `_ one command:: tox 5. Commit your changes and push your branch to GitHub:: 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. For merging, you should: 1. Include passing tests (run ``tox``) [1]_. 2. Update documentation when there's new API, functionality etc. 3. Add a note to ``CHANGELOG.rst`` about the changes. 4. Add yourself to ``AUTHORS.rst``. .. [1] If you don't have all the necessary python versions available locally you can rely on Travis - it will `run the tests `_ for each change you add in the pull request. It will be slower though ... Tips ---- To run a subset of tests:: tox -e envname -- py.test -k test_myfeature To run all the test environments in *parallel* (you need to ``pip install detox``):: detox pytest-cython-0.1.0/MANIFEST.in0000664000175000017500000000107012704731711016325 0ustar loganlogan00000000000000graft docs graft examples graft cython graft ci graft tests include .bumpversion.cfg include .coveragerc include .cookiecutterrc include .editorconfig include .isort.cfg include AUTHORS.rst include CHANGELOG.rst include CONTRIBUTING.rst include LICENSE include README.rst include tox.ini .travis.yml appveyor.yml global-exclude *.py[cod] __pycache__ *.so *.dylib global-exclude tests/example-project/build global-exclude tests/example-project/build/* global-exclude tests/example-project/src/pypackage/*.c global-exclude tests/example-project/src/pypackage/*.cpp pytest-cython-0.1.0/src/0000775000175000017500000000000012704735065015366 5ustar loganlogan00000000000000pytest-cython-0.1.0/src/pytest_cython.egg-info/0000775000175000017500000000000012704735065021774 5ustar loganlogan00000000000000pytest-cython-0.1.0/src/pytest_cython.egg-info/SOURCES.txt0000664000175000017500000000272612704735065023667 0ustar loganlogan00000000000000.bumpversion.cfg .cookiecutterrc .coveragerc .editorconfig .travis.yml AUTHORS.rst CHANGELOG.rst CONTRIBUTING.rst LICENSE MANIFEST.in README.rst appveyor.yml setup.cfg setup.py tox.ini ci/appveyor-bootstrap.py ci/appveyor-download.py ci/appveyor-with-compiler.cmd ci/bootstrap.py ci/templates/.travis.yml ci/templates/appveyor.yml docs/authors.rst docs/changelog.rst docs/conf.py docs/contributing.rst docs/index.rst docs/installation.rst docs/readme.rst docs/requirements.txt docs/spelling_wordlist.txt docs/usage.rst docs/reference/index.rst docs/reference/pytest_cython.rst 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.pyxpytest-cython-0.1.0/src/pytest_cython.egg-info/requires.txt0000664000175000017500000000001612704735062024366 0ustar loganlogan00000000000000pytest>=2.7.3 pytest-cython-0.1.0/src/pytest_cython.egg-info/dependency_links.txt0000664000175000017500000000000112704735062026037 0ustar loganlogan00000000000000 pytest-cython-0.1.0/src/pytest_cython.egg-info/PKG-INFO0000664000175000017500000000756712704735062023105 0ustar loganlogan00000000000000Metadata-Version: 1.1 Name: pytest-cython Version: 0.1.0 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 Description: Overview ======== This `Pytest`_ plugin allows for the doctesting of C extension modules for Python, specifically created through `Cython`_. Installation ============ You can install "pytest-cython" via `pip`_ from `PyPI`_:: pip install pytest-cython Usage ===== Basic usage:: py.test --doctest-cython Note ---- * It is assumed that the C extension modules have been build inplace before running `py.test` and there is a matching Cython `.pyx` file * The `embedsignature` `Cython compiler directive`_ must be set to `True` Contributing ============ Contributions are very welcome. Tests can be run with `tox`_:: tox License ======= * Free software: MIT license Distributed under the terms of the `MIT`_ license, "pytest-cython" is free and open source software Issues ====== If you encounter any problems, please `file an issue`_ along with a detailed description. Acknowledgements ================ This `Pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `Cookiecutter-pytest-plugin`_ and `@ionelmc`_'s `cookiecutter-pylibrary`_ templates. .. _`Cookiecutter`: https://github.com/audreyr/cookiecutter .. _`@hackebrot`: https://github.com/hackebrot .. _`@ionelmc`: https://github.com/ionelmc .. _`MIT`: http://opensource.org/licenses/MIT .. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause .. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt .. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0 .. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin .. _`cookiecutter-pylibrary`: https://github.com/ionelmc/cookiecutter-pylibrary .. _`file an issue`: https://github.com/lgpage/pytest-cython/issues .. _`pytest`: https://github.com/pytest-dev/pytest .. _`tox`: https://tox.readthedocs.org/en/latest/ .. _`pip`: https://pypi.python.org/pypi/pip/ .. _`PyPI`: https://pypi.python.org/pypi .. _`Cython`: http://cython.org/ .. _`Cython compiler directive`: http://docs.cython.org/src/reference/compilation.html#compiler-directives Changelog ========= 0.1.0 (2016-04-17) ----------------------------------------- * First release on PyPI. Keywords: pytest,py.test,cython,doctest Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: Unix Classifier: Operating System :: POSIX Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Utilities pytest-cython-0.1.0/src/pytest_cython.egg-info/entry_points.txt0000664000175000017500000000006112704735062025264 0ustar loganlogan00000000000000[pytest11] pytest_cython = pytest_cython.plugin pytest-cython-0.1.0/src/pytest_cython.egg-info/top_level.txt0000664000175000017500000000001612704735062024520 0ustar loganlogan00000000000000pytest_cython pytest-cython-0.1.0/src/pytest_cython.egg-info/not-zip-safe0000664000175000017500000000000112704243663024220 0ustar loganlogan00000000000000 pytest-cython-0.1.0/src/pytest_cython/0000775000175000017500000000000012704735065020302 5ustar loganlogan00000000000000pytest-cython-0.1.0/src/pytest_cython/plugin.py0000664000175000017500000001176312704714674022165 0ustar loganlogan00000000000000""" discover and run doctests in Cython extension modules.""" from __future__ import absolute_import import sys import pytest try: import sysconfig except ImportError: from distutils import sysconfig import _pytest from _pytest.doctest import get_optionflags from _pytest.doctest import DoctestItem try: from _pytest.doctest import _get_checker except ImportError: _get_checker = None def pytest_addoption(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", ) group.addoption( "--cython-ignore-import-errors", action="store_true", default=False, help="ignore doctest ImportErrors", dest="doctest_ignore_import_errors", ) def _find_matching_pyx_file(path, extensions): for ext in extensions: newpath = path.new(ext=ext) if newpath.check(): return newpath def pytest_collect_file(path, parent): bin_exts = ['.so'] cy_exts = ['.pyx', '.py'] # collect .so files if .py file exists ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") config = parent.config if path.ext in bin_exts: if config.getoption('--doctest-cython'): if ext_suffix is None: bin_file = path # XXX EXT_SUFFIX is None for pypy (python2.7) if '.pypy' in path.basename: basename = path.basename.split('.')[0] bin_file = path.new(purebasename=basename, ext=path.ext) else: basename = path.basename.replace(ext_suffix, "") bin_file = path.new(purebasename=basename, ext=path.ext) pyx_file = _find_matching_pyx_file(bin_file, cy_exts) # only run test if matching .so and .pyx files exist # create addoption for this ?? if pyx_file is not None: return DoctestModule(path, parent) # XXX patch pyimport to support PEP 3149 def _patch_pyimport(fspath, **kwargs): ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") # XXX EXT_SUFFIX is None for pypy (python2.7) if ext_suffix is None and '.pypy' not in fspath.basename: return fspath.pyimport(**kwargs) else: # XXX EXT_SUFFIX is None for pypy (python2.7) if '.pypy' in fspath.basename: ext_suffix = fspath.ext basename = fspath.basename.split('.')[0] fspath = fspath.new(purebasename=basename, ext=fspath.ext) pkgroot = fspath.dirpath() fspath._ensuresyspath(True, pkgroot) names = fspath.relto(pkgroot).split(fspath.sep) modname = ".".join(names).replace(ext_suffix, "") __import__(modname) return sys.modules[modname] class DoctestModule(pytest.Module): def collect(self): import doctest if self.fspath.basename == "conftest.py": module = self.config.pluginmanager._importconftest(self.fspath) else: try: # XXX patch pyimport in pytest._pytest.doctest.DoctestModule module = _patch_pyimport(self.fspath) except ImportError: if self.config.getoption('--cython-ignore-import-errors'): pytest.skip('unable to import module %r' % self.fspath) else: raise # uses internal doctest module parsing mechanism finder = doctest.DocTestFinder() optionflags = get_optionflags(self) checker = None if _get_checker is None else _get_checker() runner = doctest.DebugRunner(verbose=0, optionflags=optionflags, checker=checker) for test in finder.find(module, module.__name__): if test.examples: # skip empty doctests yield DoctestItem(test.name, self, runner, test) def _importtestmodule(self): # we assume we are only called once per module importmode = self.config.getoption("--import-mode", default=True) try: # XXX patch pyimport in pytest._pytest.pythod.Module mod = _patch_pyimport(self.fspath, ensuresyspath=importmode) except SyntaxError: raise self.CollectError( _pytest._code.ExceptionInfo().getrepr(style="short")) except self.fspath.ImportMismatchError: e = sys.exc_info()[1] raise self.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" % e.args ) # print "imported test module", mod self.config.pluginmanager.consider_module(mod) return mod pytest-cython-0.1.0/src/pytest_cython/__init__.py0000664000175000017500000000002612700517731022403 0ustar loganlogan00000000000000__version__ = "0.1.0" pytest-cython-0.1.0/CHANGELOG.rst0000664000175000017500000000015512704734621016616 0ustar loganlogan00000000000000 Changelog ========= 0.1.0 (2016-04-17) ----------------------------------------- * First release on PyPI. pytest-cython-0.1.0/.cookiecutterrc0000664000175000017500000000354112704731510017617 0ustar loganlogan00000000000000# This file exists so you can easily regenerate your project. # # `cookiepatcher` is a convenient shim around `cookiecutter` # for regenerating projects (it will generate a .cookiecutterrc # automatically for any template). To use it: # # pip install cookiepatcher # cookiepatcher gh:ionelmc/cookiecutter-pylibrary project-path # # See: # https://pypi.python.org/pypi/cookiecutter # # Alternatively, you can run: # # cookiecutter --overwrite-if-exists --config-file=project-path/.cookiecutterrc gh:ionelmc/cookiecutter-pylibrary default_context: appveyor: 'yes' c_extension_cython: 'no' c_extension_optional: 'no' c_extension_support: 'no' codacy: 'no' codeclimate: 'no' codecov: 'no' command_line_interface: 'no' command_line_interface_bin_name: 'pytest-cython' coveralls: 'no' distribution_name: 'pytest-cython' email: 'page.lg@gmail.com' full_name: 'Logan Page' github_username: 'lgpage' landscape: 'no' package_name: 'pytest_cython' project_name: 'pytest-cython' project_short_description: 'A plugin for testing Cython extension modules' release_date: 'today' repo_name: 'pytest-cython' requiresio: 'yes' scrutinizer: 'no' sphinx_doctest: 'no' sphinx_theme: 'sphinx-py3doc-enhanced-theme' test_matrix_configurator: 'yes' test_matrix_separate_coverage: 'no' test_runner: 'pytest' travis: 'yes' version: '0.1.0' website: 'https://github.com/lgpage/pytest-cython' year: 'now' pytest-cython-0.1.0/README.rst0000664000175000017500000000765112704731510016266 0ustar loganlogan00000000000000Overview ======== .. start-badges .. list-table:: :stub-columns: 1 * - docs - |docs| * - tests - |travis| |appveyor| |requires| * - package - |version| |downloads| |wheel| |supported-versions| |supported-implementations| .. |docs| image:: https://readthedocs.org/projects/pytest-cython/badge/?style=flat :target: https://readthedocs.org/projects/pytest-cython :alt: Documentation Status .. |travis| image:: https://travis-ci.org/lgpage/pytest-cython.svg?branch=master :alt: Travis-CI Build Status :target: https://travis-ci.org/lgpage/pytest-cython .. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/lgpage/pytest-cython?branch=master&svg=true :alt: AppVeyor Build Status :target: https://ci.appveyor.com/project/lgpage/pytest-cython .. |requires| image:: https://requires.io/github/lgpage/pytest-cython/requirements.svg?branch=master :alt: Requirements Status :target: https://requires.io/github/lgpage/pytest-cython/requirements/?branch=master .. |version| image:: https://img.shields.io/pypi/v/pytest-cython.svg?style=flat :alt: PyPI Package latest release :target: https://pypi.python.org/pypi/pytest-cython .. |downloads| image:: https://img.shields.io/pypi/dm/pytest-cython.svg?style=flat :alt: PyPI Package monthly downloads :target: https://pypi.python.org/pypi/pytest-cython .. |wheel| image:: https://img.shields.io/pypi/wheel/pytest-cython.svg?style=flat :alt: PyPI Wheel :target: https://pypi.python.org/pypi/pytest-cython .. |supported-versions| image:: https://img.shields.io/pypi/pyversions/pytest-cython.svg?style=flat :alt: Supported versions :target: https://pypi.python.org/pypi/pytest-cython .. |supported-implementations| image:: https://img.shields.io/pypi/implementation/pytest-cython.svg?style=flat :alt: Supported implementations :target: https://pypi.python.org/pypi/pytest-cython .. end-badges This `Pytest`_ plugin allows for the doctesting of C extension modules for Python, specifically created through `Cython`_. Installation ============ You can install "pytest-cython" via `pip`_ from `PyPI`_:: pip install pytest-cython Usage ===== Basic usage:: py.test --doctest-cython Note ---- * It is assumed that the C extension modules have been build inplace before running `py.test` and there is a matching Cython `.pyx` file * The `embedsignature` `Cython compiler directive`_ must be set to `True` Contributing ============ Contributions are very welcome. Tests can be run with `tox`_:: tox License ======= * Free software: MIT license Distributed under the terms of the `MIT`_ license, "pytest-cython" is free and open source software Issues ====== If you encounter any problems, please `file an issue`_ along with a detailed description. Acknowledgements ================ This `Pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `Cookiecutter-pytest-plugin`_ and `@ionelmc`_'s `cookiecutter-pylibrary`_ templates. .. _`Cookiecutter`: https://github.com/audreyr/cookiecutter .. _`@hackebrot`: https://github.com/hackebrot .. _`@ionelmc`: https://github.com/ionelmc .. _`MIT`: http://opensource.org/licenses/MIT .. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause .. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt .. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0 .. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin .. _`cookiecutter-pylibrary`: https://github.com/ionelmc/cookiecutter-pylibrary .. _`file an issue`: https://github.com/lgpage/pytest-cython/issues .. _`pytest`: https://github.com/pytest-dev/pytest .. _`tox`: https://tox.readthedocs.org/en/latest/ .. _`pip`: https://pypi.python.org/pypi/pip/ .. _`PyPI`: https://pypi.python.org/pypi .. _`Cython`: http://cython.org/ .. _`Cython compiler directive`: http://docs.cython.org/src/reference/compilation.html#compiler-directives