Repository: lgpage/pytest-cython

Issue:
Depreciation warnings
Running `pytest --doctest-cython` works, but gives the following warnings
```
<some_path>/python3.7/site-packages/pytest_cython/plugin.py:70
  <some_path>/python3.7/site-packages/pytest_cython/plugin.py:70: PytestDeprecationWarning: direct construction of DoctestModule has been deprecated, please use DoctestModule.from_parent
    return DoctestModule(path, parent)

<some_path>/.local/lib/python3.7/site-packages/pytest_cython/plugin.py:120
<some_path>/.local/lib/python3.7/site-packages/pytest_cython/plugin.py:120
  <some_path>/.local/lib/python3.7/site-packages/pytest_cython/plugin.py:120: PytestDeprecationWarning: direct construction of DoctestItem has been deprecated, please use DoctestItem.from_parent
    yield DoctestItem(test.name, self, runner, test)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
```

## A Quick Workaround
```bash
pytest --doctest-cython --disable-warnings
```

# Info
* OS: Fedora 31 (Thirty One) x86_64
* Sample `fib.pyx`

```python3
#cython: language_level=3

def fib(int n):
    '''Return the nth number in the Fibonacci sequence.

    >>> fib(0)
    0.0
    >>> fib(1)
    1.0
    >>> fib(4)
    3.0
    >>> fib(7)
    13.0
    '''
    cdef int i
    cdef double a=0.0, b=1.0
    for i in range(n):
        a, b = a + b, a
    return a
```


Comments:

Patch:
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


Test patch:
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, fs_path=path)
 
 
 # XXX patch pyimport to support PEP 3149
@@ -117,7 +117,7 @@ class DoctestModule(pytest.Module):
                                      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 @@ if __name__ == "__main__":
     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