[svn r56285] sanitize doctesting a bit. this also fixes the problem that you could not have "import" working in doctests previously. thanks nshepperd.

--HG--
branch : trunk
This commit is contained in:
hpk
2008-07-04 09:14:36 +02:00
parent cb53ad6010
commit d4c3b3ce85
4 changed files with 35 additions and 43 deletions

View File

@@ -502,13 +502,17 @@ class Generator(FunctionMixin, PyCollectorMixin, Collector):
call, args = obj, ()
return call, args
class DoctestFile(PyCollectorMixin, FSCollector):
class DoctestFile(Module):
# XXX fix py.test reporting
# we subclass Module here in order to get py.test's reporting
# show the ".txt" filename in the test run much like a
# python module shows up. instead py.test needs to
# support more direct means of influencing reporting.
def run(self):
return [self.fspath.basename]
def join(self, name):
from py.__.test.doctest import DoctestText
if name == self.fspath.basename:
item = DoctestText(self.fspath.basename, parent=self)
item._content = self.fspath.read()
return item
if name == self.fspath.basename:
from py.__.test.doctest import DoctestFileContent
return DoctestFileContent(name, self)