[py-svn] pytest commit c359bd19375e: better deal with importing conftest.py with --doctest-modules and

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Nov 18 15:32:22 CET 2010


# HG changeset patch -- Bitbucket.org
# Project pytest
# URL http://bitbucket.org/hpk42/pytest/overview
# User holger krekel <holger at merlinux.eu>
# Date 1290090718 -3600
# Node ID c359bd19375e6ce32534799d1981e9a59da627b2
# Parent  1e1073e89e9fdaf7e317f887528d075401ad5f87
better deal with importing conftest.py with --doctest-modules and
re-enable default of "--doctest-modules" even if issued at root level

--- a/_pytest/doctest.py
+++ b/_pytest/doctest.py
@@ -73,7 +73,10 @@ class DoctestTextfile(DoctestItem, pytes
 class DoctestModule(DoctestItem, pytest.File):
     def runtest(self):
         doctest = py.std.doctest
-        module = self.fspath.pyimport()
+        if self.fspath.basename == "conftest.py":
+            module = self.config._conftest.importconftest(self.fspath)
+        else:
+            module = self.fspath.pyimport()
         failed, tot = doctest.testmod(
             module, raise_on_error=True, verbose=0,
             optionflags=doctest.ELLIPSIS)

--- a/tox.ini
+++ b/tox.ini
@@ -18,6 +18,7 @@ commands= py.test --genscript=pytest1
 deps=pylib
 
 [testenv:py27-xdist]
+changedir=.
 basepython=python2.7
 deps=pytest-xdist
 commands=
@@ -63,6 +64,6 @@ commands=
 [pytest]
 minversion=2.0
 plugins=pytester
-addopts= -rxf --pyargs
+addopts= -rxf --pyargs --doctest-modules
 rsyncdirs=tox.ini pytest.py _pytest testing



More information about the pytest-commit mailing list