summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel2020-12-18 21:57:59 -0500
committerGuillaume Horel2020-12-18 21:57:59 -0500
commit1e1bd64a1c61d54c49814615f48088ad66e61148 (patch)
treeb552ded5e3262b6f144d5339a27609ea977908f1
parent8d7c14649ffa77fa3a561ea03846a60362ac9978 (diff)
downloadaur-1e1bd64a1c61d54c49814615f48088ad66e61148.tar.gz
fix tests
-rw-r--r--43f3d148738f77f8579caae49f74f8d548d3f0a9.patch122
-rw-r--r--PKGBUILD31
2 files changed, 143 insertions, 10 deletions
diff --git a/43f3d148738f77f8579caae49f74f8d548d3f0a9.patch b/43f3d148738f77f8579caae49f74f8d548d3f0a9.patch
new file mode 100644
index 00000000000..b6ffb242d8e
--- /dev/null
+++ b/43f3d148738f77f8579caae49f74f8d548d3f0a9.patch
@@ -0,0 +1,122 @@
+From 43f3d148738f77f8579caae49f74f8d548d3f0a9 Mon Sep 17 00:00:00 2001
+From: Thrasibule <thrasibule@users.noreply.github.com>
+Date: Tue, 29 Sep 2020 12:08:20 -0400
+Subject: [PATCH] Fix DoctestModule construction warning
+
+* use from_parent constructor
+* fix cython example project
+* make tests pass
+---
+ setup.cfg | 2 +-
+ src/pytest_cython/plugin.py | 4 ++--
+ tests/example-project/setup.py | 7 ++++---
+ tests/example-project/src/__init__.py | 0
+ tests/test_pytest_cython.py | 16 ++++++++--------
+ 5 files changed, 15 insertions(+), 14 deletions(-)
+ create mode 100644 tests/example-project/src/__init__.py
+
+diff --git a/setup.cfg b/setup.cfg
+index a5f7bb1..1b8c2c3 100644
+--- a/setup.cfg
++++ b/setup.cfg
+@@ -8,7 +8,7 @@ release = register clean --all sdist bdist_wheel
+ max-line-length = 140
+ exclude = tests/*,*/migrations/*,*/south_migrations/*
+
+-[pytest]
++[tool:pytest]
+ norecursedirs =
+ .git
+ .tox
+diff --git a/src/pytest_cython/plugin.py b/src/pytest_cython/plugin.py
+index d4874cd..5c610e4 100644
+--- a/src/pytest_cython/plugin.py
++++ b/src/pytest_cython/plugin.py
+@@ -67,7 +67,7 @@ def pytest_collect_file(path, parent):
+ # only run test if matching .so and .pyx files exist
+ # create addoption for this ??
+ if pyx_file is not None:
+- return DoctestModule(path, parent)
++ return DoctestModule.from_parent(parent, fspath=path)
+
+
+ # XXX patch pyimport to support PEP 3149
+@@ -117,7 +117,7 @@ def collect(self):
+ checker=checker)
+ for test in finder.find(module, module.__name__):
+ if test.examples: # skip empty doctests
+- yield DoctestItem(test.name, self, runner, test)
++ yield DoctestItem.from_parent(self, name=test.name, runner=runner, dtest=test)
+
+ def _importtestmodule(self):
+ # we assume we are only called once per module
+diff --git a/tests/example-project/setup.py b/tests/example-project/setup.py
+index fca0567..e690383 100644
+--- a/tests/example-project/setup.py
++++ b/tests/example-project/setup.py
+@@ -55,11 +55,12 @@
+ 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:
++ basename = os.path.basename(file_)
++ if basename in exclude_files:
+ continue
+- pyx_file, _ = os.path.splitext(file_)
++ pyx_file, _ = os.path.splitext(basename)
+ extensions.append(Extension(
+- pyx_file,
++ 'src.pypackage.' + pyx_file,
+ [file_],
+ define_macros=macros,
+ include_dirs=include_dirs,
+diff --git a/tests/example-project/src/__init__.py b/tests/example-project/src/__init__.py
+new file mode 100644
+index 0000000..e69de29
+diff --git a/tests/test_pytest_cython.py b/tests/test_pytest_cython.py
+index 55a66bf..e546fe3 100644
+--- a/tests/test_pytest_cython.py
++++ b/tests/test_pytest_cython.py
+@@ -15,9 +15,9 @@ def test_cython_ext_module(testdir):
+ assert module.check()
+ result = testdir.runpytest('-vv', '--doctest-cython', str(module))
+ result.stdout.fnmatch_lines([
+- "*Eggs.__init__ *PASSED",
+- "*Eggs.blarg*PASSED",
+- "*Eggs.fubar*PASSED",
++ "*Eggs.__init__ *PASSED*",
++ "*Eggs.blarg*PASSED*",
++ "*Eggs.fubar*PASSED*",
+ ])
+ assert result.ret == 0
+
+@@ -27,7 +27,7 @@ def test_wrap_c_ext_module(testdir):
+ assert module.check()
+ result = testdir.runpytest('-vv', '--doctest-cython', str(module))
+ result.stdout.fnmatch_lines([
+- "*sqr*PASSED",
++ "*sqr*PASSED*",
+ ])
+ assert result.ret == 0
+
+@@ -37,7 +37,7 @@ def test_wrap_cpp_ext_module(testdir):
+ assert module.check()
+ result = testdir.runpytest('-vv', '--doctest-cython', str(module))
+ result.stdout.fnmatch_lines([
+- "*sqr*PASSED",
++ "*sqr*PASSED*",
+ ])
+ assert result.ret == 0
+
+@@ -47,8 +47,8 @@ def test_pure_py_module(testdir):
+ assert module.check()
+ result = testdir.runpytest('-vv', '--doctest-cython', str(module))
+ result.stdout.fnmatch_lines([
+- "*Eggs.__init__*PASSED",
+- "*Eggs.foo*PASSED",
+- "*foo*PASSED",
++ "*Eggs.__init__*PASSED*",
++ "*Eggs.foo*PASSED*",
++ "*foo*PASSED*",
+ ])
+ assert result.ret == 0
diff --git a/PKGBUILD b/PKGBUILD
index c2efaf26b13..e3012da8bff 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -2,24 +2,35 @@
pkgname='python-pytest-cython'
_pkgname='pytest-cython'
pkgver='0.1.0'
-pkgrel=1
+pkgrel=2
pkgdesc="A plugin for testing Cython extension modules."
url="https://github.com/lgpage/pytest-cython"
-checkdepends=('python-pytest')
-depends=('python')
+checkdepends=('cython' 'python-pytest')
+depends=()
makedepends=('python-setuptools')
optdepends=()
license=('MIT')
arch=('any')
-source=("https://pypi.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
-sha256sums=('90fa7e4e619bababeb433d3ba173a80d20473cce0bf3dce2c0e6f298becf5998')
+source=("https://pypi.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
+ "43f3d148738f77f8579caae49f74f8d548d3f0a9.patch")
+sha256sums=('90fa7e4e619bababeb433d3ba173a80d20473cce0bf3dce2c0e6f298becf5998'
+ '0db1f2b6cd2b909fd0214d14a267a9342a74575ff3aa81ea51d3d997b8e11a61')
+
+prepare() {
+ cd "${_pkgname}-${pkgver}"
+ patch -l -p1 -i ../43f3d148738f77f8579caae49f74f8d548d3f0a9.patch
+}
package() {
- cd "${srcdir}/${_pkgname}-${pkgver}"
+ cd "${_pkgname}-${pkgver}"
python setup.py install --root="${pkgdir}" --optimize=1
}
-#check() {
- #cd "$srcdir/$_pkgname-${pkgver}"
- #python setup.py test
-#}
+check() {
+ cd "$_pkgname-${pkgver}/tests"
+ pushd example-project > /dev/null
+ python setup.py build_ext --inplace --use-cython
+ popd > /dev/null
+ cd ..
+ PY_IGNORE_IMPORTMISMATCH=1 PYTHONPATH=src pytest
+}