[py-svn] r51153 - in py/branch/event/py/test2: . rsession testing
hpk at codespeak.net
hpk at codespeak.net
Thu Jan 31 15:24:02 CET 2008
Author: hpk
Date: Thu Jan 31 15:24:01 2008
New Revision: 51153
Removed:
py/branch/event/py/test2/testing/test_repevent.py
Modified:
py/branch/event/py/test2/collectonly.py
py/branch/event/py/test2/config.py
py/branch/event/py/test2/repevent.py
py/branch/event/py/test2/rsession/rsession.py
py/branch/event/py/test2/session.py
py/branch/event/py/test2/testing/test_collectonly.py
py/branch/event/py/test2/testing/test_config.py
py/branch/event/py/test2/testing/test_remote.py
py/branch/event/py/test2/testing/test_session2.py
Log:
a bit of renaming and streamlining of event handling
(both in tests and code)
Modified: py/branch/event/py/test2/collectonly.py
==============================================================================
--- py/branch/event/py/test2/collectonly.py (original)
+++ py/branch/event/py/test2/collectonly.py Thu Jan 31 15:24:01 2008
@@ -30,8 +30,3 @@
def summary(self):
self.out.sep("=", "Total time: %.1f" % (self.timeend - self.timestart))
-class CollectSession(Session):
- reporterclass = CollectReporter
-
- def run(self, item):
- pass
Modified: py/branch/event/py/test2/config.py
==============================================================================
--- py/branch/event/py/test2/config.py (original)
+++ py/branch/event/py/test2/config.py Thu Jan 31 15:24:01 2008
@@ -163,8 +163,6 @@
name = 'Session'
if self.option.dist:
name = 'RSession'
- elif self.option.collectonly:
- name = 'CollectSession'
else:
if self.option.looponfailing or self.option.executable:
name = 'RemoteTerminalSession'
Modified: py/branch/event/py/test2/repevent.py
==============================================================================
--- py/branch/event/py/test2/repevent.py (original)
+++ py/branch/event/py/test2/repevent.py Thu Jan 31 15:24:01 2008
@@ -17,13 +17,6 @@
for key, value in self.__dict__.items()]
return "<%s %s>" %(self.__class__.__name__, " ".join(l),)
-class SendItem(ReportEvent):
- def __init__(self, channel, item):
- self.item = item
- self.channel = channel
- if channel:
- self.host = channel.gateway.host
-
class ReceivedItemOutcome(ReportEvent):
def __init__(self, channel, item, outcome):
self.channel = channel
@@ -32,25 +25,12 @@
self.item = item
self.outcome = outcome
-#class CallEvent(ReportEvent):
-# def __init__(self, func, args, kwargs):
-# self.func = func
-# self.args = args
-# self.kwargs = kwargs
-#
-# def __repr__(self):
-# call = "%s args=%s, kwargs=%s" %(self.func.__name__,
-# self.args, self.kwargs)
-# return '<%s %s>' %(self.__class__.__name__, call)
-#
-#class CallStart(CallEvent):
-# pass
-#
-#class CallException(CallEvent):
-# pass
-#
-#class CallFinish(CallEvent):
-# pass
+class SendItem(ReportEvent):
+ def __init__(self, channel, item):
+ self.item = item
+ self.channel = channel
+ if channel:
+ self.host = channel.gateway.host
class HostRSyncing(ReportEvent):
def __init__(self, host, root, remotepath, synced):
@@ -80,10 +60,6 @@
def __init__(self):
self.timeend = time.time()
-class Nodes(ReportEvent):
- def __init__(self, nodes):
- self.nodes = nodes
-
class SkippedTryiter(ReportEvent):
def __init__(self, excinfo, item):
self.excinfo = excinfo
@@ -94,6 +70,13 @@
self.excinfo = excinfo
self.item = item
+class CollectionStart(ReportEvent):
+ def __init__(self, collector):
+ self.collector = collector
+
+class CollectionFinish(ReportEvent):
+ def __init__(self, collector):
+ self.collector = collector
class ItemStart(ReportEvent):
""" This class shows most of the start stuff, like directory, module, class
Modified: py/branch/event/py/test2/rsession/rsession.py
==============================================================================
--- py/branch/event/py/test2/rsession/rsession.py (original)
+++ py/branch/event/py/test2/rsession/rsession.py Thu Jan 31 15:24:01 2008
@@ -59,8 +59,6 @@
print "tearing down nodes"
hm.teardown_hosts(nodes)
- hub.notify(repevent.Nodes(nodes))
- # XXX retval = reporter(repevent.TestFinished())
hub.notify(repevent.TestFinished())
except (KeyboardInterrupt, SystemExit):
hub.notify(repevent.InterruptedExecution())
Modified: py/branch/event/py/test2/session.py
==============================================================================
--- py/branch/event/py/test2/session.py (original)
+++ py/branch/event/py/test2/session.py Thu Jan 31 15:24:01 2008
@@ -27,7 +27,6 @@
if not colitems:
break
next = colitems.pop(0)
- hub.notify(repevent.ItemStart(next))
if isinstance(next, stopitems):
try:
next._skipbykeyword(keyword)
@@ -38,6 +37,7 @@
excinfo = py.code.ExceptionInfo()
hub.notify(repevent.SkippedTryiter(excinfo, next))
else:
+ hub.notify(repevent.CollectionStart(next))
try:
cols = [next.join(x) for x in next.run()]
for x in itemgen(session, cols, keyword):
@@ -50,8 +50,7 @@
hub.notify(repevent.SkippedTryiter(excinfo, next))
else:
hub.notify(repevent.FailedTryiter(excinfo, next))
- hub.notify(repevent.ItemFinish(next))
-
+ hub.notify(repevent.CollectionFinish(next))
class AbstractSession(object):
""" An abstract session executes collectors/items through a runner.
@@ -114,13 +113,14 @@
while 1:
try:
item = itemgenerator.next()
- outcome = self.run(item)
- self.config.hub.notify(repevent.ReceivedItemOutcome(None, item, outcome))
- if outcome is not None:
- if not outcome.passed and not outcome.skipped:
- failures.append((item, outcome))
- if self.config.option.exitfirst:
- raise StopIteration()
+ if not self.config.option.collectonly:
+ outcome = self.run(item)
+ self.config.hub.notify(repevent.ReceivedItemOutcome(None, item, outcome))
+ if outcome is not None:
+ if not outcome.passed and not outcome.skipped:
+ failures.append((item, outcome))
+ if self.config.option.exitfirst:
+ raise StopIteration()
except StopIteration:
break
finally:
Modified: py/branch/event/py/test2/testing/test_collectonly.py
==============================================================================
--- py/branch/event/py/test2/testing/test_collectonly.py (original)
+++ py/branch/event/py/test2/testing/test_collectonly.py Thu Jan 31 15:24:01 2008
@@ -1,6 +1,10 @@
import py
+
+from test_session import getevents_runmain
+from py.__.test2 import repevent
+
class TestCollectonly:
def setup_class(cls):
tmp = py.test2.ensuretemp('itemgentest')
@@ -27,23 +31,14 @@
config = py.test2.config._reparse([self.tmp, '--collectonly'])
session = config.initsession()
# test it all in once
- cap = py.io.StdCaptureFD()
- session.main()
- out, err = cap.reset()
- # XXX exact output matching
- lines = """<Directory 'itemgentest'>
- <Module 'test_one.py'>
- <Function 'test_one'>
- <Class 'TestX'>
- <Instance '()'>
- <Function 'test_method_one'>
- <Class 'TestY'>
- <Instance '()'>
- <Function 'test_method_one'>
- <Module 'test_three.py'>
- - FAILED TO LOAD MODULE -
- <Module 'test_two.py'>
- - skipped -
-"""
- for line in lines:
- assert line in out
+ allevents = getevents_runmain(session)
+ started = finished = 0
+ for event in allevents:
+ assert not isinstance(event, repevent.ReceivedItemOutcome)
+ if isinstance(event, repevent.CollectionStart):
+ started += 1
+ elif isinstance(event, repevent.CollectionFinish):
+ finished += 1
+
+ print started
+ assert started == finished
Modified: py/branch/event/py/test2/testing/test_config.py
==============================================================================
--- py/branch/event/py/test2/testing/test_config.py (original)
+++ py/branch/event/py/test2/testing/test_config.py Thu Jan 31 15:24:01 2008
@@ -223,8 +223,6 @@
assert config._getsessionname() == 'RemoteTerminalSession'
config = py.test2.config._reparse([self.tmpdir, '--dist', '--exec=x'])
assert config._getsessionname() == 'RSession'
- config = py.test2.config._reparse([self.tmpdir, '--collectonly'])
- assert config._getsessionname() == 'CollectSession'
def test_sessionname_lookup_custom(self):
self.tmpdir.join("conftest.py").write(py.code.Source("""
Modified: py/branch/event/py/test2/testing/test_remote.py
==============================================================================
--- py/branch/event/py/test2/testing/test_remote.py (original)
+++ py/branch/event/py/test2/testing/test_remote.py Thu Jan 31 15:24:01 2008
@@ -1,5 +1,6 @@
import py
from py.__.test2.testing.setupdata import setup_module
+from test_session import getevents_runmain
class TestRemote:
def test_exec(self):
@@ -13,15 +14,11 @@
config = py.test2.config._reparse(
['--exec=' + py.std.sys.executable,
o])
- cls = config._getsessionclass()
- out = [] # out = py.std.Queue.Queue()
- session = cls(config, out.append)
- failures = session.main()
- for s in out:
- if s.find('1 failed') != -1:
- break
- else:
- py.test2.fail("did not see test_1 failure in output")
+ session = config.initsession()
+ allevents = getevents_runmain(session)
+ print allevents
+ failures = [x for x in allevents
+ if isinstance(x, repevent.ReceivedItemOutcome)]
assert failures
def test_looponfailing(self):
Deleted: /py/branch/event/py/test2/testing/test_repevent.py
==============================================================================
--- /py/branch/event/py/test2/testing/test_repevent.py Thu Jan 31 15:24:01 2008
+++ (empty file)
@@ -1,34 +0,0 @@
-""" test reporting functionality. """
-
-import py
-from py.__.test2 import repevent
-
-
-def test_reporter_methods_sanity():
- """ Checks if all the methods of reporter are sane
- """
- from py.__.test2.reporter import RemoteReporter
-
- for method in dir(RemoteReporter):
-
- if method.startswith("report_") and method != "report_unknown":
- assert method[len('report_'):] in repevent.__dict__
-
-def XXXbrokentest_repevent_failures():
- # probably this thing here is a bad idea
- from py.__.test2.outcome import SerializableOutcome, ReprOutcome
-
- assert not repevent.ReportEvent().is_failure()
- assert not repevent.CallEvent(None, None, None).is_failure()
- assert repevent.FailedTryiter(None, None).is_failure()
- out = ReprOutcome(SerializableOutcome().make_repr())
- assert not repevent.ReceivedItemOutcome(None, None, out).is_failure()
- out = ReprOutcome(SerializableOutcome(skipped="xxx").make_repr())
- assert not repevent.ReceivedItemOutcome(None, None, out).is_failure()
- try:
- 1/0
- except:
- exc = py.code.ExceptionInfo()
- out = ReprOutcome(SerializableOutcome(excinfo=exc).make_repr())
- assert repevent.ReceivedItemOutcome(None, None, out).is_failure()
-
Modified: py/branch/event/py/test2/testing/test_session2.py
==============================================================================
--- py/branch/event/py/test2/testing/test_session2.py (original)
+++ py/branch/event/py/test2/testing/test_session2.py Thu Jan 31 15:24:01 2008
@@ -258,7 +258,7 @@
args = [str(tmpdir.join("sub6"))]
config = py.test2.config._reparse(args)
lsession = Session(config)
- allevents = getevents(lsession)
+ allevents = getevents_runmain(lsession)
testevents = [x for x in allevents
if isinstance(x, repevent.ReceivedItemOutcome)]
failevents = [i for i in testevents if i.outcome.excinfo]
More information about the py-svn
mailing list