[svn r37438] Fiddle-fixed --rest, although it works now some cleanups would be nice...
Cleaned up the tests a bit and re-enabled some (sucky tests are better than no tests at all, I guess... :| ), re-enabled a debug print after complaints from cfbolz ;) but this time it prints to stderr (to avoid ReST pollution). --HG-- branch : trunk
This commit is contained in:
parent
7ebd7ec888
commit
fd40b43cdf
|
@ -26,7 +26,7 @@ class Conftest(object):
|
||||||
for arg in args + [current]:
|
for arg in args + [current]:
|
||||||
anchor = current.join(arg, abs=1)
|
anchor = current.join(arg, abs=1)
|
||||||
if anchor.check(): # we found some file object
|
if anchor.check(): # we found some file object
|
||||||
#print "initializing conftest from", anchor
|
print >>py.std.sys.stderr, "initializing conftest from", anchor
|
||||||
# conftest-lookups without a path actually mean
|
# conftest-lookups without a path actually mean
|
||||||
# lookups with our initial path.
|
# lookups with our initial path.
|
||||||
self._path2confmods[None] = self.getconftestmodules(anchor)
|
self._path2confmods[None] = self.getconftestmodules(anchor)
|
||||||
|
|
|
@ -27,7 +27,10 @@ class Outcome(object):
|
||||||
tb_info = [self.traceback_entry_repr(x, tbstyle)
|
tb_info = [self.traceback_entry_repr(x, tbstyle)
|
||||||
for x in excinfo.traceback]
|
for x in excinfo.traceback]
|
||||||
rec_index = excinfo.traceback.recursionindex()
|
rec_index = excinfo.traceback.recursionindex()
|
||||||
return (excinfo.type.__name__, str(excinfo.value), (tb_info, rec_index))
|
etype = excinfo.type
|
||||||
|
if hasattr(etype, '__name__'):
|
||||||
|
etype = etype.__name__
|
||||||
|
return (etype, str(excinfo.value), (tb_info, rec_index))
|
||||||
|
|
||||||
def traceback_entry_repr(self, tb_entry, tb_style):
|
def traceback_entry_repr(self, tb_entry, tb_style):
|
||||||
lineno = tb_entry.lineno
|
lineno = tb_entry.lineno
|
||||||
|
|
|
@ -140,7 +140,10 @@ class RestReporter(AbstractReporter):
|
||||||
self.add_rest(ListItem('%s: %s' % (item, text)))
|
self.add_rest(ListItem('%s: %s' % (item, text)))
|
||||||
|
|
||||||
def get_host(self, event):
|
def get_host(self, event):
|
||||||
return event.channel.gateway.host
|
try:
|
||||||
|
return event.channel.gateway.host
|
||||||
|
except AttributeError:
|
||||||
|
return None
|
||||||
|
|
||||||
def failures(self):
|
def failures(self):
|
||||||
self.traceback_num = 0
|
self.traceback_num = 0
|
||||||
|
@ -160,7 +163,8 @@ class RestReporter(AbstractReporter):
|
||||||
t.add(Link(itempath, link))
|
t.add(Link(itempath, link))
|
||||||
else:
|
else:
|
||||||
t.add(Text(itempath))
|
t.add(Text(itempath))
|
||||||
t.add(Text('on %s' % (host.hostname,)))
|
if host:
|
||||||
|
t.add(Text('on %s' % (host.hostname,)))
|
||||||
self.add_rest(t)
|
self.add_rest(t)
|
||||||
if event.outcome.signal:
|
if event.outcome.signal:
|
||||||
self.repr_signal(event.item, event.outcome)
|
self.repr_signal(event.item, event.outcome)
|
||||||
|
|
|
@ -11,6 +11,11 @@ from py.__.rest.rst import *
|
||||||
from py.__.test.rsession.hostmanage import HostInfo
|
from py.__.test.rsession.hostmanage import HostInfo
|
||||||
from py.__.test.rsession.outcome import Outcome
|
from py.__.test.rsession.outcome import Outcome
|
||||||
|
|
||||||
|
class Container(object):
|
||||||
|
def __init__(self, **args):
|
||||||
|
for arg, val in args.items():
|
||||||
|
setattr(self, arg, val)
|
||||||
|
|
||||||
class RestTestReporter(RestReporter):
|
class RestTestReporter(RestReporter):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if args:
|
if args:
|
||||||
|
@ -78,11 +83,6 @@ Running tests on hosts\: localhost, foo.com
|
||||||
def listnames(self):
|
def listnames(self):
|
||||||
return ['package', 'foo', 'bar.py']
|
return ['package', 'foo', 'bar.py']
|
||||||
|
|
||||||
class Container(object):
|
|
||||||
def __init__(self, **args):
|
|
||||||
for arg, val in args.items():
|
|
||||||
setattr(self, arg, val)
|
|
||||||
|
|
||||||
parent = Container(parent=None, fspath=py.path.local('.'))
|
parent = Container(parent=None, fspath=py.path.local('.'))
|
||||||
event = report.ItemStart(item=FakeModule(parent))
|
event = report.ItemStart(item=FakeModule(parent))
|
||||||
reporter.report(event)
|
reporter.report(event)
|
||||||
|
@ -105,11 +105,6 @@ Testing module foo/bar.py (2 items)
|
||||||
|
|
||||||
def test_ReceivedItemOutcome_PASSED(self):
|
def test_ReceivedItemOutcome_PASSED(self):
|
||||||
outcome = Outcome()
|
outcome = Outcome()
|
||||||
class Container(object):
|
|
||||||
def __init__(self, **args):
|
|
||||||
for arg, val in args.items():
|
|
||||||
setattr(self, arg, val)
|
|
||||||
|
|
||||||
item = Container(listnames=lambda: ['', 'foo.py', 'bar', '()', 'baz'])
|
item = Container(listnames=lambda: ['', 'foo.py', 'bar', '()', 'baz'])
|
||||||
event = report.ReceivedItemOutcome(channel=ch, outcome=outcome, item=item)
|
event = report.ReceivedItemOutcome(channel=ch, outcome=outcome, item=item)
|
||||||
reporter.report(event)
|
reporter.report(event)
|
||||||
|
@ -117,11 +112,6 @@ Testing module foo/bar.py (2 items)
|
||||||
'foo.py/bar()/baz\n\n')
|
'foo.py/bar()/baz\n\n')
|
||||||
|
|
||||||
def test_ReceivedItemOutcome_SKIPPED(self):
|
def test_ReceivedItemOutcome_SKIPPED(self):
|
||||||
class Container(object):
|
|
||||||
def __init__(self, **args):
|
|
||||||
for arg, val in args.items():
|
|
||||||
setattr(self, arg, val)
|
|
||||||
|
|
||||||
outcome = Outcome(skipped="reason")
|
outcome = Outcome(skipped="reason")
|
||||||
item = Container(listnames=lambda: ['', 'foo.py', 'bar', '()', 'baz'])
|
item = Container(listnames=lambda: ['', 'foo.py', 'bar', '()', 'baz'])
|
||||||
event = report.ReceivedItemOutcome(channel=ch, outcome=outcome, item=item)
|
event = report.ReceivedItemOutcome(channel=ch, outcome=outcome, item=item)
|
||||||
|
@ -130,11 +120,6 @@ Testing module foo/bar.py (2 items)
|
||||||
'foo.py/bar()/baz\n\n')
|
'foo.py/bar()/baz\n\n')
|
||||||
|
|
||||||
def test_ReceivedItemOutcome_FAILED(self):
|
def test_ReceivedItemOutcome_FAILED(self):
|
||||||
class Container(object):
|
|
||||||
def __init__(self, **args):
|
|
||||||
for arg, val in args.items():
|
|
||||||
setattr(self, arg, val)
|
|
||||||
|
|
||||||
outcome = Outcome(excinfo="xxx")
|
outcome = Outcome(excinfo="xxx")
|
||||||
item = Container(listnames=lambda: ['', 'foo.py', 'bar', '()', 'baz'])
|
item = Container(listnames=lambda: ['', 'foo.py', 'bar', '()', 'baz'])
|
||||||
event = report.ReceivedItemOutcome(channel=ch, outcome=outcome, item=item)
|
event = report.ReceivedItemOutcome(channel=ch, outcome=outcome, item=item)
|
||||||
|
@ -144,12 +129,44 @@ Testing module foo/bar.py (2 items)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def test_skips(self):
|
def test_ReceivedItemOutcome_FAILED_stdout(self):
|
||||||
class Container(object):
|
excinfo = Container(
|
||||||
def __init__(self, **args):
|
typename='FooError',
|
||||||
for arg, val in args.items():
|
value='A foo has occurred',
|
||||||
setattr(self, arg, val)
|
traceback=[
|
||||||
|
Container(
|
||||||
|
path='foo/bar.py',
|
||||||
|
lineno=1,
|
||||||
|
relline=1,
|
||||||
|
source='foo()',
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
path='foo/baz.py',
|
||||||
|
lineno=4,
|
||||||
|
relline=1,
|
||||||
|
source='raise FooError("A foo has occurred")',
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
outcome = Outcome(excinfo=excinfo)
|
||||||
|
outcome.stdout = '<printed>'
|
||||||
|
outcome.stderr = ''
|
||||||
|
parent = Container(parent=None, fspath=py.path.local('.'))
|
||||||
|
item = Container(listnames=lambda: ['', 'foo.py', 'bar', '()', 'baz'],
|
||||||
|
parent=parent, fspath=py.path.local('foo'))
|
||||||
|
event = report.ReceivedItemOutcome(channel=ch, outcome=outcome,
|
||||||
|
item=item)
|
||||||
|
reporter.report(event)
|
||||||
|
reporter.timestart = 10
|
||||||
|
reporter.timeend = 20
|
||||||
|
reporter.timersync = 15
|
||||||
|
reporter.print_summary(10, '', '')
|
||||||
|
|
||||||
|
reporter.print_summary(1, 'skipped', 'failed')
|
||||||
|
out = stdout.getvalue()
|
||||||
|
assert out.find('<printed>') > -1
|
||||||
|
|
||||||
|
def test_skips(self):
|
||||||
class FakeOutcome(Container, report.ReceivedItemOutcome):
|
class FakeOutcome(Container, report.ReceivedItemOutcome):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -175,12 +192,6 @@ Reasons for skipped tests\:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def test_failures(self):
|
def test_failures(self):
|
||||||
py.test.skip("This one is totally artificial, needs to be rewritten")
|
|
||||||
class Container(object):
|
|
||||||
def __init__(self, **args):
|
|
||||||
for arg, val in args.items():
|
|
||||||
setattr(self, arg, val)
|
|
||||||
|
|
||||||
class FakeOutcome(Container, report.ReceivedItemOutcome):
|
class FakeOutcome(Container, report.ReceivedItemOutcome):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue