From hpk at codespeak.net Fri Feb 1 10:22:57 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 1 Feb 2008 10:22:57 +0100 (CET) Subject: [py-svn] r51163 - py/branch/event/py/test2/testing Message-ID: <20080201092257.D9B4E1684CF@codespeak.net> Author: hpk Date: Fri Feb 1 10:22:56 2008 New Revision: 51163 Modified: py/branch/event/py/test2/testing/test_remote.py Log: disabling the last failing output-checking test 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 Fri Feb 1 10:22:56 2008 @@ -15,13 +15,15 @@ ['--exec=' + py.std.sys.executable, o]) session = config.initsession() - allevents = getevents_runmain(session) - print allevents - failures = [x for x in allevents - if isinstance(x, repevent.ReceivedItemOutcome)] + #allevents = getevents_runmain(session) + #print allevents + #failures = [x for x in allevents + # if isinstance(x, repevent.ReceivedItemOutcome)] + failures = session.main() assert failures def test_looponfailing(self): + py.test.skip("fix output checking tests to check for events") o = tmpdir.ensure('looponfailing', dir=1) tfile = o.join('test_looponfailing.py') tfile.write(py.code.Source(""" @@ -30,6 +32,9 @@ """)) print py.std.sys.executable config = py.test2.config._reparse(['--looponfailing', str(o)]) + session = config.initsession() + failures = session.main() + cls = config._getsessionclass() out = py.std.Queue.Queue() session = cls(config, out.put) From hpk at codespeak.net Fri Feb 1 11:01:26 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 1 Feb 2008 11:01:26 +0100 (CET) Subject: [py-svn] r51166 - in py/branch/event/py/test2: . testing Message-ID: <20080201100126.9454D168469@codespeak.net> Author: hpk Date: Fri Feb 1 11:01:25 2008 New Revision: 51166 Modified: py/branch/event/py/test2/collect.py py/branch/event/py/test2/repevent.py py/branch/event/py/test2/session.py py/branch/event/py/test2/testing/test_session.py Log: refactor itemgen to produce these events: * CollectionStart * CollectionFailure * CollectionFinish and DeselectedTest (previous 'SkippedTryiter' aka "Skipped by keyword") Modified: py/branch/event/py/test2/collect.py ============================================================================== --- py/branch/event/py/test2/collect.py (original) +++ py/branch/event/py/test2/collect.py Fri Feb 1 11:01:25 2008 @@ -169,19 +169,19 @@ newl.append(x.name) return ".".join(newl) - def _skipbykeyword(self, keyword): - """ raise Skipped() exception if the given keyword - matches for this collector. + def _skipbykeyword(self, keywordexpr): + """ return True if they given keyword expression means to + skip this collector/item. """ - if not keyword: + if not keywordexpr: return chain = self.listchain() - for key in filter(None, keyword.split()): + for key in filter(None, keywordexpr.split()): eor = key[:1] == '-' if eor: key = key[1:] if not (eor ^ self._matchonekeyword(key, chain)): - py.test2.skip("test not selected by keyword %r" %(keyword,)) + return True def _matchonekeyword(self, key, chain): elems = key.split(".") Modified: py/branch/event/py/test2/repevent.py ============================================================================== --- py/branch/event/py/test2/repevent.py (original) +++ py/branch/event/py/test2/repevent.py Fri Feb 1 11:01:25 2008 @@ -60,20 +60,20 @@ def __init__(self): self.timeend = time.time() -class SkippedTryiter(ReportEvent): - def __init__(self, excinfo, item): - self.excinfo = excinfo - self.item = item - -class FailedTryiter(ReportEvent): - def __init__(self, excinfo, item): - self.excinfo = excinfo +class DeselectedTest(ReportEvent): + def __init__(self, item, keywordexpr): self.item = item + self.keywordexpr = keywordexpr class CollectionStart(ReportEvent): def __init__(self, collector): self.collector = collector +class CollectionFailure(ReportEvent): + def __init__(self, collector, excinfo): + self.excinfo = excinfo + self.collector = collector + class CollectionFinish(ReportEvent): def __init__(self, collector): self.collector = collector Modified: py/branch/event/py/test2/session.py ============================================================================== --- py/branch/event/py/test2/session.py (original) +++ py/branch/event/py/test2/session.py Fri Feb 1 11:01:25 2008 @@ -15,41 +15,31 @@ and tells reporter about that """ -try: - GeneratorExit -except NameError: - GeneratorExit = StopIteration # I think +GeneratorExit = py.builtin.GeneratorExit -def itemgen(session, colitems, keyword=None): +def itemgen(session, colitems, keywordexpr=None): hub = session.config.hub stopitems = py.test2.collect.Item # XXX should be generator here as well - while 1: - if not colitems: - break + while colitems: next = colitems.pop(0) if isinstance(next, stopitems): - try: - next._skipbykeyword(keyword) - yield next - except Skipped: + if next._skipbykeyword(keywordexpr): + hub.notify(repevent.DeselectedTest(next, keywordexpr)) if session.config.option.keyword_oneshot: - keyword = None - excinfo = py.code.ExceptionInfo() - hub.notify(repevent.SkippedTryiter(excinfo, next)) + keywordexpr = None + else: + yield next else: hub.notify(repevent.CollectionStart(next)) try: cols = [next.join(x) for x in next.run()] - for x in itemgen(session, cols, keyword): + for x in itemgen(session, cols, keywordexpr): yield x except (KeyboardInterrupt, SystemExit, GeneratorExit): raise except: excinfo = py.code.ExceptionInfo() - if excinfo.type is Skipped: - hub.notify(repevent.SkippedTryiter(excinfo, next)) - else: - hub.notify(repevent.FailedTryiter(excinfo, next)) + hub.notify(repevent.CollectionFailure(next, excinfo)) hub.notify(repevent.CollectionFinish(next)) class AbstractSession(object): Modified: py/branch/event/py/test2/testing/test_session.py ============================================================================== --- py/branch/event/py/test2/testing/test_session.py (original) +++ py/branch/event/py/test2/testing/test_session.py Fri Feb 1 11:01:25 2008 @@ -2,8 +2,7 @@ from setupdata import setup_module # sets up global 'tmpdir' from py.__.test2.outcome import Skipped, Failed, Passed, Outcome from py.__.test2.terminal.out import getout -from py.__.test2.repevent import ReceivedItemOutcome, SkippedTryiter,\ - FailedTryiter +from py.__.test2 import repevent from test_session2 import getevents_runmain @@ -19,7 +18,7 @@ ) def getoutcomes(all): - return [i.outcome for i in all if isinstance(i, ReceivedItemOutcome)] + return [i.outcome for i in all if isinstance(i, repevent.ReceivedItemOutcome)] def getpassed(all): @@ -27,11 +26,11 @@ def getskipped(all): return [i for i in getoutcomes(all) if i.skipped] + \ - [i for i in all if isinstance(i, SkippedTryiter)] + [i for i in all if isinstance(i, repevent.DeselectedTest)] def getfailed(all): return [i for i in getoutcomes(all) if i.excinfo] + \ - [i for i in all if isinstance(i, FailedTryiter)] + [i for i in all if isinstance(i, repevent.CollectionFailure)] def test_conflict_options(): for spec in conflict_options: @@ -78,7 +77,7 @@ '-s', '-k', keyword]) session = config._getsessionclass()(config) all = getevents_runmain(session) - outcomes = [i for i in all if isinstance(i, ReceivedItemOutcome)] + outcomes = [i for i in all if isinstance(i, repevent.ReceivedItemOutcome)] assert len(getfailed(all)) == 1 assert outcomes[0].item.name == name l = getskipped(all) @@ -110,7 +109,7 @@ all = getevents_runmain(session) print "keyword", repr(keyword) l = getpassed(all) - outcomes = [i for i in all if isinstance(i, ReceivedItemOutcome)] + outcomes = [i for i in all if isinstance(i, repevent.ReceivedItemOutcome)] assert len(l) == 1 assert outcomes[0].item.name == 'test_2' l = getskipped(all) From hpk at codespeak.net Fri Feb 1 11:20:19 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 1 Feb 2008 11:20:19 +0100 (CET) Subject: [py-svn] r51167 - in py/branch/event/py/test2: . rsession rsession/testing testing Message-ID: <20080201102019.6C7BB1684CF@codespeak.net> Author: hpk Date: Fri Feb 1 11:20:17 2008 New Revision: 51167 Modified: py/branch/event/py/test2/collect.py py/branch/event/py/test2/collectonly.py py/branch/event/py/test2/item.py py/branch/event/py/test2/outcome.py py/branch/event/py/test2/reporter.py py/branch/event/py/test2/rsession/hostmanage.py py/branch/event/py/test2/rsession/local.py py/branch/event/py/test2/rsession/master.py py/branch/event/py/test2/rsession/rest.py py/branch/event/py/test2/rsession/rsession.py py/branch/event/py/test2/rsession/slave.py py/branch/event/py/test2/rsession/testing/test_rest.py py/branch/event/py/test2/rsession/web.py py/branch/event/py/test2/rsession/webjs.py py/branch/event/py/test2/session.py py/branch/event/py/test2/testing/test_itemgen.py py/branch/event/py/test2/testing/test_session2.py Log: * getting rid of many unused imports * more event naming cleanup Modified: py/branch/event/py/test2/collect.py ============================================================================== --- py/branch/event/py/test2/collect.py (original) +++ py/branch/event/py/test2/collect.py Fri Feb 1 11:20:17 2008 @@ -25,7 +25,6 @@ """ from __future__ import generators import py -from py.__.test2.outcome import Skipped def configproperty(name): def fget(self): Modified: py/branch/event/py/test2/collectonly.py ============================================================================== --- py/branch/event/py/test2/collectonly.py (original) +++ py/branch/event/py/test2/collectonly.py Fri Feb 1 11:20:17 2008 @@ -21,12 +21,11 @@ def report_ItemFinish(self, event): self.indent -= 2 - def report_FailedTryiter(self, event): + def report_CollectionFailed(self, event): self.out.line(" " * self.indent + "- FAILED TO LOAD MODULE -") - def report_SkippedTryiter(self, event): + def report_DeselectedTest(self, event): self.out.line(" " * self.indent + "- skipped -") def summary(self): self.out.sep("=", "Total time: %.1f" % (self.timeend - self.timestart)) - Modified: py/branch/event/py/test2/item.py ============================================================================== --- py/branch/event/py/test2/item.py (original) +++ py/branch/event/py/test2/item.py Fri Feb 1 11:20:17 2008 @@ -1,7 +1,7 @@ import py from inspect import isclass, ismodule -from py.__.test2.outcome import Skipped, Failed, Passed +from py.__.test2 import outcome from py.__.test2.collect import FunctionMixin _dummy = object() @@ -72,10 +72,10 @@ def skip(msg=""): """ skip with the given Message. """ __tracebackhide__ = True - raise Skipped(msg=msg) + raise outcome.Skipped(msg=msg) def fail(msg="unknown failure"): """ fail with the given Message. """ __tracebackhide__ = True - raise Failed(msg=msg) + raise outcome.Failed(msg=msg) Modified: py/branch/event/py/test2/outcome.py ============================================================================== --- py/branch/event/py/test2/outcome.py (original) +++ py/branch/event/py/test2/outcome.py Fri Feb 1 11:20:17 2008 @@ -3,7 +3,7 @@ serialization of outcomes """ -import py, sys +import py class Outcome: def __init__(self, msg=None, excinfo=None): Modified: py/branch/event/py/test2/reporter.py ============================================================================== --- py/branch/event/py/test2/reporter.py (original) +++ py/branch/event/py/test2/reporter.py Fri Feb 1 11:20:17 2008 @@ -231,7 +231,7 @@ outcome = event.outcome text = outcome.skipped.value itemname = repr(outcome.skipped.traceback[-2]).split("\n")[0] - elif isinstance(event, repevent.SkippedTryiter): + elif isinstance(event, repevent.DeselectedTest): text = str(event.excinfo.value) itemname = "/".join(colitem.listnames()) if text not in texts: @@ -277,7 +277,7 @@ (total, skipped_str, failed_str, self.timeend - self.timestart, self.timersync - self.timestart)) - def report_SkippedTryiter(self, event): + def report_DeselectedTest(self, event): #event.outcome.excinfo.source = self.skipped_tests_outcome.append(event) @@ -337,7 +337,7 @@ # argh! bad hack, need to fix it self.failed[self.hosts[0]] += 1 - def report_SkippedTryiter(self, event): + def report_DeselectedTest(self, event): self.out.line("Skipped (%s) %s\n" % (str(event.excinfo.value), "/". join(event.item.listnames()))) @@ -376,7 +376,7 @@ self.out.sep("=", " %d test run%s%s in %.2fs" % (total, skipped_str, failed_str, self.timeend - self.timestart)) - def report_SkippedTryiter(self, event): + def report_DeselectedTest(self, event): #self.show_item(event.item, False) if isinstance(event.item, py.test2.collect.Module): self.out.write("- skipped (%s)" % event.excinfo.value) Modified: py/branch/event/py/test2/rsession/hostmanage.py ============================================================================== --- py/branch/event/py/test2/rsession/hostmanage.py (original) +++ py/branch/event/py/test2/rsession/hostmanage.py Fri Feb 1 11:20:17 2008 @@ -1,10 +1,7 @@ -import sys, os import py -import time -import thread, threading +import sys, os from py.__.test2.rsession.master import MasterNode from py.__.test2.rsession.slave import setup_slave - from py.__.test2 import repevent class HostInfo(object): Modified: py/branch/event/py/test2/rsession/local.py ============================================================================== --- py/branch/event/py/test2/rsession/local.py (original) +++ py/branch/event/py/test2/rsession/local.py Fri Feb 1 11:20:17 2008 @@ -1,4 +1,3 @@ - """ local-only operations """ Modified: py/branch/event/py/test2/rsession/master.py ============================================================================== --- py/branch/event/py/test2/rsession/master.py (original) +++ py/branch/event/py/test2/rsession/master.py Fri Feb 1 11:20:17 2008 @@ -4,8 +4,6 @@ import py from py.__.test2.outcome import ReprOutcome from py.__.test2 import repevent -from py.__.test2.outcome import Skipped -from py.builtin import GeneratorExit class MasterNode(object): def __init__(self, channel, notify): Modified: py/branch/event/py/test2/rsession/rest.py ============================================================================== --- py/branch/event/py/test2/rsession/rest.py (original) +++ py/branch/event/py/test2/rsession/rest.py Fri Feb 1 11:20:17 2008 @@ -132,7 +132,7 @@ outcome = event.outcome text = outcome.skipped itemname = self.get_item_name(event, colitem) - elif isinstance(event, repevent.SkippedTryiter): + elif isinstance(event, repevent.DeselectedTest): text = str(event.excinfo.value) itemname = "/".join(colitem.listnames()) if text not in texts: 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 Fri Feb 1 11:20:17 2008 @@ -10,11 +10,8 @@ from py.__.test2 import repevent from py.__.test2.rsession.master import dispatch_loop -from py.__.test2.rsession.hostmanage import HostInfo, HostManager -from py.__.test2.rsession.local import local_loop, plain_runner, apigen_runner,\ - box_runner +from py.__.test2.rsession.hostmanage import HostManager from py.__.test2.session import AbstractSession, itemgen -from py.__.test2.outcome import Skipped, Failed class RSession(AbstractSession): """ Remote version of session Modified: py/branch/event/py/test2/rsession/slave.py ============================================================================== --- py/branch/event/py/test2/rsession/slave.py (original) +++ py/branch/event/py/test2/rsession/slave.py Fri Feb 1 11:20:17 2008 @@ -6,7 +6,6 @@ from py.__.test2.executor import RunExecutor, BoxExecutor, AsyncExecutor from py.__.test2.outcome import SerializableOutcome from py.__.test2.outcome import Skipped -import thread import os class SlaveNode(object): Modified: py/branch/event/py/test2/rsession/testing/test_rest.py ============================================================================== --- py/branch/event/py/test2/rsession/testing/test_rest.py (original) +++ py/branch/event/py/test2/rsession/testing/test_rest.py Fri Feb 1 11:20:17 2008 @@ -178,7 +178,7 @@ class FakeOutcome(Container, repevent.ReceivedItemOutcome): pass - class FakeTryiter(Container, repevent.SkippedTryiter): + class FakeTryiter(Container, repevent.DeselectedTest): pass reporter.skips() Modified: py/branch/event/py/test2/rsession/web.py ============================================================================== --- py/branch/event/py/test2/rsession/web.py (original) +++ py/branch/event/py/test2/rsession/web.py Fri Feb 1 11:20:17 2008 @@ -250,7 +250,7 @@ args = {'hostname' : event.host.hostname, 'hostkey' : event.host.hostid} elif isinstance(event, repevent.FailedTryiter): args = add_item(event) - elif isinstance(event, repevent.SkippedTryiter): + elif isinstance(event, repevent.DeselectedTest): args = add_item(event) args['reason'] = str(event.excinfo.value) else: Modified: py/branch/event/py/test2/rsession/webjs.py ============================================================================== --- py/branch/event/py/test2/rsession/webjs.py (original) +++ py/branch/event/py/test2/rsession/webjs.py Fri Feb 1 11:20:17 2008 @@ -222,7 +222,7 @@ module_part.appendChild(tr) item_name = msg['fullitemname'] exported_methods.show_fail(item_name, fail_come_back) - elif msg['type'] == 'SkippedTryiter': + elif msg['type'] == 'DeselectedTest': module_part = get_elem(msg['fullitemname']) if not module_part: glob.pending.append(msg) Modified: py/branch/event/py/test2/session.py ============================================================================== --- py/branch/event/py/test2/session.py (original) +++ py/branch/event/py/test2/session.py Fri Feb 1 11:20:17 2008 @@ -1,20 +1,15 @@ +""" basic test session implementation. + +* drives collection of tests +* triggers executions of tests +* produces events used by reporting +""" + import py -import sys -from py.__.test2.outcome import Outcome, Failed, Passed, Skipped from py.__.test2 import repevent -from py.__.test2.outcome import SerializableOutcome, ReprOutcome -from py.__.test2.reporter import LocalReporter +from py.__.test2.outcome import ReprOutcome from py.__.test2.executor import RunExecutor, BoxExecutor -""" The session implementation - reporter version: - -* itemgen is responsible for iterating and telling reporter - about skipped and failed iterations (this is for collectors only), - this should be probably moved to session (for uniformity) -* session gets items which needs to be executed one after another - and tells reporter about that -""" - GeneratorExit = py.builtin.GeneratorExit def itemgen(session, colitems, keywordexpr=None): @@ -73,8 +68,6 @@ A Session gets test Items from Collectors, executes the Items and sends the Outcome to the Reporter. """ - reporterclass = LocalReporter - def shouldclose(self): return False @@ -116,7 +109,6 @@ finally: self.footer(colitems) return failures - return self.getitemoutcomepairs(Failed) def run(self, item): if not self.config.option.boxed: Modified: py/branch/event/py/test2/testing/test_itemgen.py ============================================================================== --- py/branch/event/py/test2/testing/test_itemgen.py (original) +++ py/branch/event/py/test2/testing/test_itemgen.py Fri Feb 1 11:20:17 2008 @@ -31,7 +31,7 @@ colitems = [py.test2.collect.Directory(self.tmp)] gen = itemgen(None, colitems, l.append) items = [i for i in gen] - assert len([i for i in l if isinstance(i, repevent.SkippedTryiter)]) == 1 + assert len([i for i in l if isinstance(i, repevent.DeselectedTest)]) == 1 assert len([i for i in l if isinstance(i, repevent.FailedTryiter)]) == 1 assert len(items) == 3 assert items[0].name == 'test_one' 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 Fri Feb 1 11:20:17 2008 @@ -241,7 +241,7 @@ if isinstance(x, repevent.FailedTryiter)] assert len(failedtryiter) == 1 skippedtryiter = [x for x in allevents - if isinstance(x, repevent.SkippedTryiter)] + if isinstance(x, repevent.DeselectedTest)] assert len(skippedtryiter) == 1 From hpk at codespeak.net Fri Feb 1 22:50:58 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 1 Feb 2008 22:50:58 +0100 (CET) Subject: [py-svn] r51194 - in py/branch/bugfix-0.9.0: . py/execnet Message-ID: <20080201215058.81969168074@codespeak.net> Author: hpk Date: Fri Feb 1 22:50:56 2008 New Revision: 51194 Added: py/branch/bugfix-0.9.0/ - copied from r50525, py/release/0.9.0/ Modified: py/branch/bugfix-0.9.0/py/execnet/gateway.py Log: * branching off 0.9.0 for bugfixing purposes * setting debug to true for execnet Modified: py/branch/bugfix-0.9.0/py/execnet/gateway.py ============================================================================== --- py/release/0.9.0/py/execnet/gateway.py (original) +++ py/branch/bugfix-0.9.0/py/execnet/gateway.py Fri Feb 1 22:50:56 2008 @@ -26,7 +26,7 @@ NamedThreadPool = py._thread.NamedThreadPool import os -debug = 0 # open('/tmp/execnet-debug-%d' % os.getpid() , 'wa') +debug = open('/tmp/execnet-debug-%d' % os.getpid() , 'wa') sysex = (KeyboardInterrupt, SystemExit) From hpk at codespeak.net Sat Feb 2 18:33:04 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 2 Feb 2008 18:33:04 +0100 (CET) Subject: [py-svn] r51217 - in py/branch/event/py/test2: . rsession rsession/testing testing Message-ID: <20080202173304.30C48168451@codespeak.net> Author: hpk Date: Sat Feb 2 18:33:02 2008 New Revision: 51217 Modified: py/branch/event/py/test2/collectonly.py py/branch/event/py/test2/outcome.py py/branch/event/py/test2/repevent.py py/branch/event/py/test2/reporter.py py/branch/event/py/test2/rsession/local.py py/branch/event/py/test2/rsession/master.py py/branch/event/py/test2/rsession/rest.py py/branch/event/py/test2/rsession/rsession.py py/branch/event/py/test2/rsession/testing/test_master.py py/branch/event/py/test2/rsession/testing/test_rest.py py/branch/event/py/test2/rsession/testing/test_rsession.py py/branch/event/py/test2/rsession/testing/test_webjs.py py/branch/event/py/test2/rsession/web.py py/branch/event/py/test2/rsession/webjs.py py/branch/event/py/test2/session.py py/branch/event/py/test2/testing/test_collect.py py/branch/event/py/test2/testing/test_collectonly.py py/branch/event/py/test2/testing/test_remote.py py/branch/event/py/test2/testing/test_reporter.py py/branch/event/py/test2/testing/test_session.py py/branch/event/py/test2/testing/test_session2.py Log: sorting out and renaming Events some more still all intermediate (but tests are passing) Modified: py/branch/event/py/test2/collectonly.py ============================================================================== --- py/branch/event/py/test2/collectonly.py (original) +++ py/branch/event/py/test2/collectonly.py Sat Feb 2 18:33:02 2008 @@ -11,7 +11,7 @@ super(LocalReporter, self).__init__(*args, **kwds) self.indent = 0 - def report_ReceivedItemOutcome(self, event): + def report_ItemFinish(self, event): pass def report_ItemStart(self, event): Modified: py/branch/event/py/test2/outcome.py ============================================================================== --- py/branch/event/py/test2/outcome.py (original) +++ py/branch/event/py/test2/outcome.py Sat Feb 2 18:33:02 2008 @@ -1,6 +1,6 @@ - -""" File defining possible outcomes of running and also -serialization of outcomes +""" + File defining possible outcomes of running and also + serialization of outcomes """ import py Modified: py/branch/event/py/test2/repevent.py ============================================================================== --- py/branch/event/py/test2/repevent.py (original) +++ py/branch/event/py/test2/repevent.py Sat Feb 2 18:33:02 2008 @@ -4,112 +4,118 @@ import py import time -def basic_report(msg_type, message): - print msg_type, message -# ---------------------------------------------------------------------- -# Reporting Events -# ---------------------------------------------------------------------- - -class ReportEvent(object): +class BaseEvent(object): def __repr__(self): l = ["%s=%s" %(key, value) for key, value in self.__dict__.items()] return "<%s %s>" %(self.__class__.__name__, " ".join(l),) -class ReceivedItemOutcome(ReportEvent): - def __init__(self, channel, item, outcome): - self.channel = channel - if channel: - self.host = channel.gateway.host +def timestamp(): + return time.time() + +# ---------------------------------------------------------------------- +# Basic Live Reporting Events +# ---------------------------------------------------------------------- + +class SessionStart(BaseEvent): + def __init__(self, session): + self.session = session + self.timestart = time.time() + +class SessionFinish(BaseEvent): + def __init__(self, session): + self.session = session + self.timeend = time.time() + +class CollectionStart(BaseEvent): + def __init__(self, collector): + self.collector = collector + +class CollectionFinish(BaseEvent): + def __init__(self, collector, excinfo=None): + self.collector = collector + self.excinfo = excinfo + +class DeselectedTest(BaseEvent): + def __init__(self, item, keywordexpr): self.item = item - self.outcome = outcome + self.keywordexpr = keywordexpr + +class ItemStart(BaseEvent): + def __init__(self, item): + self.item = item + self.time = timestamp() + +from outcome import Skipped +class ItemFinish(BaseEvent): + def __init__(self, item, excinfo=None): + self.item = item + self.time = timestamp() + self.excinfo = excinfo + self.passed = not excinfo + self.skipped = excinfo and excinfo.errisinstance(Skipped) + self.failed = not (self.passed or self.skipped) + +# ---------------------------------------------------------------------- +# Report of the run of a single test (might come from a disttributed run) +# ---------------------------------------------------------------------- + +class ItemTestReport(BaseEvent): + passed = failed = skipped = False + def __init__(self, trail, outcome, info=None): + self.trail = trail + assert outcome in ("passed", "failed", "skipped") + setattr(self, outcome, True) + self.outcome = outcome + self.info = info -class SendItem(ReportEvent): +# ---------------------------------------------------------------------- +# Distributed Testing Events +# ---------------------------------------------------------------------- + +class SendItem(BaseEvent): def __init__(self, channel, item): self.item = item self.channel = channel if channel: self.host = channel.gateway.host -class HostRSyncing(ReportEvent): +class HostRSyncing(BaseEvent): def __init__(self, host, root, remotepath, synced): self.host = host self.root = root self.remotepath = remotepath self.synced = synced -class HostGatewayReady(ReportEvent): +class RsyncFinished(BaseEvent): + def __init__(self): + self.time = timestamp() + +class HostGatewayReady(BaseEvent): def __init__(self, host, roots): self.host = host self.roots = roots -class HostRSyncRootReady(ReportEvent): +class HostRSyncRootReady(BaseEvent): def __init__(self, host, root): self.host = host self.root = root -class SessionStart(ReportEvent): - def __init__(self, hosts, config, roots): - self.hosts = hosts - self.roots = roots - self.timestart = time.time() - self.config = config - -class SessionFinish(ReportEvent): - def __init__(self): - self.timeend = time.time() - -class DeselectedTest(ReportEvent): - def __init__(self, item, keywordexpr): - self.item = item - self.keywordexpr = keywordexpr - -class CollectionStart(ReportEvent): - def __init__(self, collector): - self.collector = collector - -class CollectionFailure(ReportEvent): - def __init__(self, collector, excinfo): - self.excinfo = excinfo - 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 - can be used for containers - """ - def __init__(self, item): - self.item = item - -class ItemFinish(ReportEvent): - """ This class shows most of the start stuff, like directory, module, class - can be used for containers - """ - def __init__(self, item): - self.item = item - -class RsyncFinished(ReportEvent): - def __init__(self): - self.time = time.time() +# ---------------------------------------------------------------------- +# XXX Extra Events XXX +# ---------------------------------------------------------------------- -class ImmediateFailure(ReportEvent): +class ImmediateFailure(BaseEvent): def __init__(self, item, outcome): self.item = item self.outcome = outcome -class PongReceived(ReportEvent): - def __init__(self, hostid, result): - self.hostid = hostid - self.result = result - -class InterruptedExecution(ReportEvent): +class InterruptedExecution(BaseEvent): def __init__(self): - self.timeend = time.time() + self.timeend = timestamp() -class CrashedExecution(ReportEvent): +class CrashedExecution(BaseEvent): def __init__(self): - self.timeend = time.time() + self.timeend = timestamp() Modified: py/branch/event/py/test2/reporter.py ============================================================================== --- py/branch/event/py/test2/reporter.py (original) +++ py/branch/event/py/test2/reporter.py Sat Feb 2 18:33:02 2008 @@ -177,7 +177,7 @@ if self.failed_tests_outcome: self.out.sep("=", " FAILURES ") for event in self.failed_tests_outcome: - if isinstance(event, repevent.ReceivedItemOutcome): + if isinstance(event, repevent.ItemFinish): host = self.gethost(event) self.out.sep('_', "%s on %s" % (" ".join(event.item.listnames()), host)) @@ -227,7 +227,7 @@ texts = {} for event in self.skipped_tests_outcome: colitem = event.item - if isinstance(event, repevent.ReceivedItemOutcome): + if isinstance(event, repevent.ItemFinish): outcome = event.outcome text = outcome.skipped.value itemname = repr(outcome.skipped.traceback[-2]).split("\n")[0] @@ -285,7 +285,7 @@ pass # XXX: right now we do not do anything with it - def report_ReceivedItemOutcome(self, event): + def report_ItemFinish(self, event): host = event.host hostrepr = self._hostrepr(host) if event.outcome.passed: @@ -390,7 +390,7 @@ self.failed_tests_outcome.append(event) self.failed += 1 - def report_ReceivedItemOutcome(self, event): + def report_ItemFinish(self, event): if event.outcome.passed: self.passed += 1 self.out.write(".") Modified: py/branch/event/py/test2/rsession/local.py ============================================================================== --- py/branch/event/py/test2/rsession/local.py (original) +++ py/branch/event/py/test2/rsession/local.py Sat Feb 2 18:33:02 2008 @@ -64,6 +64,6 @@ if shouldstop(): return outcome = runner(item, session, reporter) - reporter(repevent.ReceivedItemOutcome(None, item, outcome)) + reporter(repevent.ItemFinish(None, item, outcome)) except StopIteration: break Modified: py/branch/event/py/test2/rsession/master.py ============================================================================== --- py/branch/event/py/test2/rsession/master.py (original) +++ py/branch/event/py/test2/rsession/master.py Sat Feb 2 18:33:02 2008 @@ -19,8 +19,14 @@ def receive_result(self, outcomestring, item): repr_outcome = ReprOutcome(outcomestring) # send finish report - self.notify(repevent.ReceivedItemOutcome( - self.channel, item, repr_outcome)) + # XXX the following should be done by outcome serializing + if repr_outcome.passed: + outcome = "passed" + elif repr_outcome.skipped: + outcome = "skipped" + else: + outcome = "failed" + self.notify(repevent.ItemTestReport(item, outcome)) def send(self, item): try: Modified: py/branch/event/py/test2/rsession/rest.py ============================================================================== --- py/branch/event/py/test2/rsession/rest.py (original) +++ py/branch/event/py/test2/rsession/rest.py Sat Feb 2 18:33:02 2008 @@ -102,7 +102,7 @@ # yet self.out.write(self.rest.render_links()) - def report_ReceivedItemOutcome(self, event): + def report_ItemFinish(self, event): host = self.gethost(event) if event.outcome.passed: status = [Strong("PASSED")] @@ -128,7 +128,7 @@ texts = {} for event in self.skipped_tests_outcome: colitem = event.item - if isinstance(event, repevent.ReceivedItemOutcome): + if isinstance(event, repevent.ItemFinish): outcome = event.outcome text = outcome.skipped itemname = self.get_item_name(event, colitem) @@ -159,7 +159,7 @@ for i, event in enumerate(self.failed_tests_outcome): if i > 0: self.add_rest(Transition()) - if isinstance(event, repevent.ReceivedItemOutcome): + if isinstance(event, repevent.ItemFinish): host = self.get_host(event) itempath = self.get_path_from_item(event.item) root = self.get_rootpath(event.item) 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 Sat Feb 2 18:33:02 2008 @@ -41,7 +41,7 @@ """ main loop for running tests. """ hm = HostManager(self.config) hub = self.config.hub - hub.notify(repevent.SessionStart(hm.hosts, self.config, hm.roots)) + hub.notify(repevent.SessionStart(self)) try: nodes = hm.setup_hosts() try: @@ -56,7 +56,7 @@ print "tearing down nodes" hm.teardown_hosts(nodes) - hub.notify(repevent.SessionFinish()) + hub.notify(repevent.SessionFinish(self)) except (KeyboardInterrupt, SystemExit): hub.notify(repevent.InterruptedExecution()) raise Modified: py/branch/event/py/test2/rsession/testing/test_master.py ============================================================================== --- py/branch/event/py/test2/rsession/testing/test_master.py (original) +++ py/branch/event/py/test2/rsession/testing/test_master.py Sat Feb 2 18:33:02 2008 @@ -68,7 +68,8 @@ ch.callback(SerializableOutcome(excinfo=excinfo).make_repr()) assert len(reportlist) == 4 received = [i for i in reportlist - if isinstance(i, repevent.ReceivedItemOutcome)] + if isinstance(i, repevent.ItemTestReport)] + py.test.skip("XXX fix master tests") assert received[0].outcome.passed assert not received[1].outcome.passed @@ -139,7 +140,7 @@ def test_slave_running(self): py.test.skip("XXX test broken, needs refactoring") def simple_report(event): - if not isinstance(event, repevent.ReceivedItemOutcome): + if not isinstance(event, repevent.ItemFinish): return item = event.item if item.code.name == 'funcpass': @@ -169,7 +170,7 @@ def test_slave_running_interrupted(): py.test.skip("XXX test broken, needs refactoring") #def simple_report(event): - # if not isinstance(event, repevent.ReceivedItemOutcome): + # if not isinstance(event, repevent.ItemFinish): # return # item = event.item # if item.code.name == 'funcpass': Modified: py/branch/event/py/test2/rsession/testing/test_rest.py ============================================================================== --- py/branch/event/py/test2/rsession/testing/test_rest.py (original) +++ py/branch/event/py/test2/rsession/testing/test_rest.py Sat Feb 2 18:33:02 2008 @@ -111,33 +111,33 @@ """ - def test_ReceivedItemOutcome_PASSED(self): + def test_ItemFinish_PASSED(self): outcome = SerializableOutcome() item = Container(listnames=lambda: ['', 'foo.py', 'bar', '()', 'baz']) - event = repevent.ReceivedItemOutcome(channel=ch, outcome=outcome, item=item) + event = repevent.ItemFinish(channel=ch, outcome=outcome, item=item) reporter.report(event) assert stdout.getvalue() == ('* localhost\\: **PASSED** ' 'foo.py/bar()/baz\n\n') - def test_ReceivedItemOutcome_SKIPPED(self): + def test_ItemFinish_SKIPPED(self): outcome = SerializableOutcome(skipped="reason") item = Container(listnames=lambda: ['', 'foo.py', 'bar', '()', 'baz']) - event = repevent.ReceivedItemOutcome(channel=ch, outcome=outcome, item=item) + event = repevent.ItemFinish(channel=ch, outcome=outcome, item=item) reporter.report(event) assert stdout.getvalue() == ('* localhost\\: **SKIPPED** ' 'foo.py/bar()/baz\n\n') - def test_ReceivedItemOutcome_FAILED(self): + def test_ItemFinish_FAILED(self): outcome = SerializableOutcome(excinfo="xxx") item = Container(listnames=lambda: ['', 'foo.py', 'bar', '()', 'baz']) - event = repevent.ReceivedItemOutcome(channel=ch, outcome=outcome, item=item) + event = repevent.ItemFinish(channel=ch, outcome=outcome, item=item) reporter.report(event) assert stdout.getvalue() == """\ * localhost\: **FAILED** `traceback0`_ foo.py/bar()/baz """ - def test_ReceivedItemOutcome_FAILED_stdout(self): + def test_ItemFinish_FAILED_stdout(self): excinfo = Container( typename='FooError', value='A foo has occurred', @@ -162,7 +162,7 @@ parent = Container(parent=None, fspath=py.path.local('.')) item = Container(listnames=lambda: ['', 'foo.py', 'bar', '()', 'baz'], parent=parent, fspath=py.path.local('foo')) - event = repevent.ReceivedItemOutcome(channel=ch, outcome=outcome, + event = repevent.ItemFinish(channel=ch, outcome=outcome, item=item) reporter.report(event) reporter.timestart = 10 @@ -175,7 +175,7 @@ assert out.find('') > -1 def test_skips(self): - class FakeOutcome(Container, repevent.ReceivedItemOutcome): + class FakeOutcome(Container, repevent.ItemFinish): pass class FakeTryiter(Container, repevent.DeselectedTest): @@ -200,7 +200,7 @@ """ def test_failures(self): - class FakeOutcome(Container, repevent.ReceivedItemOutcome): + class FakeOutcome(Container, repevent.ItemFinish): pass parent = Container(parent=None, fspath=py.path.local('.')) Modified: py/branch/event/py/test2/rsession/testing/test_rsession.py ============================================================================== --- py/branch/event/py/test2/rsession/testing/test_rsession.py (original) +++ py/branch/event/py/test2/rsession/testing/test_rsession.py Sat Feb 2 18:33:02 2008 @@ -42,7 +42,7 @@ config.hub.append(f) allevents = getevents_runmain(rsession) testevents = [x for x in allevents - if isinstance(x, repevent.ReceivedItemOutcome)] + if isinstance(x, repevent.ItemTestReport)] assert len(testevents) == 3 def test_distribution_rsync_roots_example(self): @@ -76,28 +76,15 @@ rsession = RSession(config) allevents = getevents_runmain(rsession) testevents = [x for x in allevents - if isinstance(x, repevent.ReceivedItemOutcome)] + if isinstance(x, repevent.ItemTestReport)] assert len(testevents) print testevents - passevents = [i for i in testevents if i.outcome.passed] - failevents = [i for i in testevents if i.outcome.excinfo] - skippedevents = [i for i in testevents if i.outcome.skipped] + passevents = [i for i in testevents if i.passed] + failevents = [i for i in testevents if i.failed] + skippedevents = [i for i in testevents if i.skipped] assert len(testevents) == 5 assert len(passevents) == 2 assert len(failevents) == 3 - tb = failevents[0].outcome.excinfo.traceback - assert str(tb[0].path).find("test_one") != -1 - assert tb[0].source.find("test_2") != -1 - assert failevents[0].outcome.excinfo.typename == 'AssertionError' - tb = failevents[1].outcome.excinfo.traceback - assert str(tb[0].path).find("test_one") != -1 - assert tb[0].source.find("test_3") != -1 - assert failevents[1].outcome.excinfo.typename == 'ValueError' - assert failevents[1].outcome.excinfo.value == '23' - tb = failevents[2].outcome.excinfo.traceback - assert failevents[2].outcome.excinfo.typename == 'TypeError' - assert str(tb[0].path).find("executor") != -1 - assert tb[0].source.find("execute") != -1 def test_setup_teardown_run_ssh(self): hosts = [HostInfo('localhost:%s' % self.dest)] @@ -117,20 +104,20 @@ events = [] while len(events) < 4 * len(nodes): item = queue.get(timeout=0.5) - if isinstance(item, repevent.ReceivedItemOutcome): + if isinstance(item, repevent.ItemTestReport): events.append(item) print "got all events", events hm.teardown_hosts(nodes) - passed = [i for i in events - if i.outcome.passed] - skipped = [i for i in events - if i.outcome.skipped] + passed = [ev for ev in events + if ev.passed] + skipped = [ev for ev in events + if ev.skipped] assert len(passed) == 2 * len(nodes) assert len(skipped) == len(nodes) assert len(events) == 4 * len(nodes) # one of passed for each node has non-empty stdout - passed_stdout = [i for i in passed if i.outcome.stdout.find('samfing') != -1] - assert len(passed_stdout) == len(nodes), passed + #passed_stdout = [i for i in passed if i.outcome.stdout.find('samfing') != -1] + #assert len(passed_stdout) == len(nodes), passed def test_nice_level(self): """ Tests if nice level behaviour is ok @@ -151,8 +138,8 @@ rsession = RSession(config) allevents = getevents_runmain(rsession) testevents = [x for x in allevents - if isinstance(x, repevent.ReceivedItemOutcome)] - passevents = [x for x in testevents if x.outcome.passed] + if isinstance(x, repevent.ItemTestReport)] + passevents = [x for x in testevents if x.passed] assert len(passevents) == 1 def test_rsession_no_disthost(): Modified: py/branch/event/py/test2/rsession/testing/test_webjs.py ============================================================================== --- py/branch/event/py/test2/rsession/testing/test_webjs.py (original) +++ py/branch/event/py/test2/rsession/testing/test_webjs.py Sat Feb 2 18:33:02 2008 @@ -98,7 +98,7 @@ 'length': 10, } webjs.process(msg) - msg = {'type': 'ReceivedItemOutcome', + msg = {'type': 'ItemFinish', 'fullmodulename': 'modules/foo.py', 'passed' : 'True', 'fullitemname' : 'modules/foo.py/test_item', @@ -122,7 +122,7 @@ 'length': 10, } webjs.process(msg) - msg = {'type': 'ReceivedItemOutcome', + msg = {'type': 'ItemFinish', 'fullmodulename': 'modules/foo.py', 'passed' : 'False', 'fullitemname' : 'modules/foo.py/test_item', Modified: py/branch/event/py/test2/rsession/web.py ============================================================================== --- py/branch/event/py/test2/rsession/web.py (original) +++ py/branch/event/py/test2/rsession/web.py Sat Feb 2 18:33:02 2008 @@ -207,7 +207,7 @@ self.end_event.set() return {} # some dispatcher here - if isinstance(event, repevent.ReceivedItemOutcome): + if isinstance(event, repevent.ItemFinish): args = {} outcome = event.outcome for key, val in outcome.__dict__.iteritems(): @@ -277,7 +277,7 @@ lines.append(" " + line) return lines - def report_ReceivedItemOutcome(self, event): + def report_ItemFinish(self, event): self.all += 1 self.pending_events.put(event) Modified: py/branch/event/py/test2/rsession/webjs.py ============================================================================== --- py/branch/event/py/test2/rsession/webjs.py (original) +++ py/branch/event/py/test2/rsession/webjs.py Sat Feb 2 18:33:02 2008 @@ -192,7 +192,7 @@ "#00ff00" host_elem.childNodes[0].nodeValue = '%s[0]' % ( glob.host_dict[msg['hostkey']],) - elif msg['type'] == 'ReceivedItemOutcome': + elif msg['type'] == 'ItemFinish': module_part = get_elem(msg['fullmodulename']) if not module_part: glob.pending.append(msg) Modified: py/branch/event/py/test2/session.py ============================================================================== --- py/branch/event/py/test2/session.py (original) +++ py/branch/event/py/test2/session.py Sat Feb 2 18:33:02 2008 @@ -34,8 +34,9 @@ raise except: excinfo = py.code.ExceptionInfo() - hub.notify(repevent.CollectionFailure(next, excinfo)) - hub.notify(repevent.CollectionFinish(next)) + hub.notify(repevent.CollectionFinish(next, excinfo)) + else: + hub.notify(repevent.CollectionFinish(next)) class AbstractSession(object): """ An abstract session executes collectors/items through a runner. @@ -73,7 +74,7 @@ def header(self, colitems): """ setup any neccessary resources ahead of the test run. """ - self.config.hub.notify(repevent.SessionStart(None, self.config, None)) + self.config.hub.notify(repevent.SessionStart(self)) if not self.config.option.nomagic: py.magic.invoke(assertion=1) @@ -82,7 +83,7 @@ py.test2.collect.Function._state.teardown_all() if not self.config.option.nomagic: py.magic.revoke(assertion=1) - self.config.hub.notify(repevent.SessionFinish()) + self.config.hub.notify(repevent.SessionFinish(self)) def main(self): """ main loop for running tests. """ @@ -98,7 +99,7 @@ item = itemgenerator.next() if not self.config.option.collectonly: outcome = self.run(item) - self.config.hub.notify(repevent.ReceivedItemOutcome(None, item, outcome)) + self.config.hub.notify(repevent.ItemFinish(item, outcome.excinfo)) if outcome is not None: if not outcome.passed and not outcome.skipped: failures.append((item, outcome)) Modified: py/branch/event/py/test2/testing/test_collect.py ============================================================================== --- py/branch/event/py/test2/testing/test_collect.py (original) +++ py/branch/event/py/test2/testing/test_collect.py Sat Feb 2 18:33:02 2008 @@ -3,7 +3,7 @@ from setupdata import setupdatadir from py.__.test2.outcome import Skipped, Failed, Passed, Outcome from py.__.test2.terminal.out import getout -from py.__.test2.repevent import ReceivedItemOutcome +from py.__.test2.repevent import ItemFinish def getpassed(session): hub = session.config.hub @@ -12,9 +12,8 @@ try: session.main() print all - outcomes = [i.outcome for i in all if isinstance(i, ReceivedItemOutcome)] - l = [i for i in outcomes if i.passed] - return l + passed = [i.passed for i in all if isinstance(i, ItemFinish)] + return passed finally: hub.pop() 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 Sat Feb 2 18:33:02 2008 @@ -34,7 +34,7 @@ allevents = getevents_runmain(session) started = finished = 0 for event in allevents: - assert not isinstance(event, repevent.ReceivedItemOutcome) + assert not isinstance(event, repevent.ItemFinish) if isinstance(event, repevent.CollectionStart): started += 1 elif isinstance(event, repevent.CollectionFinish): 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 Sat Feb 2 18:33:02 2008 @@ -18,7 +18,7 @@ #allevents = getevents_runmain(session) #print allevents #failures = [x for x in allevents - # if isinstance(x, repevent.ReceivedItemOutcome)] + # if isinstance(x, repevent.ItemFinish)] failures = session.main() assert failures Modified: py/branch/event/py/test2/testing/test_reporter.py ============================================================================== --- py/branch/event/py/test2/testing/test_reporter.py (original) +++ py/branch/event/py/test2/testing/test_reporter.py Sat Feb 2 18:33:02 2008 @@ -84,7 +84,7 @@ else: ch = None for outcome in outcomes: - r.report(repevent.ReceivedItemOutcome(ch, item, outcome)) + r.report(repevent.ItemFinish(ch, item, outcome)) cap = py.io.StdCaptureFD() boxfun(self.config, item, outcomes) @@ -106,7 +106,7 @@ else: ch = None for outcome in outcomes: - r.report(repevent.ReceivedItemOutcome(ch, funcitem, outcome)) + r.report(repevent.ItemFinish(ch, funcitem, outcome)) cap = py.io.StdCaptureFD() boxfun(self.config, moditem, funcitem, outcomes) Modified: py/branch/event/py/test2/testing/test_session.py ============================================================================== --- py/branch/event/py/test2/testing/test_session.py (original) +++ py/branch/event/py/test2/testing/test_session.py Sat Feb 2 18:33:02 2008 @@ -18,7 +18,7 @@ ) def getoutcomes(all): - return [i.outcome for i in all if isinstance(i, repevent.ReceivedItemOutcome)] + return [i for i in all if isinstance(i, repevent.ItemFinish)] def getpassed(all): @@ -29,8 +29,10 @@ [i for i in all if isinstance(i, repevent.DeselectedTest)] def getfailed(all): - return [i for i in getoutcomes(all) if i.excinfo] + \ - [i for i in all if isinstance(i, repevent.CollectionFailure)] + return [i for i in getoutcomes(all) if i.failed] + \ + [i for i in all + if isinstance(i, repevent.CollectionFinish) and + i.excinfo] def test_conflict_options(): for spec in conflict_options: @@ -77,7 +79,7 @@ '-s', '-k', keyword]) session = config._getsessionclass()(config) all = getevents_runmain(session) - outcomes = [i for i in all if isinstance(i, repevent.ReceivedItemOutcome)] + outcomes = [i for i in all if isinstance(i, repevent.ItemFinish)] assert len(getfailed(all)) == 1 assert outcomes[0].item.name == name l = getskipped(all) @@ -109,7 +111,7 @@ all = getevents_runmain(session) print "keyword", repr(keyword) l = getpassed(all) - outcomes = [i for i in all if isinstance(i, repevent.ReceivedItemOutcome)] + outcomes = [i for i in all if isinstance(i, repevent.ItemFinish)] assert len(l) == 1 assert outcomes[0].item.name == 'test_2' l = getskipped(all) 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 Sat Feb 2 18:33:02 2008 @@ -50,16 +50,19 @@ lsession = Session(config) allevents = getevents_runmain(lsession) testevents = [x for x in allevents - if isinstance(x, repevent.ReceivedItemOutcome)] + if isinstance(x, repevent.ItemFinish)] assert len(testevents) - passevents = [i for i in testevents if i.outcome.passed] - failevents = [i for i in testevents if i.outcome.excinfo] - skippedevents = [i for i in testevents if i.outcome.skipped] - signalevents = [i for i in testevents if i.outcome.signal] + passevents = [i for i in testevents if i.passed] + failevents = [i for i in testevents if i.failed] + skippedevents = [i for i in testevents if i.skipped] + #signalevents = [i for i in testevents if i.outcome.signal] assert len(passevents) == 1 assert len(failevents) == 3 assert len(skippedevents) == 0 #assert len(signalevents) == 1 + + return + # XXX tb = failevents[0].outcome.excinfo.traceback assert str(tb[0].path).find("test_one") != -1 assert str(tb[0].source).find("test_2") != -1 @@ -96,9 +99,9 @@ lsession = Session(config) allevents = getevents_runmain(lsession) testevents = [x for x in allevents - if isinstance(x, repevent.ReceivedItemOutcome)] + if isinstance(x, repevent.ItemFinish)] assert len(testevents) - assert testevents[0].outcome.signal + #assert testevents[0].outcome.signal def test_plain(self): self.example_distribution(False) @@ -157,7 +160,7 @@ lsession = Session(config) allevents = getevents_runmain(lsession) testevents = [x for x in allevents - if isinstance(x, repevent.ReceivedItemOutcome)] + if isinstance(x, repevent.ItemFinish)] assert len(testevents) passevents = [i for i in testevents if i.outcome.passed] failevents = [i for i in testevents if i.outcome.excinfo] @@ -185,7 +188,7 @@ allevents = getevents_runmain(lsession) testevents = [x for x in allevents - if isinstance(x, repevent.ReceivedItemOutcome)] + if isinstance(x, repevent.ItemFinish)] assert len(testevents) passevents = [i for i in testevents if i.outcome.passed] failevents = [i for i in testevents if i.outcome.excinfo] @@ -212,7 +215,7 @@ allruns = [] allevents = getevents_runmain(lsession) testevents = [x for x in allevents - if isinstance(x, repevent.ReceivedItemOutcome)] + if isinstance(x, repevent.ItemFinish)] assert len(testevents) == 4 lst = ['test_one', 'test_one_one', 'test_other', 'test_two'] for num, i in enumerate(testevents): @@ -235,7 +238,7 @@ lsession = Session(config) allevents = getevents_runmain(lsession) testevents = [x for x in allevents - if isinstance(x, repevent.ReceivedItemOutcome)] + if isinstance(x, repevent.ItemFinish)] assert len(testevents) == 0 failedtryiter = [x for x in allevents if isinstance(x, repevent.FailedTryiter)] @@ -260,7 +263,7 @@ lsession = Session(config) allevents = getevents_runmain(lsession) testevents = [x for x in allevents - if isinstance(x, repevent.ReceivedItemOutcome)] + if isinstance(x, repevent.ItemFinish)] failevents = [i for i in testevents if i.outcome.excinfo] assert len(failevents) == 1 assert len(testevents) == 1 @@ -280,7 +283,7 @@ lsession = Session(config) allevents = getevents_runmain(lsession.main) testevents = [x for x in allevents - if isinstance(x, repevent.ReceivedItemOutcome)] + if isinstance(x, repevent.ItemFinish)] assert len(testevents) == 1 assert testevents[0].outcome.passed assert testevents[0].outcome.stderr == "" From hpk at codespeak.net Sat Feb 2 21:38:03 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 2 Feb 2008 21:38:03 +0100 (CET) Subject: [py-svn] r51222 - in py/branch/event/py/test2: . rsession rsession/testing testing Message-ID: <20080202203803.F1FE116842F@codespeak.net> Author: hpk Date: Sat Feb 2 21:38:02 2008 New Revision: 51222 Removed: py/branch/event/py/test2/rsession/testing/test_master.py Modified: py/branch/event/py/test2/repevent.py py/branch/event/py/test2/rsession/hostmanage.py py/branch/event/py/test2/rsession/master.py py/branch/event/py/test2/rsession/rsession.py py/branch/event/py/test2/rsession/slave.py py/branch/event/py/test2/rsession/testing/basetest.py py/branch/event/py/test2/rsession/testing/test_hostmanage.py py/branch/event/py/test2/rsession/testing/test_rsession.py py/branch/event/py/test2/rsession/testing/test_slave.py py/branch/event/py/test2/session.py py/branch/event/py/test2/testing/test_itemgen.py py/branch/event/py/test2/testing/test_outcome.py py/branch/event/py/test2/testing/test_session2.py Log: * intermediate checkin (2 tests failing) * sharing more code between dist and local sessions * strike one layer of indirection * remove some obscure and complicated (mostly skipped) tests Modified: py/branch/event/py/test2/repevent.py ============================================================================== --- py/branch/event/py/test2/repevent.py (original) +++ py/branch/event/py/test2/repevent.py Sat Feb 2 21:38:02 2008 @@ -67,7 +67,6 @@ self.trail = trail assert outcome in ("passed", "failed", "skipped") setattr(self, outcome, True) - self.outcome = outcome self.info = info # ---------------------------------------------------------------------- @@ -75,11 +74,9 @@ # ---------------------------------------------------------------------- class SendItem(BaseEvent): - def __init__(self, channel, item): + def __init__(self, host, item): self.item = item - self.channel = channel - if channel: - self.host = channel.gateway.host + self.host = host class HostRSyncing(BaseEvent): def __init__(self, host, root, remotepath, synced): @@ -97,12 +94,15 @@ self.host = host self.roots = roots +class HostDown(BaseEvent): + def __init__(self, host): + self.host = host + class HostRSyncRootReady(BaseEvent): def __init__(self, host, root): self.host = host self.root = root - # ---------------------------------------------------------------------- # XXX Extra Events XXX # ---------------------------------------------------------------------- Modified: py/branch/event/py/test2/rsession/hostmanage.py ============================================================================== --- py/branch/event/py/test2/rsession/hostmanage.py (original) +++ py/branch/event/py/test2/rsession/hostmanage.py Sat Feb 2 21:38:02 2008 @@ -1,7 +1,6 @@ import py import sys, os from py.__.test2.rsession.master import MasterNode -from py.__.test2.rsession.slave import setup_slave from py.__.test2 import repevent class HostInfo(object): @@ -157,43 +156,41 @@ def setup_hosts(self): self.init_rsync() - nodes = [] for host in self.hosts: - if hasattr(host.gw, 'remote_exec'): # otherwise dummy for tests :/ - ch = setup_slave(host, self.config) - nodes.append(MasterNode(ch, self.config.hub.notify)) - return nodes - - def teardown_hosts(self, nodes, timeout=1.0): - return - for node in nodes: - node.channel.send(None) - clean = False - while not clean: - clean = True - for node in nodes: - if node.pending: - clean = False - # XXX magic waiting - py.std.time.sleep(0.1) - self.teardown_gateways(nodes) - - def kill_channels(self, channels): - for channel in channels: - channel.send(42) - - def teardown_gateways(self, nodes): - return - self.config.hub.notify("teardown gateways %r" %(nodes,)) - for node in nodes: - #try: - try: - node.channel.waitclose(1.0) - except IOError: # timeout - # force closing - node.channel.close() - node.channel.gateway.exit() + host.node = MasterNode(host, self.config) + def teardown_hosts(self, timeout=1.0): + # XXX teardown nodes and hosts + queue = py.std.Queue.Queue() + def hostdown(event): + if isinstance(event, repevent.HostDown): + queue.put(event) + self.config.hub.append(hostdown) + + pending_hosts = [] + for host in self.hosts: + if not host.node.channel.isclosed(): + host.node.channel.send(None) + pending_hosts.append(host) + + while pending_hosts: + event = queue.get(timeout=timeout) + if event.host not in pending_hosts: + print "got random HostDown of", event.host + else: + pending_hosts.remove(event.host) + + def trysendtest(self, item): + for host in self.hosts: + node = getattr(host, 'node', None) + if node and len(node.pending) < 15: # XXX + node.send(item) + return True + + +# +# helpers +# def gethomedir(): import os homedir = os.environ.get('HOME', '') Modified: py/branch/event/py/test2/rsession/master.py ============================================================================== --- py/branch/event/py/test2/rsession/master.py (original) +++ py/branch/event/py/test2/rsession/master.py Sat Feb 2 21:38:02 2008 @@ -6,17 +6,19 @@ from py.__.test2 import repevent class MasterNode(object): - def __init__(self, channel, notify): - self.notify = notify - self.channel = channel + def __init__(self, host, config): + self.host = host + self.config = config + self.notify = config.hub.notify + self.channel = setup_slave(host, config) + self.channel.setcallback(self._callback) self.pending = [] - channel.setcallback(self._callback) - def _callback(self, outcome): + def _callback(self, outcomestring): + if outcomestring is None: + self.notify(repevent.HostDown(self.host)) + return item = self.pending.pop() - self.receive_result(outcome, item) - - def receive_result(self, outcomestring, item): repr_outcome = ReprOutcome(outcomestring) # send finish report # XXX the following should be done by outcome serializing @@ -30,14 +32,12 @@ def send(self, item): try: - if item is StopIteration: - self.channel.send(42) + if item is None: + self.channel.send(None) else: - self.pending.insert(0, item) - #itemspec = item.listnames()[1:] self.channel.send(item._get_collector_trail()) - # send start report - self.notify(repevent.SendItem(self.channel, item)) + self.pending.insert(0, item) + self.notify(repevent.SendItem(self.host, item)) except IOError: print "Sending error, channel IOError" print self.channel._getremoteerror() @@ -45,23 +45,19 @@ # of hanging nodes and such raise -def dispatch_loop(masternodes, itemgenerator, #shouldstop, - waiter = lambda: py.std.time.sleep(0.1), - max_tasks_per_node=15): - all_tests = {} - while 1: - try: - for node in masternodes: - if len(node.pending) < max_tasks_per_node: - item = itemgenerator.next() - all_tests[item] = True - #if shouldstop(): - # for _node in masternodes: - # _node.send(StopIteration) # magic connector - # return None - node.send(item) - except StopIteration: - break - waiter() - return all_tests +# setting up slave code +from slave import setup +defaultconftestnames = ['dist_nicelevel'] +def setup_slave(host, config): + channel = host.gw.remote_exec(str(py.code.Source(setup, "setup()"))) + configrepr = config._makerepr(defaultconftestnames) + #print "sending configrepr", configrepr + topdir = host.gw_remotepath + if topdir is None: + assert host.inplacelocal + topdir = config.topdir + channel.send(str(topdir)) + channel.send(configrepr) + return channel + 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 Sat Feb 2 21:38:02 2008 @@ -1,27 +1,22 @@ - -""" Remote session base class +""" + Remote Session Base Class """ import os import py -import sys -import re -import time -from py.__.test2 import repevent -from py.__.test2.rsession.master import dispatch_loop +from py.__.test2.session import Session from py.__.test2.rsession.hostmanage import HostManager -from py.__.test2.session import AbstractSession, itemgen -class RSession(AbstractSession): - """ Remote version of session +class RSession(Session): + """ Distributing tests to remote places. """ def fixoptions(self): super(RSession, self).fixoptions() option = self.config.option if option.nocapture: print "Cannot use nocapture with distributed testing" - sys.exit(1) + py.std.sys.exit(1) config = self.config try: config.getvalue('dist_hosts') @@ -37,37 +32,20 @@ print "see also: http://codespeak.net/py/current/doc/test.html#automated-distributed-testing" raise SystemExit - def main(self): - """ main loop for running tests. """ - hm = HostManager(self.config) - hub = self.config.hub - hub.notify(repevent.SessionStart(self)) - try: - nodes = hm.setup_hosts() - try: - self.dispatch_tests(nodes) - except (KeyboardInterrupt, SystemExit): - print >>sys.stderr, "C-c pressed waiting for gateways to teardown..." - channels = [node.channel for node in nodes] - hm.kill_channels(channels) - hm.teardown_gateways(channels) - print >>sys.stderr, "... Done" - raise - - print "tearing down nodes" - hm.teardown_hosts(nodes) - hub.notify(repevent.SessionFinish(self)) - except (KeyboardInterrupt, SystemExit): - hub.notify(repevent.InterruptedExecution()) - raise - except: - hub.notify(repevent.CrashedExecution()) - raise - - def dispatch_tests(self, nodes): - colitems = self.config.getcolitems() - keyword = self.config.option.keyword - itemgenerator = itemgen(self, colitems, keyword) - max_tasks_per_node = self.config.getvalue("dist_taskspernode") - all_tests = dispatch_loop(nodes, itemgenerator, - max_tasks_per_node=max_tasks_per_node) + def setup(self): + super(RSession, self).setup() + self.hm = hm = HostManager(self.config) + self.hm.setup_hosts() + + def teardown(self): + super(RSession, self).teardown() + self.hm.teardown_hosts() + + def runtest(self, item): + # dispatch tests to host manager + sent = self.hm.trysendtest(item) + if not sent and not self.shouldstop: + self.sleepabit() + + def sleepabit(self): + py.std.time.sleep(0.1) Modified: py/branch/event/py/test2/rsession/slave.py ============================================================================== --- py/branch/event/py/test2/rsession/slave.py (original) +++ py/branch/event/py/test2/rsession/slave.py Sat Feb 2 21:38:02 2008 @@ -44,6 +44,7 @@ while 1: nextitem = receive() if nextitem is None: + send(None) break try: node = getnode(nextitem) @@ -54,28 +55,13 @@ excinfo = py.code.ExceptionInfo() send(SerializableOutcome(excinfo=excinfo, is_critical=True).make_repr()) else: + send(res) if not res[0] and not res[3] and config.option.exitfirst: - # we're finished, but need to eat what we can - send(res) break - send(res) - + # we're finished, but we should eat what we can while nextitem is not None: nextitem = receive() -defaultconftestnames = ['dist_nicelevel'] -def setup_slave(host, config): - channel = host.gw.remote_exec(str(py.code.Source(setup, "setup()"))) - configrepr = config._makerepr(defaultconftestnames) - #print "sending configrepr", configrepr - topdir = host.gw_remotepath - if topdir is None: - assert host.inplacelocal - topdir = config.topdir - channel.send(str(topdir)) - channel.send(configrepr) - return channel - def setup(): # our current dir is the topdir import os, sys Modified: py/branch/event/py/test2/rsession/testing/basetest.py ============================================================================== --- py/branch/event/py/test2/rsession/testing/basetest.py (original) +++ py/branch/event/py/test2/rsession/testing/basetest.py Sat Feb 2 21:38:02 2008 @@ -7,13 +7,13 @@ def func_source(): import py import time - def funcpass(): + def funcpassed(): pass - def funcfail(): + def funcfailed(): raise AssertionError("hello world") - def funcskip(): + def funcskipped(): py.test2.skip("skipped") def funcprint(): Modified: py/branch/event/py/test2/rsession/testing/test_hostmanage.py ============================================================================== --- py/branch/event/py/test2/rsession/testing/test_hostmanage.py (original) +++ py/branch/event/py/test2/rsession/testing/test_hostmanage.py Sat Feb 2 21:38:02 2008 @@ -268,6 +268,7 @@ print events assert 0 + def test_getpath_relto_home(): x = getpath_relto_home("hello") assert x == py.path.local._gethomedir().join("hello") Deleted: /py/branch/event/py/test2/rsession/testing/test_master.py ============================================================================== --- /py/branch/event/py/test2/rsession/testing/test_master.py Sat Feb 2 21:38:02 2008 +++ (empty file) @@ -1,198 +0,0 @@ -""" master code and test dispatching for - making 1-n master -> slave connection - and test it locally. -""" - -import time, threading -import py, sys - -if sys.platform == 'win32': - py.test.skip("rsession is unsupported on Windows.") - -from py.__.test2.rsession.master import dispatch_loop, MasterNode -from py.__.test2.rsession.slave import setup_slave -from py.__.test2.outcome import ReprOutcome, SerializableOutcome -from py.__.test2 import repevent -from py.__.test2.rsession.hostmanage import HostInfo - -def setup_module(mod): - # bind an empty config - mod.tmpdir = tmpdir = py.test2.ensuretemp(mod.__name__) - # to avoid rsyncing - config = py.test2.config._reparse([tmpdir]) - config.option.dist_taskspernode = 10 - mod.rootcol = config._getcollector(tmpdir) - -class DummyGateway(object): - def __init__(self): - self.host = HostInfo("localhost") - -class DummyChannel(object): - def __init__(self): - self.sent = [] - self.gateway = DummyGateway() - - def setcallback(self, func): - self.callback = func - - def send(self, item): - assert py.std.marshal.dumps(item) - self.sent.append(item) - -class NonWorkingChannel(object): - def setcallback(self, func): - pass - - def send(self, item): - raise IOError - - def _getremoteerror(self): - return "blah" - -class Item(py.test2.collect.Item): - def _get_collector_trail(self): - return (self.name,) - -def test_masternode(): - try: - raise ValueError() - except ValueError: - excinfo = py.code.ExceptionInfo() - - ch = DummyChannel() - reportlist = [] - mnode = MasterNode(ch, reportlist.append) - mnode.send(Item("ok")) - mnode.send(Item("notok")) - ch.callback(SerializableOutcome().make_repr()) - ch.callback(SerializableOutcome(excinfo=excinfo).make_repr()) - assert len(reportlist) == 4 - received = [i for i in reportlist - if isinstance(i, repevent.ItemTestReport)] - py.test.skip("XXX fix master tests") - assert received[0].outcome.passed - assert not received[1].outcome.passed - -def test_masternode_nonworking_channel(): - ch = NonWorkingChannel() - reportlist = [] - mnode = MasterNode(ch, reportlist.append) - cap = py.io.StdCaptureFD() - py.test2.raises(IOError, 'mnode.send(Item("ok"))') - out, err = cap.reset() - assert out.find("blah") != -1 - -def test_sending_two_noes(): - # XXX fijal: this test previously tested that the second - # item result would not get send. why? did i miss - # something? - # - ch = DummyChannel() - reportlist = [] - mnode = MasterNode(ch, reportlist.append) - mnode.send(Item("ok")) - mnode.send(Item("ok")) - ch.callback(SerializableOutcome().make_repr()) - ch.callback(SerializableOutcome().make_repr()) - assert len(reportlist) == 4 - -def test_outcome_repr(): - out = ReprOutcome(SerializableOutcome(skipped="xxx").make_repr()) - s = repr(out) - assert s.lower().find("skip") != -1 - -class DummyMasterNode(object): - def __init__(self): - self.pending = [] - - def send(self, data): - self.pending.append(data) - -def test_dispatch_loop(): - masternodes = [DummyMasterNode(), DummyMasterNode()] - itemgenerator = iter(range(100)) - shouldstop = lambda : False - def waiter(): - for node in masternodes: - node.pending.pop() - dispatch_loop(masternodes, itemgenerator, waiter=waiter) - -class TestSlave: - def setup_class(cls): - cls.tmpdir = tmpdir = py.test2.ensuretemp(cls.__name__) - cls.pkgpath = pkgpath = tmpdir.join("slavetestpkg") - pkgpath.ensure("__init__.py") - pkgpath.join("test_something.py").write(py.code.Source(""" - def funcpass(): - pass - - def funcfail(): - raise AssertionError("hello world") - """)) - cls.config = py.test2.config._reparse([tmpdir]) - assert cls.config.topdir == tmpdir - cls.rootcol = cls.config._getcollector(tmpdir) - - def _gettrail(self, *names): - item = self.rootcol._getitembynames(names) - return self.config.get_collector_trail(item) - - def test_slave_running(self): - py.test.skip("XXX test broken, needs refactoring") - def simple_report(event): - if not isinstance(event, repevent.ItemFinish): - return - item = event.item - if item.code.name == 'funcpass': - assert event.outcome.passed - else: - assert not event.outcome.passed - - def open_gw(): - gw = py.execnet.PopenGateway() - host = HostInfo("localhost") - host.gw_remotepath = '' - host.gw = gw - #gw.host.gw = gw - config = py.test2.config._reparse([tmpdir]) - channel = setup_slave(host, config) - mn = MasterNode(channel, simple_report) - return mn - - master_nodes = [open_gw(), open_gw(), open_gw()] - funcpass_item = self.xxx - funcfail_item = rootcol._getitembynames(funcfail_spec) - itemgenerator = iter([funcfail_item] + - [funcpass_item] * 5 + [funcfail_item] * 5) - shouldstop = lambda : False - dispatch_loop(master_nodes, itemgenerator, shouldstop) - -def test_slave_running_interrupted(): - py.test.skip("XXX test broken, needs refactoring") - #def simple_report(event): - # if not isinstance(event, repevent.ItemFinish): - # return - # item = event.item - # if item.code.name == 'funcpass': - # assert event.outcome.passed - # else: - # assert not event.outcome.passed - reports = [] - - def open_gw(): - gw = py.execnet.PopenGateway() - gw.host = HostInfo("localhost") - gw.host.gw = gw - config = py.test2.config._reparse([tmpdir]) - channel = setup_slave(gw.host, config) - mn = MasterNode(channel, reports.append, {}) - return mn, gw, channel - - mn, gw, channel = open_gw() - rootcol = py.test2.collect.Directory(pkgdir) - funchang_item = rootcol._getitembynames(funchang_spec) - mn.send(funchang_item) - mn.send(StopIteration) - # XXX: We have to wait here a bit to make sure that it really did happen - channel.waitclose(2) - Modified: py/branch/event/py/test2/rsession/testing/test_rsession.py ============================================================================== --- py/branch/event/py/test2/rsession/testing/test_rsession.py (original) +++ py/branch/event/py/test2/rsession/testing/test_rsession.py Sat Feb 2 21:38:02 2008 @@ -37,9 +37,6 @@ """)) config = py.test2.config._reparse([self.source.join("sub"), '-x']) rsession = RSession(config) - def f(ev): - print ev - config.hub.append(f) allevents = getevents_runmain(rsession) testevents = [x for x in allevents if isinstance(x, repevent.ItemTestReport)] @@ -92,29 +89,31 @@ queue = py.std.Queue.Queue() self.config.hub.append(queue.put) hm = HostManager(self.config, hosts=hosts) - nodes = hm.setup_hosts() + hm.setup_hosts() # actually run some tests - for node in nodes: - node.send(self.getexample("pass")) - node.send(self.getexample("fail")) - node.send(self.getexample("skip")) + for host in hm.hosts: + node = host.node + node.send(self.getexample("passed")) + node.send(self.getexample("failed")) + node.send(self.getexample("skipped")) node.send(self.getexample("print")) + num_hosts = len(hm.hosts) events = [] - while len(events) < 4 * len(nodes): + while len(events) < 4 * num_hosts: item = queue.get(timeout=0.5) if isinstance(item, repevent.ItemTestReport): events.append(item) print "got all events", events - hm.teardown_hosts(nodes) + hm.teardown_hosts() passed = [ev for ev in events if ev.passed] skipped = [ev for ev in events if ev.skipped] - assert len(passed) == 2 * len(nodes) - assert len(skipped) == len(nodes) - assert len(events) == 4 * len(nodes) + assert len(passed) == 2 * num_hosts + assert len(skipped) == num_hosts + assert len(events) == 4 * num_hosts # one of passed for each node has non-empty stdout #passed_stdout = [i for i in passed if i.outcome.stdout.find('samfing') != -1] #assert len(passed_stdout) == len(nodes), passed Modified: py/branch/event/py/test2/rsession/testing/test_slave.py ============================================================================== --- py/branch/event/py/test2/rsession/testing/test_slave.py (original) +++ py/branch/event/py/test2/rsession/testing/test_slave.py Sat Feb 2 21:38:02 2008 @@ -22,7 +22,7 @@ def test_slave_run_passing(self): node = self.gettestnode() - item = self.getexample("pass") + item = self.getexample("passed") outcome = node.execute(item._get_collector_trail()) assert outcome.passed assert not outcome.setupfailure @@ -34,12 +34,12 @@ def test_slave_run_failing(self): node = self.gettestnode() - item = self.getexample("fail") + item = self.getexample("failed") outcome = node.execute(item._get_collector_trail()) assert not outcome.passed assert not outcome.setupfailure assert len(outcome.excinfo.traceback) == 1 - assert outcome.excinfo.traceback[-1].frame.code.name == 'funcfail' + assert outcome.excinfo.traceback[-1].frame.code.name == 'funcfailed' ser = outcome.make_repr() reproutcome = ReprOutcome(ser) @@ -49,7 +49,7 @@ def test_slave_run_skipping(self): node = self.gettestnode() - item = self.getexample("skip") + item = self.getexample("skipped") outcome = node.execute(item._get_collector_trail()) assert not outcome.passed assert outcome.skipped @@ -61,7 +61,7 @@ def test_slave_run_failing_wrapped(self): node = self.gettestnode() - item = self.getexample("fail") + item = self.getexample("failed") repr_outcome = node.run(item._get_collector_trail()) outcome = ReprOutcome(repr_outcome) assert not outcome.passed Modified: py/branch/event/py/test2/session.py ============================================================================== --- py/branch/event/py/test2/session.py (original) +++ py/branch/event/py/test2/session.py Sat Feb 2 21:38:02 2008 @@ -12,38 +12,13 @@ GeneratorExit = py.builtin.GeneratorExit -def itemgen(session, colitems, keywordexpr=None): - hub = session.config.hub - stopitems = py.test2.collect.Item # XXX should be generator here as well - while colitems: - next = colitems.pop(0) - if isinstance(next, stopitems): - if next._skipbykeyword(keywordexpr): - hub.notify(repevent.DeselectedTest(next, keywordexpr)) - if session.config.option.keyword_oneshot: - keywordexpr = None - else: - yield next - else: - hub.notify(repevent.CollectionStart(next)) - try: - cols = [next.join(x) for x in next.run()] - for x in itemgen(session, cols, keywordexpr): - yield x - except (KeyboardInterrupt, SystemExit, GeneratorExit): - raise - except: - excinfo = py.code.ExceptionInfo() - hub.notify(repevent.CollectionFinish(next, excinfo)) - else: - hub.notify(repevent.CollectionFinish(next)) - -class AbstractSession(object): - """ An abstract session executes collectors/items through a runner. - """ +class Session(object): + """ + Session drives the collection and running of tests + and generates test events for reporters. + """ def __init__(self, config): self.config = config - self._keyword = config.option.keyword def fixoptions(self): """ check, fix and determine conflicting options. """ @@ -60,64 +35,87 @@ raise ValueError, "--looponfailing together with --dist not supported." if option.executable and option.usepdb: raise ValueError, "--exec together with --pdb not supported." - if option.keyword_oneshot and not option.keyword: raise ValueError, "--keyword-oneshot makes sense only when --keyword is supplied" -class Session(AbstractSession): - """ - A Session gets test Items from Collectors, executes the - Items and sends the Outcome to the Reporter. - """ - def shouldclose(self): - return False + def collect(self): + colitems = self.config.getcolitems() + keyword = self.config.option.keyword + for x in self.genitems(colitems, keyword): + yield x - def header(self, colitems): + def genitems(self, colitems, keywordexpr=None): + hub = self.config.hub + stopitems = py.test2.collect.Item + while colitems: + next = colitems.pop(0) + if isinstance(next, stopitems): + if next._skipbykeyword(keywordexpr): + hub.notify(repevent.DeselectedTest(next, keywordexpr)) + if self.config.option.keyword_oneshot: + keywordexpr = None + else: + yield next + else: + hub.notify(repevent.CollectionStart(next)) + excinfo = None + try: + cols = [next.join(x) for x in next.run()] + for x in self.genitems(cols, keywordexpr): + yield x + except (KeyboardInterrupt, SystemExit, GeneratorExit): + raise + except: + excinfo = py.code.ExceptionInfo() + hub.notify(repevent.CollectionFinish(next, excinfo)) + + def setup(self): """ setup any neccessary resources ahead of the test run. """ - self.config.hub.notify(repevent.SessionStart(self)) if not self.config.option.nomagic: py.magic.invoke(assertion=1) + self._failurelist = self._initfailurelist() - def footer(self, colitems): + def teardown(self): """ teardown any resources after a test run. """ py.test2.collect.Function._state.teardown_all() if not self.config.option.nomagic: py.magic.revoke(assertion=1) - self.config.hub.notify(repevent.SessionFinish(self)) - + return self._failurelist + + def _initfailurelist(self): + failurelist = [] + def processfailures(event): + if isinstance(event, repevent.ItemFinish) and event.failed: + failurelist.append(event) + if self.config.option.exitfirst: + self.shouldstop = True + self.config.hub.append(processfailures) + return failurelist + def main(self): """ main loop for running tests. """ - config = self.config - colitems = self.config.getcolitems() - self.header(colitems) - keyword = self.config.option.keyword - itemgenerator = itemgen(self, colitems, keyword) - failures = [] + self.shouldstop = False + self.setup() + self.config.hub.notify(repevent.SessionStart(self)) try: - while 1: - try: - item = itemgenerator.next() - if not self.config.option.collectonly: - outcome = self.run(item) - self.config.hub.notify(repevent.ItemFinish(item, outcome.excinfo)) - 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 + for item in self.collect(): + if self.shouldstop: + break + if not self.config.option.collectonly: + self.runtest(item) finally: - self.footer(colitems) + failures = self.teardown() + self.config.hub.notify(repevent.SessionFinish(self)) return failures - def run(self, item): + def runtest(self, item): if not self.config.option.boxed: executor = RunExecutor(item, config=self.config) - return ReprOutcome(executor.execute().make_repr()) + outcome = ReprOutcome(executor.execute().make_repr()) else: executor = BoxExecutor(item, config=self.config) - return ReprOutcome(executor.execute()) + outcome = ReprOutcome(executor.execute()) + self.config.hub.notify(repevent.ItemFinish(item, outcome.excinfo)) class Exit(Exception): """ for immediate program exits without tracebacks and reporter/summary. """ Modified: py/branch/event/py/test2/testing/test_itemgen.py ============================================================================== --- py/branch/event/py/test2/testing/test_itemgen.py (original) +++ py/branch/event/py/test2/testing/test_itemgen.py Sat Feb 2 21:38:02 2008 @@ -1,6 +1,5 @@ import py -from py.__.test2.session import itemgen from py.__.test2 import repevent class TestItemgen: Modified: py/branch/event/py/test2/testing/test_outcome.py ============================================================================== --- py/branch/event/py/test2/testing/test_outcome.py (original) +++ py/branch/event/py/test2/testing/test_outcome.py Sat Feb 2 21:38:02 2008 @@ -62,3 +62,9 @@ #def test_f3(): # f3() + +def test_outcome_repr(): + out = ReprOutcome(SerializableOutcome(skipped="xxx").make_repr()) + s = repr(out) + assert s.lower().find("skip") != -1 + 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 Sat Feb 2 21:38:02 2008 @@ -11,12 +11,15 @@ def getevents_runmain(session): hub = session.config.hub allevents = [] - hub.append(allevents.append) + def appendevent(event): + allevents.append(event) + print event + hub.append(appendevent) try: session.main() return allevents finally: - hub.remove(allevents.append) + hub.remove(appendevent) def setup_module(mod): From lamby at codespeak.net Tue Feb 5 12:55:01 2008 From: lamby at codespeak.net (lamby at codespeak.net) Date: Tue, 5 Feb 2008 12:55:01 +0100 (CET) Subject: [py-svn] r51285 - py/trunk/py/bin Message-ID: <20080205115501.44A5D168446@codespeak.net> Author: lamby Date: Tue Feb 5 12:55:00 2008 New Revision: 51285 Modified: py/trunk/py/bin/_docgen.py Log: Fix _docgen.py documentation building. Modified: py/trunk/py/bin/_docgen.py ============================================================================== --- py/trunk/py/bin/_docgen.py (original) +++ py/trunk/py/bin/_docgen.py Tue Feb 5 12:55:00 2008 @@ -28,7 +28,7 @@ def build_docs(targetpath, testargs): docpath = pypath.join('doc') run_tests(docpath, '', - testargs + ' --forcegen --apigenrelpath="apigen/"') + testargs + ' --forcegen --apigen="%s/apigen/apigen.py"' % (pypath,)) docpath.copy(targetpath) def build_nav(targetpath, docs=True, api=True): From fijal at codespeak.net Tue Feb 5 15:35:49 2008 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 5 Feb 2008 15:35:49 +0100 (CET) Subject: [py-svn] r51292 - py/trunk/py/test Message-ID: <20080205143549.9B77A16842C@codespeak.net> Author: fijal Date: Tue Feb 5 15:35:49 2008 New Revision: 51292 Modified: py/trunk/py/test/representation.py Log: Just another except, in order to represent source when it's not there. Modified: py/trunk/py/test/representation.py ============================================================================== --- py/trunk/py/test/representation.py (original) +++ py/trunk/py/test/representation.py Tue Feb 5 15:35:49 2008 @@ -71,8 +71,11 @@ s = str(source.getstatement(len(source)-1)) except KeyboardInterrupt: raise - except: - s = str(source[-1]) + except: + try: + s = str(source[-1]) + except IndexError: + s = "" indent = " " * (4 + (len(s) - len(s.lstrip()))) # get the real exception information out lines = excinfo.exconly(tryshort=True).split('\n') From py-svn at codespeak.net Thu Feb 7 23:55:20 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Thu, 7 Feb 2008 23:55:20 +0100 (CET) Subject: [py-svn] Monthly Newsletter - February Message-ID: <20080207061414.3577.qmail@C915CBE6.poa.virtua.com.br> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/py-svn/attachments/20080207/8b2124a7/attachment.htm From hpk at codespeak.net Fri Feb 8 09:43:07 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 8 Feb 2008 09:43:07 +0100 (CET) Subject: [py-svn] r51329 - in py/trunk/py: . apigen/tracer bin doc misc misc/testing path/local test Message-ID: <20080208084307.7CA061684CF@codespeak.net> Author: hpk Date: Fri Feb 8 09:43:05 2008 New Revision: 51329 Modified: py/trunk/py/apigen/tracer/docstorage.py py/trunk/py/bin/_docgen.py py/trunk/py/bin/_makepyrelease.py py/trunk/py/bin/_update_website.py py/trunk/py/doc/TODO.txt py/trunk/py/doc/conftest.py py/trunk/py/initpkg.py py/trunk/py/misc/_dist.py py/trunk/py/misc/testing/test_initpkg.py py/trunk/py/path/local/local.py py/trunk/py/test/reporter.py Log: rename special __package__ to __pkg__ because python 2.6 needs the former (thanks to Ralf Schmitt) Modified: py/trunk/py/apigen/tracer/docstorage.py ============================================================================== --- py/trunk/py/apigen/tracer/docstorage.py (original) +++ py/trunk/py/apigen/tracer/docstorage.py Fri Feb 8 09:43:05 2008 @@ -16,7 +16,7 @@ sorted = py.builtin.sorted def pkg_to_dict(module): - defs = module.__package__.exportdefs + defs = module.__pkg__.exportdefs d = {} for key, value in defs.iteritems(): chain = key.split('.') @@ -33,7 +33,7 @@ """ deal with '*' entries in an initpkg situation """ ret = {} modpath = py.path.local(inspect.getsourcefile(module)) - pkgpath = module.__package__.getpath() + pkgpath = module.__pkg__.getpath() for objname in dir(module): if objname.startswith('_'): continue # also skip __*__ attributes @@ -281,8 +281,8 @@ return "Lack of module info" try: retval = module.__doc__ or "*undocumented*" - retval = module.__package__.description - retval = module.__package__.long_description + retval = module.__pkg__.description + retval = module.__pkg__.long_description except AttributeError: pass return retval Modified: py/trunk/py/bin/_docgen.py ============================================================================== --- py/trunk/py/bin/_docgen.py (original) +++ py/trunk/py/bin/_docgen.py Fri Feb 8 09:43:05 2008 @@ -10,7 +10,7 @@ from _findpy import py import py -pypath = py.__package__.getpath() +pypath = py.__pkg__.getpath() def run_tests(path, envvars='', args=''): pytestpath = pypath.join('bin/py.test') Modified: py/trunk/py/bin/_makepyrelease.py ============================================================================== --- py/trunk/py/bin/_makepyrelease.py (original) +++ py/trunk/py/bin/_makepyrelease.py Fri Feb 8 09:43:05 2008 @@ -147,9 +147,9 @@ if __name__ == '__main__': py.magic.invoke(assertion=True) version = py.std.sys.argv[1] - assert py.__package__.version == version, ( + assert py.__pkg__.version == version, ( "py package has version %s\nlocation: %s" % - (py.__package__.version, pydir)) + (py.__pkg__.version, pydir)) tmpdir = py.path.local.get_temproot().join('makepyrelease-%s' % version) if tmpdir.check(): @@ -171,14 +171,14 @@ py.process.cmdexec("rsync -avz %(source)s/ %(remotedir)s" % locals()) ddir = tmpdir.ensure('download', dir=1) - URL = py.__package__.download_url # 'http://codespeak.net/download/py/' + URL = py.__pkg__.download_url # 'http://codespeak.net/download/py/' unpacked = unpackremotetar(ddir, URL) assert unpacked == ddir.join("py-%s" % (version,)) #checksvnworks(unpacked) #pytest(unpacked) - pytest_remote('test at codespeak.net', py.__package__.download_url) + pytest_remote('test at codespeak.net', py.__pkg__.download_url) Modified: py/trunk/py/bin/_update_website.py ============================================================================== --- py/trunk/py/bin/_update_website.py (original) +++ py/trunk/py/bin/_update_website.py Fri Feb 8 09:43:05 2008 @@ -24,7 +24,7 @@ def run_tests(pkgpath, apigenpath, args='', captureouterr=False): """ run the unit tests and build the docs """ - pypath = py.__package__.getpath() + pypath = py.__pkg__.getpath() pytestpath = pypath.join('bin/py.test') # XXX this would need a Windows specific version if we want to allow # running this script on that platform, but currently --apigen doesn't @@ -82,7 +82,7 @@ args.remove('--ignorefail') ignorefail = True args = ' '.join(sys.argv[1:]) - pkgpath = py.__package__.getpath() + pkgpath = py.__pkg__.getpath() apidocspath = pkgpath.dirpath().join('apigen') main(pkgpath, apidocspath, 'codespeak.net', '/home/guido/rsynctests', args, ignorefail) Modified: py/trunk/py/doc/TODO.txt ============================================================================== --- py/trunk/py/doc/TODO.txt (original) +++ py/trunk/py/doc/TODO.txt Fri Feb 8 09:43:05 2008 @@ -39,10 +39,12 @@ - refactor to produce intermediate data/files capturing info of test runs - - refactor html renderer to work on intermediate data/files rather than on the live data +- check out CodeInvestigator + http://codeinvestigator.googlepages.com/main + ld (review and shift to above) ================================= Modified: py/trunk/py/doc/conftest.py ============================================================================== --- py/trunk/py/doc/conftest.py (original) +++ py/trunk/py/doc/conftest.py Fri Feb 8 09:43:05 2008 @@ -311,7 +311,7 @@ 'to the py package') % (text,) relpath = '/'.join(text.split('/')[1:]) if check: - pkgroot = py.__package__.getpath() + pkgroot = py.__pkg__.getpath() abspath = pkgroot.join(relpath) assert pkgroot.join(relpath).check(), ( 'problem with linkrole :source:`%s`: ' Modified: py/trunk/py/initpkg.py ============================================================================== --- py/trunk/py/initpkg.py (original) +++ py/trunk/py/initpkg.py Fri Feb 8 09:43:05 2008 @@ -38,9 +38,9 @@ self.name = name self.exportdefs = exportdefs self.module = pkgmodule - assert not hasattr(pkgmodule, '__package__'), \ + assert not hasattr(pkgmodule, '__pkg__'), \ "unsupported reinitialization of %r" % pkgmodule - pkgmodule.__package__ = self + pkgmodule.__pkg__ = self # make available pkgname.__ implname = name + '.' + '__' @@ -134,7 +134,7 @@ from cStringIO import StringIO except ImportError: from StringIO import StringIO - base = py.__package__.getpath().dirpath() + base = py.__pkg__.getpath().dirpath() outf = StringIO() f = zipfile.ZipFile(outf, 'w', compression=zipfile.ZIP_DEFLATED) try: @@ -164,14 +164,14 @@ class Module(ModuleType): def __init__(self, pkg, name): - self.__package__ = pkg + self.__pkg__ = pkg self.__name__ = name self.__map__ = {} def __getattr__(self, name): if '*' in self.__map__: extpy = self.__map__['*'][0], name - result = self.__package__._resolve(extpy) + result = self.__pkg__._resolve(extpy) else: try: extpy = self.__map__[name] @@ -179,7 +179,7 @@ __tracebackhide__ = True raise AttributeError(name) else: - result = self.__package__._resolve(extpy) + result = self.__pkg__._resolve(extpy) del self.__map__[name] setattr(self, name, result) #self._fixinspection(result, name) @@ -216,7 +216,7 @@ assert not self.__map__, "%r not empty" % self.__map__ else: fsname = self.__map__['*'][0] - dict.update(self.__package__._loadimpl(fsname[:-3]).__dict__) + dict.update(self.__pkg__._loadimpl(fsname[:-3]).__dict__) return dict __dict__ = property(getdict) Modified: py/trunk/py/misc/_dist.py ============================================================================== --- py/trunk/py/misc/_dist.py (original) +++ py/trunk/py/misc/_dist.py Fri Feb 8 09:43:05 2008 @@ -144,7 +144,7 @@ params = Params(pkg) #dump(params) - source = getattr(pkg, '__package__', pkg) + source = getattr(pkg, '__pkg__', pkg) namelist = list(core.setup_keywords) namelist.extend(['packages', 'scripts', 'data_files']) for name in namelist: Modified: py/trunk/py/misc/testing/test_initpkg.py ============================================================================== --- py/trunk/py/misc/testing/test_initpkg.py (original) +++ py/trunk/py/misc/testing/test_initpkg.py Fri Feb 8 09:43:05 2008 @@ -33,7 +33,7 @@ def test_resolve_attrerror(): extpyish = "./initpkg.py", "hello" - excinfo = py.test.raises(AttributeError, "py.__package__._resolve(extpyish)") + excinfo = py.test.raises(AttributeError, "py.__pkg__._resolve(extpyish)") s = str(excinfo.value) assert s.find(extpyish[0]) != -1 assert s.find(extpyish[1]) != -1 @@ -83,16 +83,16 @@ assert __import__(modpath) def test_shahexdigest(): - hex = py.__package__.shahexdigest() + hex = py.__pkg__.shahexdigest() assert len(hex) == 40 def test_getzipdata(): - s = py.__package__.getzipdata() + s = py.__pkg__.getzipdata() def test_getrev(): if not py.path.local(py.__file__).dirpath('.svn').check(): py.test.skip("py package is not a svn checkout") - d = py.__package__.getrev() + d = py.__pkg__.getrev() svnversion = py.path.local.sysfind('svnversion') if svnversion is None: py.test.skip("cannot test svnversion, 'svnversion' binary not found") @@ -255,9 +255,9 @@ def test_url_of_version(): #py.test.skip("FAILING! - provide a proper URL or upload pylib tgz") from urllib import URLopener - url = py.__package__.download_url + url = py.__pkg__.download_url if url.lower() == "xxx": - assert py.__package__.version.find("alpha") != -1 + assert py.__pkg__.version.find("alpha") != -1 else: URLopener().open(url) Modified: py/trunk/py/path/local/local.py ============================================================================== --- py/trunk/py/path/local/local.py (original) +++ py/trunk/py/path/local/local.py Fri Feb 8 09:43:05 2008 @@ -400,8 +400,8 @@ self._prependsyspath(pkgpath.dirpath()) pkg = __import__(pkgpath.basename, None, None, []) - if hasattr(pkg, '__package__'): - modname = pkg.__package__.getimportname(self) + if hasattr(pkg, '__pkg__'): + modname = pkg.__pkg__.getimportname(self) assert modname is not None, "package %s doesn't know %s" % ( pkg.__name__, self) Modified: py/trunk/py/test/reporter.py ============================================================================== --- py/trunk/py/test/reporter.py (original) +++ py/trunk/py/test/reporter.py Fri Feb 8 09:43:05 2008 @@ -356,7 +356,7 @@ self.timestart = item.timestart self.out.line("executable: %s (%s)" % (py.std.sys.executable, repr_pythonversion())) - rev = py.__package__.getrev() + rev = py.__pkg__.getrev() self.out.line("using py lib: %s " % ( py.path.local(py.__file__).dirpath(), rev)) config = item.config From hpk at codespeak.net Fri Feb 8 09:48:32 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 8 Feb 2008 09:48:32 +0100 (CET) Subject: [py-svn] r51330 - in py/branch/bugfix-0.9.0/py: . apigen/tracer bin doc misc misc/testing path/local test/terminal Message-ID: <20080208084832.EB5901684E6@codespeak.net> Author: hpk Date: Fri Feb 8 09:48:31 2008 New Revision: 51330 Modified: py/branch/bugfix-0.9.0/py/apigen/tracer/docstorage.py py/branch/bugfix-0.9.0/py/bin/_docgen.py py/branch/bugfix-0.9.0/py/bin/_makepyrelease.py py/branch/bugfix-0.9.0/py/bin/_update_website.py py/branch/bugfix-0.9.0/py/doc/conftest.py py/branch/bugfix-0.9.0/py/initpkg.py py/branch/bugfix-0.9.0/py/misc/_dist.py py/branch/bugfix-0.9.0/py/misc/testing/test_initpkg.py py/branch/bugfix-0.9.0/py/path/local/local.py py/branch/bugfix-0.9.0/py/test/terminal/terminal.py Log: * backport 51329 from trunk (rename __package__ to __pkg__) Modified: py/branch/bugfix-0.9.0/py/apigen/tracer/docstorage.py ============================================================================== --- py/branch/bugfix-0.9.0/py/apigen/tracer/docstorage.py (original) +++ py/branch/bugfix-0.9.0/py/apigen/tracer/docstorage.py Fri Feb 8 09:48:31 2008 @@ -16,7 +16,7 @@ sorted = py.builtin.sorted def pkg_to_dict(module): - defs = module.__package__.exportdefs + defs = module.__pkg__.exportdefs d = {} for key, value in defs.iteritems(): chain = key.split('.') @@ -33,7 +33,7 @@ """ deal with '*' entries in an initpkg situation """ ret = {} modpath = py.path.local(inspect.getsourcefile(module)) - pkgpath = module.__package__.getpath() + pkgpath = module.__pkg__.getpath() for objname in dir(module): if objname.startswith('_'): continue # also skip __*__ attributes @@ -281,8 +281,8 @@ return "Lack of module info" try: retval = module.__doc__ or "*undocumented*" - retval = module.__package__.description - retval = module.__package__.long_description + retval = module.__pkg__.description + retval = module.__pkg__.long_description except AttributeError: pass return retval Modified: py/branch/bugfix-0.9.0/py/bin/_docgen.py ============================================================================== --- py/branch/bugfix-0.9.0/py/bin/_docgen.py (original) +++ py/branch/bugfix-0.9.0/py/bin/_docgen.py Fri Feb 8 09:48:31 2008 @@ -10,7 +10,7 @@ from _findpy import py import py -pypath = py.__package__.getpath() +pypath = py.__pkg__.getpath() def run_tests(path, envvars='', args=''): pytestpath = pypath.join('bin/py.test') Modified: py/branch/bugfix-0.9.0/py/bin/_makepyrelease.py ============================================================================== --- py/branch/bugfix-0.9.0/py/bin/_makepyrelease.py (original) +++ py/branch/bugfix-0.9.0/py/bin/_makepyrelease.py Fri Feb 8 09:48:31 2008 @@ -147,9 +147,9 @@ if __name__ == '__main__': py.magic.invoke(assertion=True) version = py.std.sys.argv[1] - assert py.__package__.version == version, ( + assert py.__pkg__.version == version, ( "py package has version %s\nlocation: %s" % - (py.__package__.version, pydir)) + (py.__pkg__.version, pydir)) tmpdir = py.path.local.get_temproot().join('makepyrelease-%s' % version) if tmpdir.check(): @@ -171,14 +171,14 @@ py.process.cmdexec("rsync -avz %(source)s/ %(remotedir)s" % locals()) ddir = tmpdir.ensure('download', dir=1) - URL = py.__package__.download_url # 'http://codespeak.net/download/py/' + URL = py.__pkg__.download_url # 'http://codespeak.net/download/py/' unpacked = unpackremotetar(ddir, URL) assert unpacked == ddir.join("py-%s" % (version,)) #checksvnworks(unpacked) #pytest(unpacked) - pytest_remote('test at codespeak.net', py.__package__.download_url) + pytest_remote('test at codespeak.net', py.__pkg__.download_url) Modified: py/branch/bugfix-0.9.0/py/bin/_update_website.py ============================================================================== --- py/branch/bugfix-0.9.0/py/bin/_update_website.py (original) +++ py/branch/bugfix-0.9.0/py/bin/_update_website.py Fri Feb 8 09:48:31 2008 @@ -24,7 +24,7 @@ def run_tests(pkgpath, apigenpath, args='', captureouterr=False): """ run the unit tests and build the docs """ - pypath = py.__package__.getpath() + pypath = py.__pkg__.getpath() pytestpath = pypath.join('bin/py.test') # XXX this would need a Windows specific version if we want to allow # running this script on that platform, but currently --apigen doesn't @@ -82,7 +82,7 @@ args.remove('--ignorefail') ignorefail = True args = ' '.join(sys.argv[1:]) - pkgpath = py.__package__.getpath() + pkgpath = py.__pkg__.getpath() apidocspath = pkgpath.dirpath().join('apigen') main(pkgpath, apidocspath, 'codespeak.net', '/home/guido/rsynctests', args, ignorefail) Modified: py/branch/bugfix-0.9.0/py/doc/conftest.py ============================================================================== --- py/branch/bugfix-0.9.0/py/doc/conftest.py (original) +++ py/branch/bugfix-0.9.0/py/doc/conftest.py Fri Feb 8 09:48:31 2008 @@ -310,7 +310,7 @@ 'to the py package') % (text,) relpath = '/'.join(text.split('/')[1:]) if check: - pkgroot = py.__package__.getpath() + pkgroot = py.__pkg__.getpath() abspath = pkgroot.join(relpath) assert pkgroot.join(relpath).check(), ( 'problem with linkrole :source:`%s`: ' Modified: py/branch/bugfix-0.9.0/py/initpkg.py ============================================================================== --- py/branch/bugfix-0.9.0/py/initpkg.py (original) +++ py/branch/bugfix-0.9.0/py/initpkg.py Fri Feb 8 09:48:31 2008 @@ -38,9 +38,9 @@ self.name = name self.exportdefs = exportdefs self.module = pkgmodule - assert not hasattr(pkgmodule, '__package__'), \ + assert not hasattr(pkgmodule, '__pkg__'), \ "unsupported reinitialization of %r" % pkgmodule - pkgmodule.__package__ = self + pkgmodule.__pkg__ = self # make available pkgname.__ implname = name + '.' + '__' @@ -134,7 +134,7 @@ from cStringIO import StringIO except ImportError: from StringIO import StringIO - base = py.__package__.getpath().dirpath() + base = py.__pkg__.getpath().dirpath() outf = StringIO() f = zipfile.ZipFile(outf, 'w', compression=zipfile.ZIP_DEFLATED) try: @@ -164,14 +164,14 @@ class Module(ModuleType): def __init__(self, pkg, name): - self.__package__ = pkg + self.__pkg__ = pkg self.__name__ = name self.__map__ = {} def __getattr__(self, name): if '*' in self.__map__: extpy = self.__map__['*'][0], name - result = self.__package__._resolve(extpy) + result = self.__pkg__._resolve(extpy) else: try: extpy = self.__map__[name] @@ -179,7 +179,7 @@ __tracebackhide__ = True raise AttributeError(name) else: - result = self.__package__._resolve(extpy) + result = self.__pkg__._resolve(extpy) del self.__map__[name] setattr(self, name, result) #self._fixinspection(result, name) @@ -216,7 +216,7 @@ assert not self.__map__, "%r not empty" % self.__map__ else: fsname = self.__map__['*'][0] - dict.update(self.__package__._loadimpl(fsname[:-3]).__dict__) + dict.update(self.__pkg__._loadimpl(fsname[:-3]).__dict__) return dict __dict__ = property(getdict) Modified: py/branch/bugfix-0.9.0/py/misc/_dist.py ============================================================================== --- py/branch/bugfix-0.9.0/py/misc/_dist.py (original) +++ py/branch/bugfix-0.9.0/py/misc/_dist.py Fri Feb 8 09:48:31 2008 @@ -144,7 +144,7 @@ params = Params(pkg) #dump(params) - source = getattr(pkg, '__package__', pkg) + source = getattr(pkg, '__pkg__', pkg) namelist = list(core.setup_keywords) namelist.extend(['packages', 'scripts', 'data_files']) for name in namelist: Modified: py/branch/bugfix-0.9.0/py/misc/testing/test_initpkg.py ============================================================================== --- py/branch/bugfix-0.9.0/py/misc/testing/test_initpkg.py (original) +++ py/branch/bugfix-0.9.0/py/misc/testing/test_initpkg.py Fri Feb 8 09:48:31 2008 @@ -33,7 +33,7 @@ def test_resolve_attrerror(): extpyish = "./initpkg.py", "hello" - excinfo = py.test.raises(AttributeError, "py.__package__._resolve(extpyish)") + excinfo = py.test.raises(AttributeError, "py.__pkg__._resolve(extpyish)") s = str(excinfo.value) assert s.find(extpyish[0]) != -1 assert s.find(extpyish[1]) != -1 @@ -83,16 +83,16 @@ assert __import__(modpath) def test_shahexdigest(): - hex = py.__package__.shahexdigest() + hex = py.__pkg__.shahexdigest() assert len(hex) == 40 def test_getzipdata(): - s = py.__package__.getzipdata() + s = py.__pkg__.getzipdata() def test_getrev(): if not py.path.local(py.__file__).dirpath('.svn').check(): py.test.skip("py package is not a svn checkout") - d = py.__package__.getrev() + d = py.__pkg__.getrev() svnversion = py.path.local.sysfind('svnversion') if svnversion is None: py.test.skip("cannot test svnversion, 'svnversion' binary not found") @@ -255,5 +255,5 @@ def test_url_of_version(): py.test.skip("FAILING! - provide a proper URL or upload pylib tgz") from urllib import URLopener - URLopener().open(py.__package__.download_url) + URLopener().open(py.__pkg__.download_url) Modified: py/branch/bugfix-0.9.0/py/path/local/local.py ============================================================================== --- py/branch/bugfix-0.9.0/py/path/local/local.py (original) +++ py/branch/bugfix-0.9.0/py/path/local/local.py Fri Feb 8 09:48:31 2008 @@ -401,8 +401,8 @@ self._prependsyspath(pkgpath.dirpath()) pkg = __import__(pkgpath.basename, None, None, []) - if hasattr(pkg, '__package__'): - modname = pkg.__package__.getimportname(self) + if hasattr(pkg, '__pkg__'): + modname = pkg.__pkg__.getimportname(self) assert modname is not None, "package %s doesn't know %s" % ( pkg.__name__, self) Modified: py/branch/bugfix-0.9.0/py/test/terminal/terminal.py ============================================================================== --- py/branch/bugfix-0.9.0/py/test/terminal/terminal.py (original) +++ py/branch/bugfix-0.9.0/py/test/terminal/terminal.py Fri Feb 8 09:48:31 2008 @@ -129,7 +129,7 @@ #self.out.line("testing-mode: %s" % mode) self.out.line("executable: %s (%s)" % (py.std.sys.executable, repr_pythonversion())) - rev = py.__package__.getrev() + rev = py.__pkg__.getrev() self.out.line("using py lib: %s " % ( py.path.local(py.__file__).dirpath(), rev)) From py-svn at codespeak.net Fri Feb 8 20:50:06 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Fri, 8 Feb 2008 20:50:06 +0100 (CET) Subject: SALE 73% OFF on VIAGRAŽ Message-ID: <20080208075002.13369.qmail@host86-144-105-31.range86-144.btcentralplus.com> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/py-svn/attachments/20080208/bfc83a90/attachment.htm From guido at codespeak.net Mon Feb 11 13:12:19 2008 From: guido at codespeak.net (guido at codespeak.net) Date: Mon, 11 Feb 2008 13:12:19 +0100 (CET) Subject: [py-svn] r51381 - py/branch/guido-svn-auth Message-ID: <20080211121219.39E651683E5@codespeak.net> Author: guido Date: Mon Feb 11 13:12:18 2008 New Revision: 51381 Added: py/branch/guido-svn-auth/ - copied from r51380, py/trunk/ Log: Creating branch to work on auth support for py.path.svn*. From hpk at codespeak.net Mon Feb 11 20:58:08 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 11 Feb 2008 20:58:08 +0100 (CET) Subject: [py-svn] r51396 - py/branch/event/py/test2/testing Message-ID: <20080211195808.54553168405@codespeak.net> Author: hpk Date: Mon Feb 11 20:58:07 2008 New Revision: 51396 Removed: py/branch/event/py/test2/testing/example1.py py/branch/event/py/test2/testing/example2.py Modified: py/branch/event/py/test2/testing/test_boxing.py py/branch/event/py/test2/testing/test_executor.py Log: remove or inline example test data Deleted: /py/branch/event/py/test2/testing/example1.py ============================================================================== --- /py/branch/event/py/test2/testing/example1.py Mon Feb 11 20:58:07 2008 +++ (empty file) @@ -1,12 +0,0 @@ - -def f1(): - f2() - -def f2(): - pass - -def g1(): - g2() - -def g2(): - raise ValueError() Deleted: /py/branch/event/py/test2/testing/example2.py ============================================================================== --- /py/branch/event/py/test2/testing/example2.py Mon Feb 11 20:58:07 2008 +++ (empty file) @@ -1,30 +0,0 @@ - -""" some example for running box stuff inside -""" - -import sys -import py, os - -def boxf1(): - print "some out" - print >>sys.stderr, "some err" - return 1 - -def boxf2(): - os.write(1, "someout") - os.write(2, "someerr") - return 2 - -def boxseg(): - os.kill(os.getpid(), 11) - -def boxhuge(): - os.write(1, " " * 10000) - os.write(2, " " * 10000) - os.write(1, " " * 10000) - - os.write(1, " " * 10000) - os.write(2, " " * 10000) - os.write(2, " " * 10000) - os.write(1, " " * 10000) - return 3 Modified: py/branch/event/py/test2/testing/test_boxing.py ============================================================================== --- py/branch/event/py/test2/testing/test_boxing.py (original) +++ py/branch/event/py/test2/testing/test_boxing.py Mon Feb 11 20:58:07 2008 @@ -8,7 +8,6 @@ py.test.skip("rsession is unsupported on Windows.") from py.__.test2.box import Box -from py.__.test2.testing import example2 def setup_module(mod): tmpdir = py.test2.ensuretemp("boxtests") @@ -18,7 +17,7 @@ # XXX: because we do not have option transfer ## if not hasattr(option, 'nocapture') or not option.nocapture: ## py.test.skip("Interacts with pylib i/o skipping which is bad actually") - b = Box(example2.boxf1, config=config) + b = Box(boxf1, config=config) b.run() assert b.stdoutrepr == "some out\n" assert b.stderrrepr == "some err\n" @@ -27,7 +26,7 @@ assert b.retval == 1 def test_boxing_on_fds(): - b = Box(example2.boxf2, config=config) + b = Box(boxf2, config=config) b.run() assert b.stdoutrepr == "someout" assert b.stderrrepr == "someerr" @@ -36,7 +35,7 @@ assert b.retval == 2 def test_boxing_signal(): - b = Box(example2.boxseg, config=config) + b = Box(boxseg, config=config) b.run() assert b.retval is None if py.std.sys.version_info < (2,4): @@ -44,7 +43,7 @@ assert b.signal == 11 def test_boxing_huge_data(): - b = Box(example2.boxhuge, config=config) + b = Box(boxhuge, config=config) b.run() assert b.stdoutrepr assert b.exitstat == 0 @@ -54,7 +53,7 @@ def test_box_seq(): # we run many boxes with huge data, just one after another for i in xrange(100): - b = Box(example2.boxhuge, config=config) + b = Box(boxhuge, config=config) b.run() assert b.stdoutrepr assert b.exitstat == 0 @@ -63,7 +62,7 @@ def test_box_in_a_box(): def boxfun(): - b = Box(example2.boxf2, config=config) + b = Box(boxf2, config=config) b.run() print b.stdoutrepr print >>sys.stderr, b.stderrrepr @@ -93,3 +92,33 @@ if py.std.sys.version_info < (2,4): py.test.skip("signal detection does not work with python prior 2.4") assert b.signal == 15 + + +# ====================================================================== +# examples +# ====================================================================== +# + +def boxf1(): + print "some out" + print >>sys.stderr, "some err" + return 1 + +def boxf2(): + os.write(1, "someout") + os.write(2, "someerr") + return 2 + +def boxseg(): + os.kill(os.getpid(), 11) + +def boxhuge(): + os.write(1, " " * 10000) + os.write(2, " " * 10000) + os.write(1, " " * 10000) + + os.write(1, " " * 10000) + os.write(2, " " * 10000) + os.write(2, " " * 10000) + os.write(1, " " * 10000) + return 3 Modified: py/branch/event/py/test2/testing/test_executor.py ============================================================================== --- py/branch/event/py/test2/testing/test_executor.py (original) +++ py/branch/event/py/test2/testing/test_executor.py Mon Feb 11 20:58:07 2008 @@ -1,6 +1,5 @@ import py -import example1 from py.__.test2.executor import RunExecutor, BoxExecutor,\ AsyncExecutor, ApigenExecutor From hpk at codespeak.net Mon Feb 11 21:02:37 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 11 Feb 2008 21:02:37 +0100 (CET) Subject: [py-svn] r51397 - py/branch/event/py/test2/rsession Message-ID: <20080211200237.8A34C168405@codespeak.net> Author: hpk Date: Mon Feb 11 21:02:36 2008 New Revision: 51397 Modified: py/branch/event/py/test2/rsession/hostmanage.py Log: cleanup import Modified: py/branch/event/py/test2/rsession/hostmanage.py ============================================================================== --- py/branch/event/py/test2/rsession/hostmanage.py (original) +++ py/branch/event/py/test2/rsession/hostmanage.py Mon Feb 11 21:02:36 2008 @@ -1,12 +1,10 @@ import py -import sys, os +import os from py.__.test2.rsession.master import MasterNode from py.__.test2 import repevent class HostInfo(object): - """ Class trying to store all necessary attributes - for host - """ + """ Host location representation for distributed testing. """ _hostname2list = {} def __init__(self, spec, addrel=""): From hpk at codespeak.net Mon Feb 11 21:03:19 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 11 Feb 2008 21:03:19 +0100 (CET) Subject: [py-svn] r51398 - py/branch/event/py/test2/testing Message-ID: <20080211200319.C9119168405@codespeak.net> Author: hpk Date: Mon Feb 11 21:03:17 2008 New Revision: 51398 Removed: py/branch/event/py/test2/testing/test_collectonly.py py/branch/event/py/test2/testing/test_raises.py Modified: py/branch/event/py/test2/testing/test_collect.py py/branch/event/py/test2/testing/test_outcome.py Log: merge test files a bit Modified: py/branch/event/py/test2/testing/test_collect.py ============================================================================== --- py/branch/event/py/test2/testing/test_collect.py (original) +++ py/branch/event/py/test2/testing/test_collect.py Mon Feb 11 21:03:17 2008 @@ -4,6 +4,8 @@ from py.__.test2.outcome import Skipped, Failed, Passed, Outcome from py.__.test2.terminal.out import getout from py.__.test2.repevent import ItemFinish +from test_session import getevents_runmain +from py.__.test2 import repevent def getpassed(session): hub = session.config.hub @@ -474,5 +476,41 @@ col = py.test2.collect.Directory(tmpdir) names = col.run() assert names == fnames + +class TestCollectonly: + def setup_class(cls): + tmp = py.test2.ensuretemp('itemgentest') + tmp.ensure("__init__.py") + tmp.ensure("test_one.py").write(py.code.Source(""" + def test_one(): + pass + + class TestX: + def test_method_one(self): + pass + + class TestY(TestX): + pass + """)) + tmp.ensure("test_two.py").write(py.code.Source(""" + import py + py.test.skip('xxx') + """)) + tmp.ensure("test_three.py").write("xxxdsadsadsadsa") + cls.tmp = tmp + + def test_collectonly(s