summarylogtreecommitdiffstats
path: root/43f3d148738f77f8579caae49f74f8d548d3f0a9.patch
blob: b6ffb242d8ee7abe0aed94b85b626d02919de906 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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