[py-svn] r63461 - py/trunk/py/test/plugin
hpk at codespeak.net
hpk at codespeak.net
Tue Mar 31 19:58:02 CEST 2009
Author: hpk
Date: Tue Mar 31 19:58:02 2009
New Revision: 63461
Modified:
py/trunk/py/test/plugin/pytest_default.py
py/trunk/py/test/plugin/pytest_doctest.py
py/trunk/py/test/plugin/pytest_figleaf.py
py/trunk/py/test/plugin/pytest_plugintester.py
py/trunk/py/test/plugin/pytest_pytester.py
py/trunk/py/test/plugin/pytest_terminal.py
Log:
a few fixes, now figleaf writes files correctly.
also changed figleaf plugin to include only
the files of the current working dir.
Modified: py/trunk/py/test/plugin/pytest_default.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_default.py (original)
+++ py/trunk/py/test/plugin/pytest_default.py Tue Mar 31 19:58:02 2009
@@ -5,7 +5,6 @@
def pytest_pyfunc_call(self, pyfuncitem, args, kwargs):
pyfuncitem.obj(*args, **kwargs)
- return
def pytest_collect_file(self, path, parent):
ext = path.ext
Modified: py/trunk/py/test/plugin/pytest_doctest.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_doctest.py (original)
+++ py/trunk/py/test/plugin/pytest_doctest.py Tue Mar 31 19:58:02 2009
@@ -2,7 +2,8 @@
class DoctestPlugin:
def pytest_addoption(self, parser):
- parser.addoption("--doctest-modules",
+ group = parser.addgroup("doctest options")
+ group.addoption("--doctest-modules",
action="store_true", default=False,
dest="doctestmodules")
Modified: py/trunk/py/test/plugin/pytest_figleaf.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_figleaf.py (original)
+++ py/trunk/py/test/plugin/pytest_figleaf.py Tue Mar 31 19:58:02 2009
@@ -5,7 +5,8 @@
group = parser.addgroup('figleaf options')
group.addoption('-F', action='store_true', default=False,
dest = 'figleaf',
- help='trace coverage with figleaf and write HTML')
+ help=('trace coverage with figleaf and write HTML '
+ 'for files below the current working dir'))
group.addoption('--figleaf-data', action='store', default='.figleaf',
dest='figleafdata',
help='path coverage tracing file.')
@@ -25,32 +26,31 @@
def pytest_terminal_summary(self, terminalreporter):
if hasattr(self, 'figleaf'):
- datafile = terminalreporter.config.getvalue('figleafdata')
- datafile = py.path.local(datafile)
+ config = terminalreporter.config
+ datafile = py.path.local(config.getvalue('figleafdata'))
tw = terminalreporter._tw
tw.sep('-', 'figleaf')
tw.line('Writing figleaf data to %s' % (datafile))
self.figleaf.stop()
self.figleaf.write_coverage(str(datafile))
- coverage = self.get_coverage(datafile,
- terminalreporter.config.topdir)
+ coverage = self.get_coverage(datafile, config)
- reportdir = terminalreporter.config.getvalue('figleafhtml')
- reportdir = py.path.local(reportdir)
+ reportdir = py.path.local(config.getvalue('figleafhtml'))
tw.line('Writing figleaf html to file://%s' % (reportdir))
self.figleaf.annotate_html.prepare_reportdir(str(reportdir))
exclude = []
self.figleaf.annotate_html.report_as_html(coverage,
str(reportdir), exclude, {})
- def get_coverage(self, datafile, topdir):
+ def get_coverage(self, datafile, config):
+ # basepath = config.topdir
+ basepath = py.path.local()
data = self.figleaf.read_coverage(str(datafile))
d = {}
coverage = self.figleaf.combine_coverage(d, data)
for path in coverage.keys():
- if not py.path.local(path).relto(topdir):
+ if not py.path.local(path).relto(basepath):
del coverage[path]
-
return coverage
@@ -71,4 +71,4 @@
assert result.stdout.fnmatch_lines([
'*figleaf html*'
])
- print result.stdout.str()
+ #print result.stdout.str()
Modified: py/trunk/py/test/plugin/pytest_plugintester.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_plugintester.py (original)
+++ py/trunk/py/test/plugin/pytest_plugintester.py Tue Mar 31 19:58:02 2009
@@ -29,6 +29,7 @@
# FSTester = self.pyfuncitem.config.pytestplugins.getpluginattr("pytester", "FSTester")
from pytest_pytester import TmpTestdir
crunner = TmpTestdir(self.pyfuncitem)
+ self.pyfuncitem.addfinalizer(crunner.finalize)
#
for colitem in self.pyfuncitem.listchain():
if isinstance(colitem, py.test.collect.Module) and \
Modified: py/trunk/py/test/plugin/pytest_pytester.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_pytester.py (original)
+++ py/trunk/py/test/plugin/pytest_pytester.py Tue Mar 31 19:58:02 2009
@@ -15,7 +15,6 @@
def pytest_funcarg__testdir(self, pyfuncitem):
tmptestdir = TmpTestdir(pyfuncitem)
- pyfuncitem.addfinalizer(tmptestdir.finalize)
return tmptestdir
def pytest_funcarg__EventRecorder(self, pyfuncitem):
@@ -56,6 +55,11 @@
self.plugins = []
self._syspathremove = []
self.chdir() # always chdir
+ assert hasattr(self, '_olddir')
+ self.pyfuncitem.addfinalizer(self.finalize)
+
+ def __repr__(self):
+ return "<TmpTestdir %r>" % (self.tmpdir,)
def Config(self, pyplugins=None, topdir=None):
if topdir is None:
@@ -69,7 +73,7 @@
self._olddir.chdir()
def chdir(self):
- old = self.testdir.chdir()
+ old = self.tmpdir.chdir()
if not hasattr(self, '_olddir'):
self._olddir = old
@@ -110,9 +114,6 @@
def mkdir(self, name):
return self.tmpdir.mkdir(name)
- def chdir(self):
- return self.tmpdir.chdir()
-
def genitems(self, colitems):
return list(self.session.genitems(colitems))
Modified: py/trunk/py/test/plugin/pytest_terminal.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_terminal.py (original)
+++ py/trunk/py/test/plugin/pytest_terminal.py Tue Mar 31 19:58:02 2009
@@ -29,6 +29,7 @@
self.gateway2info = {}
def write_fspath_result(self, fspath, res):
+ fspath = self.curdir.bestrelpath(fspath)
if fspath != self.currentfspath:
self._tw.line()
relpath = self.curdir.bestrelpath(fspath)
@@ -138,6 +139,8 @@
def pyevent_itemstart(self, item, node=None):
if self.config.option.debug:
info = item.repr_metainfo()
+node
+n
line = info.verboseline(basedir=self.curdir) + " "
extra = ""
if node:
More information about the pytest-commit
mailing list