[pypy-svn] r58077 - in pypy/branch/pypy-pytrunk/pypy/tool/pytest: . test
pedronis at codespeak.net
pedronis at codespeak.net
Fri Sep 12 11:12:56 CEST 2008
Author: pedronis
Date: Fri Sep 12 11:12:54 2008
New Revision: 58077
Modified:
pypy/branch/pypy-pytrunk/pypy/tool/pytest/filelog.py
pypy/branch/pypy-pytrunk/pypy/tool/pytest/test/test_filelog.py
Log:
(iko, pedronis)
make the test more robust by faking less, simpler but naive for now implementation of paths for items
Modified: pypy/branch/pypy-pytrunk/pypy/tool/pytest/filelog.py
==============================================================================
--- pypy/branch/pypy-pytrunk/pypy/tool/pytest/filelog.py (original)
+++ pypy/branch/pypy-pytrunk/pypy/tool/pytest/filelog.py Fri Sep 12 11:12:54 2008
@@ -1,6 +1,11 @@
from py.__.test.session import Session
from py.__.test import event
+
+def generic_path(item):
+ names = item.listnames()
+ return '.'.join(names).replace('.(', '(')
+
class FileLogSession(Session):
def __init__(self, config):
@@ -14,10 +19,6 @@
def log_event_to_file(self, ev):
if isinstance(ev, event.ItemTestReport):
outcome = ev.outcome
- metainfo = ev.colitem.repr_metainfo()
- path = metainfo.fspath
- modpath = metainfo.modpath
- if modpath:
- path += ":%s" % modpath
- print >>self.logfile, "%s %s" % (outcome.shortrepr, path)
+ gpath = generic_path(ev.colitem)
+ print >>self.logfile, "%s %s" % (outcome.shortrepr, gpath)
Modified: pypy/branch/pypy-pytrunk/pypy/tool/pytest/test/test_filelog.py
==============================================================================
--- pypy/branch/pypy-pytrunk/pypy/tool/pytest/test/test_filelog.py (original)
+++ pypy/branch/pypy-pytrunk/pypy/tool/pytest/test/test_filelog.py Fri Sep 12 11:12:54 2008
@@ -1,7 +1,11 @@
+import py
+
from pypy.tool.pytest import filelog
import os, StringIO
+from py.__.test.collect import Node, Item
from py.__.test.event import ItemTestReport
+from py.__.test.runner import OutcomeRepr
class Fake(object):
@@ -9,6 +13,23 @@
self.__dict__.update(kwds)
+def test_generic_path():
+ p1 = Node('a', config='dummy')
+ p2 = Node('B', parent=p1)
+ p3 = Node('()', parent = p2)
+ item = Item('c', parent = p3)
+
+ res = filelog.generic_path(item)
+ assert res == 'a.B().c'
+
+
+def make_item(*names):
+ node = None
+ config = "dummy"
+ for name in names[:-1]:
+ node = Node(name, parent=node, config=config)
+ return Item(names[-1], parent=node)
+
class TestFileLogSession(object):
@@ -34,15 +55,15 @@
sess.logfile.close()
os.unlink(logfname)
- def test_item_test_passed_or_skipped(self):
+ def test_item_test_passed(self):
option = Fake(eventlog=None)
config = Fake(option=option)
sess = filelog.FileLogSession(config)
sess.logfile = StringIO.StringIO()
- colitem = Fake(repr_metainfo=lambda: Fake(fspath='some/path',
- modpath="a.b"))
- outcome=Fake(shortrepr='.')
+ colitem = make_item('some', 'path', 'a', 'b')
+
+ outcome=OutcomeRepr('execute', '.', '')
rep_ev = ItemTestReport(colitem, outcome=outcome)
sess.bus.notify(rep_ev)
@@ -51,12 +72,16 @@
assert len(lines) == 1
line = lines[0]
assert line.startswith(". ")
- assert line[2:] == 'some/path:a.b'
+ assert line[2:] == 'some.path.a.b'
+
+ def test_item_test_skipped(self):
+ py.test.skip("WIP: take the longrepr into account")
+ option = Fake(eventlog=None)
+ config = Fake(option=option)
+ sess = filelog.FileLogSession(config)
sess.logfile = StringIO.StringIO()
- colitem = Fake(repr_metainfo=lambda: Fake(fspath='some/path',
- modpath=None))
- outcome=Fake(shortrepr='s')
+ outcome=OutcomeRepr('execute', 's', '')
rep_ev = ItemTestReport(colitem, outcome=outcome)
sess.bus.notify(rep_ev)
@@ -66,7 +91,3 @@
line = lines[0]
assert line.startswith("s ")
- assert line[2:] == 'some/path'
-
-
-# XXX integration tests
More information about the Pypy-commit
mailing list