From eaf68c1ffdc37216004470a6137b74c5b98ad03a Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 18 Nov 2010 15:31:58 +0100 Subject: [PATCH] better deal with importing conftest.py with --doctest-modules and re-enable default of "--doctest-modules" even if issued at root level --- _pytest/doctest.py | 5 ++++- tox.ini | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/_pytest/doctest.py b/_pytest/doctest.py index c8417c521..c21c82b1c 100644 --- a/_pytest/doctest.py +++ b/_pytest/doctest.py @@ -73,7 +73,10 @@ class DoctestTextfile(DoctestItem, pytest.File): 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) diff --git a/tox.ini b/tox.ini index b0e4a0383..37bac7162 100644 --- 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