use item's own fspath when doing progress reporting, fixes #31
--HG-- branch : 1.0.x
This commit is contained in:
parent
d2f497084e
commit
822b69a4e8
|
@ -99,8 +99,8 @@ def pytest_configure(config):
|
||||||
setsession(config)
|
setsession(config)
|
||||||
if config.option.version:
|
if config.option.version:
|
||||||
p = py.path.local(py.__file__).dirpath()
|
p = py.path.local(py.__file__).dirpath()
|
||||||
print "This is py.test version %s, imported from %s" % (
|
sys.stderr.write("This is py.test version %s, imported from %s\n" %
|
||||||
py.__version__, p)
|
(py.__version__, p))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
#xxxloadplugins(config)
|
#xxxloadplugins(config)
|
||||||
|
|
||||||
|
|
|
@ -181,8 +181,8 @@ class TerminalReporter:
|
||||||
else:
|
else:
|
||||||
# ensure that the path is printed before the
|
# ensure that the path is printed before the
|
||||||
# 1st test of a module starts running
|
# 1st test of a module starts running
|
||||||
fspath, lineno, msg = self._getreportinfo(item)
|
|
||||||
self.write_fspath_result(fspath, "")
|
self.write_fspath_result(self._getfspath(item), "")
|
||||||
|
|
||||||
def pytest__teardown_final_logerror(self, report):
|
def pytest__teardown_final_logerror(self, report):
|
||||||
self.stats.setdefault("error", []).append(report)
|
self.stats.setdefault("error", []).append(report)
|
||||||
|
@ -199,8 +199,7 @@ class TerminalReporter:
|
||||||
markup = {}
|
markup = {}
|
||||||
self.stats.setdefault(cat, []).append(rep)
|
self.stats.setdefault(cat, []).append(rep)
|
||||||
if not self.config.option.verbose:
|
if not self.config.option.verbose:
|
||||||
fspath, lineno, msg = self._getreportinfo(rep.item)
|
self.write_fspath_result(self._getfspath(rep.item), letter)
|
||||||
self.write_fspath_result(fspath, letter)
|
|
||||||
else:
|
else:
|
||||||
line = self._reportinfoline(rep.item)
|
line = self._reportinfoline(rep.item)
|
||||||
if not hasattr(rep, 'node'):
|
if not hasattr(rep, 'node'):
|
||||||
|
@ -288,8 +287,13 @@ class TerminalReporter:
|
||||||
self.write_line("### Watching: %s" %(rootdir,), bold=True)
|
self.write_line("### Watching: %s" %(rootdir,), bold=True)
|
||||||
|
|
||||||
def _reportinfoline(self, item):
|
def _reportinfoline(self, item):
|
||||||
|
collect_fspath = self._getfspath(item)
|
||||||
fspath, lineno, msg = self._getreportinfo(item)
|
fspath, lineno, msg = self._getreportinfo(item)
|
||||||
if fspath:
|
if fspath and fspath != collect_fspath:
|
||||||
|
fspath = "%s <- %s" % (
|
||||||
|
self.curdir.bestrelpath(collect_fspath),
|
||||||
|
self.curdir.bestrelpath(fspath))
|
||||||
|
elif fspath:
|
||||||
fspath = self.curdir.bestrelpath(fspath)
|
fspath = self.curdir.bestrelpath(fspath)
|
||||||
if lineno is not None:
|
if lineno is not None:
|
||||||
lineno += 1
|
lineno += 1
|
||||||
|
@ -298,7 +302,7 @@ class TerminalReporter:
|
||||||
elif fspath and msg:
|
elif fspath and msg:
|
||||||
line = "%(fspath)s: %(msg)s"
|
line = "%(fspath)s: %(msg)s"
|
||||||
elif fspath and lineno:
|
elif fspath and lineno:
|
||||||
line = "%(fspath)s:%(lineno)s"
|
line = "%(fspath)s:%(lineno)s %(extrapath)s"
|
||||||
else:
|
else:
|
||||||
line = "[noreportinfo]"
|
line = "[noreportinfo]"
|
||||||
return line % locals() + " "
|
return line % locals() + " "
|
||||||
|
@ -322,6 +326,13 @@ class TerminalReporter:
|
||||||
item.__reportinfo = reportinfo
|
item.__reportinfo = reportinfo
|
||||||
return reportinfo
|
return reportinfo
|
||||||
|
|
||||||
|
def _getfspath(self, item):
|
||||||
|
try:
|
||||||
|
return item.fspath
|
||||||
|
except AttributeError:
|
||||||
|
fspath, lineno, msg = self._getreportinfo(item)
|
||||||
|
return fspath
|
||||||
|
|
||||||
#
|
#
|
||||||
# summaries for sessionfinish
|
# summaries for sessionfinish
|
||||||
#
|
#
|
||||||
|
|
|
@ -209,10 +209,6 @@ class TestTerminal:
|
||||||
item = testdir.getitem("def test_func(): pass")
|
item = testdir.getitem("def test_func(): pass")
|
||||||
tr = TerminalReporter(item.config, file=linecomp.stringio)
|
tr = TerminalReporter(item.config, file=linecomp.stringio)
|
||||||
item.config.pluginmanager.register(tr)
|
item.config.pluginmanager.register(tr)
|
||||||
tr.config.hook.pytest_itemstart(item=item)
|
|
||||||
linecomp.assert_contains_lines([
|
|
||||||
"*ABCDE "
|
|
||||||
])
|
|
||||||
tr.config.option.verbose = True
|
tr.config.option.verbose = True
|
||||||
tr.config.hook.pytest_itemstart(item=item)
|
tr.config.hook.pytest_itemstart(item=item)
|
||||||
linecomp.assert_contains_lines([
|
linecomp.assert_contains_lines([
|
||||||
|
@ -227,16 +223,35 @@ class TestTerminal:
|
||||||
item.config.pluginmanager.register(Plugin())
|
item.config.pluginmanager.register(Plugin())
|
||||||
tr = TerminalReporter(item.config, file=linecomp.stringio)
|
tr = TerminalReporter(item.config, file=linecomp.stringio)
|
||||||
item.config.pluginmanager.register(tr)
|
item.config.pluginmanager.register(tr)
|
||||||
tr.config.hook.pytest_itemstart(item=item)
|
|
||||||
linecomp.assert_contains_lines([
|
|
||||||
"*FGHJ "
|
|
||||||
])
|
|
||||||
tr.config.option.verbose = True
|
tr.config.option.verbose = True
|
||||||
tr.config.hook.pytest_itemstart(item=item)
|
tr.config.hook.pytest_itemstart(item=item)
|
||||||
linecomp.assert_contains_lines([
|
linecomp.assert_contains_lines([
|
||||||
"*FGHJ:43: custom*"
|
"*FGHJ:43: custom*"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_itemreport_subclasses_show_subclassed_file(self, testdir):
|
||||||
|
p1 = testdir.makepyfile(test_p1="""
|
||||||
|
class BaseTests:
|
||||||
|
def test_p1(self):
|
||||||
|
pass
|
||||||
|
class TestClass(BaseTests):
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
p2 = testdir.makepyfile(test_p2="""
|
||||||
|
from test_p1 import BaseTests
|
||||||
|
class TestMore(BaseTests):
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest(p2)
|
||||||
|
assert result.stdout.fnmatch_lines([
|
||||||
|
"*test_p2.py .",
|
||||||
|
"*1 passed*",
|
||||||
|
])
|
||||||
|
result = testdir.runpytest("-v", p2)
|
||||||
|
result.stdout.fnmatch_lines([
|
||||||
|
"*test_p2.py <- test_p1.py:2: TestMore.test_p1*",
|
||||||
|
])
|
||||||
|
|
||||||
def test_keyboard_interrupt_dist(self, testdir, option):
|
def test_keyboard_interrupt_dist(self, testdir, option):
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
raise KeyboardInterrupt
|
raise KeyboardInterrupt
|
||||||
|
|
Loading…
Reference in New Issue