From hpk at codespeak.net Fri Jan 4 19:14:11 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 4 Jan 2008 19:14:11 +0100 (CET) Subject: [py-svn] r50332 - py/branch/dist-doctest Message-ID: <20080104181411.A14C716843C@codespeak.net> Author: hpk Date: Fri Jan 4 19:14:11 2008 New Revision: 50332 Removed: py/branch/dist-doctest/ Log: remove unused branch From hpk at codespeak.net Fri Jan 4 19:20:02 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 4 Jan 2008 19:20:02 +0100 (CET) Subject: [py-svn] r50333 - py/branch/apigen Message-ID: <20080104182002.AB25A16843F@codespeak.net> Author: hpk Date: Fri Jan 4 19:20:02 2008 New Revision: 50333 Removed: py/branch/apigen/ Log: remove merged branch From hpk at codespeak.net Fri Jan 4 19:40:47 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 4 Jan 2008 19:40:47 +0100 (CET) Subject: [py-svn] r50336 - in py/branch: distributed rsession-cleanup session-cleanups test2 Message-ID: <20080104184047.B5D7B16844F@codespeak.net> Author: hpk Date: Fri Jan 4 19:40:45 2008 New Revision: 50336 Removed: py/branch/distributed/ py/branch/rsession-cleanup/ py/branch/session-cleanups/ py/branch/test2/ Log: remove more unused branches From hpk at codespeak.net Fri Jan 4 19:44:53 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 4 Jan 2008 19:44:53 +0100 (CET) Subject: [py-svn] r50337 - py/branch/session-merge Message-ID: <20080104184453.A01B016844F@codespeak.net> Author: hpk Date: Fri Jan 4 19:44:53 2008 New Revision: 50337 Removed: py/branch/session-merge/ Log: another ones bites From py-svn at codespeak.net Sat Jan 5 19:51:37 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Sat, 5 Jan 2008 19:51:37 +0100 (CET) Subject: [py-svn] Your Featured Products for the Week‏ Message-ID: <20080106185138.2819.qmail@c5853.149.sinor.ru> An HTML attachment was scrubbed... URL: From arigo at codespeak.net Mon Jan 14 10:38:24 2008 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 14 Jan 2008 10:38:24 +0100 (CET) Subject: [py-svn] r50576 - py/trunk/py/c-extension/greenlet Message-ID: <20080114093824.2CEFD168536@codespeak.net> Author: arigo Date: Mon Jan 14 10:38:23 2008 New Revision: 50576 Added: py/trunk/py/c-extension/greenlet/switch_mips_unix.h (contents, props changed) Modified: py/trunk/py/c-extension/greenlet/slp_platformselect.h Log: This patch by Thiemo Seufer adds support for mips and mipsel. Modified: py/trunk/py/c-extension/greenlet/slp_platformselect.h ============================================================================== --- py/trunk/py/c-extension/greenlet/slp_platformselect.h (original) +++ py/trunk/py/c-extension/greenlet/slp_platformselect.h Mon Jan 14 10:38:23 2008 @@ -18,4 +18,6 @@ #include "switch_s390_unix.h" /* Linux/S390 */ #elif defined(__GNUC__) && defined(__s390x__) && defined(__linux__) #include "switch_s390_unix.h" /* Linux/S390 zSeries (identical) */ +#elif defined(__GNUC__) && defined(__mips__) && defined(__linux__) +#include "switch_mips_unix.h" /* Linux/MIPS */ #endif Added: py/trunk/py/c-extension/greenlet/switch_mips_unix.h ============================================================================== --- (empty file) +++ py/trunk/py/c-extension/greenlet/switch_mips_unix.h Mon Jan 14 10:38:23 2008 @@ -0,0 +1,56 @@ +/* + * this is the internal transfer function. + * + * HISTORY + * 05-Jan-08 Thiemo Seufer + * Ported from ppc. + */ + +#define STACK_REFPLUS 1 + +#ifdef SLP_EVAL + +#define STACK_MAGIC 0 + +#ifdef __mips64 +#define REGS_TO_SAVE "$16", "$17", "$18", "$19", "$20", "$21", "$22", \ + "$23", "$28", "$30" +#else +#define REGS_TO_SAVE "$16", "$17", "$18", "$19", "$20", "$21", "$22", \ + "$23", "$30" +#endif +static int +slp_switch(void) +{ + register int *stackref, stsizediff; + __asm__ __volatile__ ("" : : : REGS_TO_SAVE); + __asm__ ("move %0, $29" : "=r" (stackref) : ); + { + SLP_SAVE_STATE(stackref, stsizediff); + __asm__ __volatile__ ( +#ifdef __mips64 + "daddu $29, %0\n" +#else + "addu $29, %0\n" +#endif + : /* no outputs */ + : "r" (stsizediff) + ); + SLP_RESTORE_STATE(); + } + __asm__ __volatile__ ("" : : : REGS_TO_SAVE); + return 0; +} + +#endif + +/* + * further self-processing support + */ + +/* + * if you want to add self-inspection tools, place them + * here. See the x86_msvc for the necessary defines. + * These features are highly experimental und not + * essential yet. + */ From hpk at codespeak.net Mon Jan 14 17:43:08 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 14 Jan 2008 17:43:08 +0100 (CET) Subject: [py-svn] r50606 - py/trunk/py/doc Message-ID: <20080114164308.BFCBC168565@codespeak.net> Author: hpk Date: Mon Jan 14 17:43:08 2008 New Revision: 50606 Modified: py/trunk/py/doc/conftest.py Log: don't fail for links to html files where we don'T have a .txt Modified: py/trunk/py/doc/conftest.py ============================================================================== --- py/trunk/py/doc/conftest.py (original) +++ py/trunk/py/doc/conftest.py Mon Jan 14 17:43:08 2008 @@ -240,8 +240,9 @@ fn = ishtml and fn.new(ext='.txt') or fn print "filename is", fn if not fn.check(): # not ishtml or not fn.check(): - py.test.fail("reference error %r in %s:%d" %( - tryfn, path.basename, lineno+1)) + if not py.path.local(tryfn).check(): # the html could be there + py.test.fail("reference error %r in %s:%d" %( + tryfn, path.basename, lineno+1)) if anchor: source = unicode(fn.read(), 'latin1') source = source.lower().replace('-', ' ') # aehem From hpk at codespeak.net Mon Jan 14 17:43:39 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 14 Jan 2008 17:43:39 +0100 (CET) Subject: [py-svn] r50607 - py/dist/py/doc Message-ID: <20080114164339.32679168565@codespeak.net> Author: hpk Date: Mon Jan 14 17:43:38 2008 New Revision: 50607 Modified: py/dist/py/doc/conftest.py Log: html-link fix 50606 to dist Modified: py/dist/py/doc/conftest.py ============================================================================== --- py/dist/py/doc/conftest.py (original) +++ py/dist/py/doc/conftest.py Mon Jan 14 17:43:38 2008 @@ -240,8 +240,9 @@ fn = ishtml and fn.new(ext='.txt') or fn print "filename is", fn if not fn.check(): # not ishtml or not fn.check(): - py.test.fail("reference error %r in %s:%d" %( - tryfn, path.basename, lineno+1)) + if not py.path.local(tryfn).check(): # the html could be there + py.test.fail("reference error %r in %s:%d" %( + tryfn, path.basename, lineno+1)) if anchor: source = unicode(fn.read(), 'latin1') source = source.lower().replace('-', ' ') # aehem From arigo at codespeak.net Tue Jan 15 18:46:56 2008 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 15 Jan 2008 18:46:56 +0100 (CET) Subject: [py-svn] r50645 - py/trunk/py/tool Message-ID: <20080115174656.44ED5168566@codespeak.net> Author: arigo Date: Tue Jan 15 18:46:55 2008 New Revision: 50645 Modified: py/trunk/py/tool/utestconvert.py Log: Fix for "utestconvert.py < input". Modified: py/trunk/py/tool/utestconvert.py ============================================================================== --- py/trunk/py/tool/utestconvert.py (original) +++ py/trunk/py/tool/utestconvert.py Tue Jan 15 18:46:55 2008 @@ -225,7 +225,7 @@ if not args: s = '' - for block in blocksplitter(sys.stdin.read()): + for block in blocksplitter(sys.stdin): s += rewrite_utest(block) sys.stdout.write(s) From fijal at codespeak.net Fri Jan 18 17:31:09 2008 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 18 Jan 2008 17:31:09 +0100 (CET) Subject: [py-svn] r50754 - py/branch/reporter-merge/py/code Message-ID: <20080118163109.7B509169E3D@codespeak.net> Author: fijal Date: Fri Jan 18 17:31:07 2008 New Revision: 50754 Modified: py/branch/reporter-merge/py/code/source.py Log: Fix a "problem" with pypy compiler which caused py.test -A to take forever. Modified: py/branch/reporter-merge/py/code/source.py ============================================================================== --- py/branch/reporter-merge/py/code/source.py (original) +++ py/branch/reporter-merge/py/code/source.py Fri Jan 18 17:31:07 2008 @@ -109,7 +109,7 @@ for start in range(lineno, -1, -1): trylines = self.lines[start:lineno+1] # quick hack to indent the source and get it as a string in one go - trylines.insert(0, 'if 0:') + trylines.insert(0, 'def xxx():') trysource = '\n '.join(trylines) # ^ space here try: From fijal at codespeak.net Fri Jan 18 17:35:33 2008 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 18 Jan 2008 17:35:33 +0100 (CET) Subject: [py-svn] r50755 - py/trunk/py/code Message-ID: <20080118163533.6639E169E3D@codespeak.net> Author: fijal Date: Fri Jan 18 17:35:33 2008 New Revision: 50755 Modified: py/trunk/py/code/source.py Log: Port from reporter-merge branch. Modified: py/trunk/py/code/source.py ============================================================================== --- py/trunk/py/code/source.py (original) +++ py/trunk/py/code/source.py Fri Jan 18 17:35:33 2008 @@ -109,7 +109,7 @@ for start in range(lineno, -1, -1): trylines = self.lines[start:lineno+1] # quick hack to indent the source and get it as a string in one go - trylines.insert(0, 'if 0:') + trylines.insert(0, 'def xxx():') trysource = '\n '.join(trylines) # ^ space here try: From arigo at codespeak.net Fri Jan 18 17:45:56 2008 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 18 Jan 2008 17:45:56 +0100 (CET) Subject: [py-svn] r50757 - py/dist/py/code Message-ID: <20080118164556.3F7CF16855F@codespeak.net> Author: arigo Date: Fri Jan 18 17:45:55 2008 New Revision: 50757 Modified: py/dist/py/code/source.py Log: Port the r50754 bugfix. Modified: py/dist/py/code/source.py ============================================================================== --- py/dist/py/code/source.py (original) +++ py/dist/py/code/source.py Fri Jan 18 17:45:55 2008 @@ -109,7 +109,7 @@ for start in range(lineno, -1, -1): trylines = self.lines[start:lineno+1] # quick hack to indent the source and get it as a string in one go - trylines.insert(0, 'if 0:') + trylines.insert(0, 'def xxx():') trysource = '\n '.join(trylines) # ^ space here try: From py-svn at codespeak.net Tue Jan 22 00:05:37 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Tue, 22 Jan 2008 00:05:37 +0100 (CET) Subject: Your Featured Products for the Weekþþ Message-ID: <20080121010531.136449.qmail@dynamic-acs-24-239-228-205.zoominternet.net> An HTML attachment was scrubbed... URL: From hpk at codespeak.net Wed Jan 23 11:48:27 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 23 Jan 2008 11:48:27 +0100 (CET) Subject: [py-svn] r50907 - in py/extradoc: . sprintinfo Message-ID: <20080123104827.E9C74168452@codespeak.net> Author: hpk Date: Wed Jan 23 11:48:27 2008 New Revision: 50907 Added: py/extradoc/ py/extradoc/sprintinfo/ py/extradoc/sprintinfo/pycon2008.txt Log: * start py/extradoc hierarchy * sprint planning draft Added: py/extradoc/sprintinfo/pycon2008.txt ============================================================================== --- (empty file) +++ py/extradoc/sprintinfo/pycon2008.txt Wed Jan 23 11:48:27 2008 @@ -0,0 +1,22 @@ +py.test and py lib sprint at Pycon 2008 +---------------------------------------------- + +Time: Monday, March 17th 11pm TILL Thursday, March 20th + +starting with a tutorial 17th March 11pm + +URL: http://pylib.org + +Tasks: + - XXX -- tasks depend on if 1.0 gets out before and what it contains + - writing extensions / plugins + - implementing code coverage + - packaging for win32, debian + - unifying, exploring common usage with NOSE + - improving testing support for PyPy + - XXX + +sprint leaders: + Holger Krekel (holger at merlinux.de) + Brian Dorsey (briandorsey at gmail.com) + (Maciej Fijalkowski) From hpk at codespeak.net Thu Jan 24 18:27:06 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 24 Jan 2008 18:27:06 +0100 (CET) Subject: [py-svn] r50984 - py/branch/reporter-merge/py/test Message-ID: <20080124172706.99C6716844B@codespeak.net> Author: hpk Date: Thu Jan 24 18:27:06 2008 New Revision: 50984 Modified: py/branch/reporter-merge/py/test/session.py Log: avoid reporting hooks on session object Modified: py/branch/reporter-merge/py/test/session.py ============================================================================== --- py/branch/reporter-merge/py/test/session.py (original) +++ py/branch/reporter-merge/py/test/session.py Thu Jan 24 18:27:06 2008 @@ -27,8 +27,9 @@ if not colitems: break next = colitems.pop(0) - if session: - session.start(next) + if reporter: + reporter(repevent.ItemStart(next)) + if isinstance(next, stopitems): try: next._skipbykeyword(keyword) @@ -51,8 +52,8 @@ reporter(repevent.SkippedTryiter(excinfo, next)) else: reporter(repevent.FailedTryiter(excinfo, next)) - if session: - session.finish(next) + if reporter: + reporter(repevent.ItemFinish(next)) class AbstractSession(object): """ An abstract session executes collectors/items through a runner. @@ -90,16 +91,6 @@ reporter.was_failure() return reporter, checkfun - def start(self, item): - """ A hook invoked per every item started - """ - self.reporter(repevent.ItemStart(item)) - - def finish(self, item): - """ A hook invoked per every item ending - """ - self.reporter(repevent.ItemFinish(item)) - class Session(AbstractSession): """ A Session gets test Items from Collectors, executes the From hpk at codespeak.net Thu Jan 24 18:45:22 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 24 Jan 2008 18:45:22 +0100 (CET) Subject: [py-svn] r50985 - py/branch/reporter-merge/py/doc Message-ID: <20080124174522.1B51516844C@codespeak.net> Author: hpk Date: Thu Jan 24 18:45:21 2008 New Revision: 50985 Modified: py/branch/reporter-merge/py/doc/test_conftest.py Log: fix py/doc tests after removal of getitemoutcomespairs from the session object Modified: py/branch/reporter-merge/py/doc/test_conftest.py ============================================================================== --- py/branch/reporter-merge/py/doc/test_conftest.py (original) +++ py/branch/reporter-merge/py/doc/test_conftest.py Thu Jan 24 18:45:21 2008 @@ -1,10 +1,24 @@ import py -from py.__.test.outcome import Skipped, Failed, Passed +from py.__.test import repevent def setup_module(mod): mod.tmpdir = py.test.ensuretemp('docdoctest') +def countoutcomes(session): + l = [] + session.main(l.append) + passed = failed = skipped = 0 + for event in l: + if isinstance(event, repevent.ReceivedItemOutcome): + if event.outcome.passed: + passed += 1 + elif event.outcome.skipped: + skipped += 1 + else: + failed += 1 + return failed, passed, skipped + def test_doctest_extra_exec(): # XXX get rid of the next line: py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py')) @@ -16,9 +30,8 @@ """)) config = py.test.config._reparse([xtxt]) session = config.initsession() - session.main() - l = session.getitemoutcomepairs(Failed) - assert len(l) == 1 + failed, passed, skipped = countoutcomes(session) + assert failed == 1 def test_doctest_basic(): # XXX get rid of the next line: @@ -45,12 +58,9 @@ """)) config = py.test.config._reparse([xtxt]) session = config.initsession() - session.main() - l = session.getitemoutcomepairs(Failed) - assert len(l) == 0 - l = session.getitemoutcomepairs(Passed) - l2 = session.getitemoutcomepairs(Skipped) - assert len(l+l2) == 2 + failed, passed, skipped = countoutcomes(session) + assert failed == 0 + assert passed + skipped == 2 def test_deindent(): from py.__.doc.conftest import deindent @@ -69,12 +79,9 @@ ytxt.write(py.code.Source(".. >>> 1 + 1\r\n 2\r\n\r\n")) config = py.test.config._reparse([ytxt]) session = config.initsession() - session.main() - l = session.getitemoutcomepairs(Failed) - assert len(l) == 0 - l = session.getitemoutcomepairs(Passed) - l2 = session.getitemoutcomepairs(Skipped) - assert len(l+l2) == 2 + failed, passed, skipped = countoutcomes(session) + assert failed == 0 + assert passed + skipped == 2 def test_doctest_indentation(): # XXX get rid of the next line: @@ -84,12 +91,9 @@ txt.write('..\n >>> print "foo\\n bar"\n foo\n bar\n') config = py.test.config._reparse([txt]) session = config.initsession() - session.main() - l = session.getitemoutcomepairs(Failed) - assert len(l) == 0 - l = session.getitemoutcomepairs(Passed) - l2 = session.getitemoutcomepairs(Skipped) - assert len(l+l2) == 2 + failed, passed, skipped = countoutcomes(session) + assert failed == 0 + assert skipped + passed == 2 def test_js_ignore(): py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py')) @@ -102,12 +106,10 @@ """)) config = py.test.config._reparse([xtxt]) session = config.initsession() - session.main() - l = session.getitemoutcomepairs(Failed) - assert len(l) == 0 - l = session.getitemoutcomepairs(Passed) - l2 = session.getitemoutcomepairs(Skipped) - assert len(l+l2) == 3 + + failed, passed, skipped = countoutcomes(session) + assert failed == 0 + assert skipped + passed == 3 def test_resolve_linkrole(): from py.__.doc.conftest import get_apigen_relpath From hpk at codespeak.net Thu Jan 24 18:53:50 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 24 Jan 2008 18:53:50 +0100 (CET) Subject: [py-svn] r50986 - py/branch/reporter-merge/py/doc/example/pytest Message-ID: <20080124175350.E93C716844D@codespeak.net> Author: hpk Date: Thu Jan 24 18:53:50 2008 New Revision: 50986 Modified: py/branch/reporter-merge/py/doc/example/pytest/test_failures.py Log: refactoring test to use countoutcomes helper - it fails though: failure demo yield 21 failures not only 20 (compare it to running "py.test failure_demo.py" which does report 21 failures) Modified: py/branch/reporter-merge/py/doc/example/pytest/test_failures.py ============================================================================== --- py/branch/reporter-merge/py/doc/example/pytest/test_failures.py (original) +++ py/branch/reporter-merge/py/doc/example/pytest/test_failures.py Thu Jan 24 18:53:50 2008 @@ -1,13 +1,11 @@ import py failure_demo = py.magic.autopath().dirpath('failure_demo.py') -from py.__.test.outcome import Failed, Passed +from py.__.doc.test_conftest import countoutcomes def test_failure_demo_fails_properly(): config = py.test.config._reparse([failure_demo]) session = config.initsession() - session.main() - l = session.getitemoutcomepairs(Failed) - assert len(l) == 21 - l = session.getitemoutcomepairs(Passed) - assert not l + failed, passed, skipped = countoutcomes(session) + assert failed == 21 + assert passed == 0 From fijal at codespeak.net Fri Jan 25 12:55:07 2008 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 25 Jan 2008 12:55:07 +0100 (CET) Subject: [py-svn] r51025 - py/branch/reporter-merge/py/doc Message-ID: <20080125115507.2A88D16847A@codespeak.net> Author: fijal Date: Fri Jan 25 12:55:06 2008 New Revision: 51025 Modified: py/branch/reporter-merge/py/doc/test_conftest.py Log: Fix the test Modified: py/branch/reporter-merge/py/doc/test_conftest.py ============================================================================== --- py/branch/reporter-merge/py/doc/test_conftest.py (original) +++ py/branch/reporter-merge/py/doc/test_conftest.py Fri Jan 25 12:55:06 2008 @@ -17,6 +17,8 @@ skipped += 1 else: failed += 1 + elif isinstance(event, repevent.FailedTryiter): + failed += 1 return failed, passed, skipped def test_doctest_extra_exec(): From fijal at codespeak.net Fri Jan 25 13:00:11 2008 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 25 Jan 2008 13:00:11 +0100 (CET) Subject: [py-svn] r51026 - py/branch/reporter-merge/py/misc/testing Message-ID: <20080125120011.98998168461@codespeak.net> Author: fijal Date: Fri Jan 25 13:00:10 2008 New Revision: 51026 Modified: py/branch/reporter-merge/py/misc/testing/test_update_website.py Log: Skip those tests as apigen is turned off. Modified: py/branch/reporter-merge/py/misc/testing/test_update_website.py ============================================================================== --- py/branch/reporter-merge/py/misc/testing/test_update_website.py (original) +++ py/branch/reporter-merge/py/misc/testing/test_update_website.py Fri Jan 25 13:00:10 2008 @@ -57,6 +57,7 @@ captureouterr=True) print errors assert not errors + py.test.skip("Apigen turned off") assert pkgpath.join('../apigen').check(dir=True) assert pkgpath.join('../apigen/api/sub.foo.html').check(file=True) @@ -65,6 +66,7 @@ py.test.skip("update_website is not supposed to be run from win32") pkgpath = setup_pkg('update_website_run_tests_failure') assert not pkgpath.join('../apigen').check(dir=True) + py.test.skip("Apigen turned off") pkgpath.ensure('../apigen', file=True) errors = update_website.run_tests(pkgpath, pkgpath.dirpath().join('apigen'), From cfbolz at codespeak.net Fri Jan 25 13:46:33 2008 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Fri, 25 Jan 2008 13:46:33 +0100 (CET) Subject: [py-svn] r51029 - py/trunk/py/builtin Message-ID: <20080125124633.C5F0E1684D4@codespeak.net> Author: cfbolz Date: Fri Jan 25 13:46:31 2008 New Revision: 51029 Modified: py/trunk/py/builtin/exception.py Log: make sure the artificial GeneratorExit claims to come from the exceptions module Modified: py/trunk/py/builtin/exception.py ============================================================================== --- py/trunk/py/builtin/exception.py (original) +++ py/trunk/py/builtin/exception.py Fri Jan 25 13:46:31 2008 @@ -11,3 +11,4 @@ write code compatible with CPython 2.5 even in lower CPython versions.""" pass + GeneratorExit.__module__ = 'exceptions' From hpk at codespeak.net Fri Jan 25 14:30:54 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 25 Jan 2008 14:30:54 +0100 (CET) Subject: [py-svn] r51030 - in py/branch/reporter-merge/py/test: . terminal testing Message-ID: <20080125133054.97689168433@codespeak.net> Author: hpk Date: Fri Jan 25 14:30:54 2008 New Revision: 51030 Modified: py/branch/reporter-merge/py/test/session.py py/branch/reporter-merge/py/test/terminal/remote.py py/branch/reporter-merge/py/test/testing/test_remote.py Log: fixing test and restoring the functionality that session.main returns a list of failures (py.test --exec=python should work again) Modified: py/branch/reporter-merge/py/test/session.py ============================================================================== --- py/branch/reporter-merge/py/test/session.py (original) +++ py/branch/reporter-merge/py/test/session.py Fri Jan 25 14:30:54 2008 @@ -125,6 +125,7 @@ keyword = self.config.option.keyword reporter = self.reporter itemgenerator = itemgen(self, colitems, reporter, keyword) + failures = [] try: while 1: try: @@ -132,11 +133,15 @@ if shouldstop(): return outcome = self.run(item) + if outcome is not None: + if not outcome.passed and not outcome.skipped: + failures.append((item, outcome)) reporter(repevent.ReceivedItemOutcome(None, item, outcome)) except StopIteration: break finally: self.footer(colitems) + return failures def run(self, item): if not self.config.option.boxed: Modified: py/branch/reporter-merge/py/test/terminal/remote.py ============================================================================== --- py/branch/reporter-merge/py/test/terminal/remote.py (original) +++ py/branch/reporter-merge/py/test/terminal/remote.py Fri Jan 25 14:30:54 2008 @@ -135,7 +135,6 @@ session = config.initsession() session.shouldclose = channel.isclosed print "SLAVE: starting session.main()" - session.main() - failures = session.getitemoutcomepairs(Failed) + failures = session.main() failures = [config.get_collector_trail(item) for item,_ in failures] channel.send(failures) Modified: py/branch/reporter-merge/py/test/testing/test_remote.py ============================================================================== --- py/branch/reporter-merge/py/test/testing/test_remote.py (original) +++ py/branch/reporter-merge/py/test/testing/test_remote.py Fri Jan 25 14:30:54 2008 @@ -16,12 +16,13 @@ cls = config._getsessionclass() out = [] # out = py.std.Queue.Queue() session = cls(config, out.append) - session.main() + failures = session.main() for s in out: if s.find('1 failed') != -1: break else: - py.test.fail("did not see test_1 failure") + py.test.fail("did not see test_1 failure in output") + assert failures def test_looponfailing(self): o = tmpdir.ensure('looponfailing', dir=1) From fijal at codespeak.net Fri Jan 25 14:44:15 2008 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 25 Jan 2008 14:44:15 +0100 (CET) Subject: [py-svn] r51032 - py/branch/reporter-merge/py/green/test Message-ID: <20080125134415.0D00E168471@codespeak.net> Author: fijal Date: Fri Jan 25 14:44:12 2008 New Revision: 51032 Modified: py/branch/reporter-merge/py/green/test/test_greenexecnet.py Log: skip green execnet tests. Modified: py/branch/reporter-merge/py/green/test/test_greenexecnet.py ============================================================================== --- py/branch/reporter-merge/py/green/test/test_greenexecnet.py (original) +++ py/branch/reporter-merge/py/green/test/test_greenexecnet.py Fri Jan 25 14:44:12 2008 @@ -1,6 +1,8 @@ import py from py.__.green.greenexecnet import * +py.test.skip("Does not work with globally installed pylib") + def test_simple(): gw = PopenGateway() channel = gw.remote_exec("x = channel.receive(); channel.send(x * 6)") From hpk at codespeak.net Fri Jan 25 16:51:48 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 25 Jan 2008 16:51:48 +0100 (CET) Subject: [py-svn] r51033 - py/trunk/py/test Message-ID: <20080125155148.8655D1684E1@codespeak.net> Author: hpk Date: Fri Jan 25 16:51:46 2008 New Revision: 51033 Added: py/trunk/py/test/session.py.merge.tmp - copied, changed from r51032, py/trunk/py/test/session.py Log: merging of svn+ssh://codespeak.net/svn/py/branch/reporter-merge/py/test/session.py revisions 47584 to 51032: ------------------------------------------------------------------------ r51030 | hpk | 2008-01-25 14:30:54 +0100 (Fri, 25 Jan 2008) | 5 lines fixing test and restoring the functionality that session.main returns a list of failures (py.test --exec=python should work again) ------------------------------------------------------------------------ r50984 | hpk | 2008-01-24 18:27:06 +0100 (Thu, 24 Jan 2008) | 1 line avoid reporting hooks on session object ------------------------------------------------------------------------ r49391 | fijal | 2007-12-05 17:33:05 +0100 (Wed, 05 Dec 2007) | 2 lines Don't cache results. ------------------------------------------------------------------------ r48698 | fijal | 2007-11-15 01:31:42 +0100 (Thu, 15 Nov 2007) | 2 lines Uh. 2.4 compatibility ------------------------------------------------------------------------ r48318 | fijal | 2007-11-05 16:47:34 +0100 (Mon, 05 Nov 2007) | 3 lines Seems that --pdb don't need to imply -s and worked out of the box. I've got no idea how to test it though :-/ ------------------------------------------------------------------------ r48140 | fijal | 2007-10-28 19:43:21 +0100 (Sun, 28 Oct 2007) | 2 lines Reintroduce boxing ------------------------------------------------------------------------ r48138 | fijal | 2007-10-28 19:22:42 +0100 (Sun, 28 Oct 2007) | 2 lines Share more code. ------------------------------------------------------------------------ r48130 | fijal | 2007-10-28 14:58:42 +0100 (Sun, 28 Oct 2007) | 2 lines Add --collectonly handling, new style, logic separated ------------------------------------------------------------------------ r48129 | fijal | 2007-10-28 14:41:06 +0100 (Sun, 28 Oct 2007) | 2 lines Refactor LocalReporter not to rely on hosts being there ------------------------------------------------------------------------ r48128 | fijal | 2007-10-28 14:24:41 +0100 (Sun, 28 Oct 2007) | 2 lines Small regactoring for simple usage of default reporter class ------------------------------------------------------------------------ r48127 | fijal | 2007-10-28 12:56:41 +0100 (Sun, 28 Oct 2007) | 2 lines Remove terminal session as it's no longer needed ------------------------------------------------------------------------ r48126 | fijal | 2007-10-28 12:48:35 +0100 (Sun, 28 Oct 2007) | 2 lines Some real test for itemgen ------------------------------------------------------------------------ r47678 | fijal | 2007-10-21 18:43:54 +0200 (Sun, 21 Oct 2007) | 2 lines Make even less things working. ------------------------------------------------------------------------ r47667 | fijal | 2007-10-21 13:00:20 +0200 (Sun, 21 Oct 2007) | 4 lines Huge refactoring, the target is unification of session reporters and eventually sessions. Right now there is about 200 lines of code cut, but there is still some code to die and also some features missing :) ------------------------------------------------------------------------ r47660 | fijal | 2007-10-21 00:02:04 +0200 (Sun, 21 Oct 2007) | 2 lines Create a new branch for reporter merge ------------------------------------------------------------------------ Copied: py/trunk/py/test/session.py.merge.tmp (from r51032, py/trunk/py/test/session.py) ============================================================================== --- py/trunk/py/test/session.py (original) +++ py/trunk/py/test/session.py.merge.tmp Fri Jan 25 16:51:46 2008 @@ -1,12 +1,64 @@ import py +import sys from py.__.test.outcome import Outcome, Failed, Passed, Skipped from py.__.test.reporter import choose_reporter, TestReporter +from py.__.test import repevent +from py.__.test.outcome import SerializableOutcome, ReprOutcome +from py.__.test.reporter import LocalReporter +from py.__.test.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 +""" + +try: + GeneratorExit +except NameError: + GeneratorExit = StopIteration # I think + +def itemgen(session, colitems, reporter, keyword=None): + stopitems = py.test.collect.Item # XXX should be generator here as well + while 1: + if not colitems: + break + next = colitems.pop(0) + if reporter: + reporter(repevent.ItemStart(next)) + + if isinstance(next, stopitems): + try: + next._skipbykeyword(keyword) + yield next + except Skipped: + if session.config.option.keyword_oneshot: + keyword = None + excinfo = py.code.ExceptionInfo() + reporter(repevent.SkippedTryiter(excinfo, next)) + else: + try: + cols = [next.join(x) for x in next.run()] + for x in itemgen(session, cols, reporter, keyword): + yield x + except (KeyboardInterrupt, SystemExit, GeneratorExit): + raise + except: + excinfo = py.code.ExceptionInfo() + if excinfo.type is Skipped: + reporter(repevent.SkippedTryiter(excinfo, next)) + else: + reporter(repevent.FailedTryiter(excinfo, next)) + if reporter: + reporter(repevent.ItemFinish(next)) class AbstractSession(object): """ An abstract session executes collectors/items through a runner. """ - def __init__(self, config): - self._memo = [] + def __init__(self, config): self.config = config self._keyword = config.option.keyword @@ -18,10 +70,6 @@ option.startserver = True if self.config.getvalue("dist_boxed") and option.dist: option.boxed = True - # implied options - if option.usepdb: - if not option.nocapture: - option.nocapture = True # conflicting options if option.looponfailing and option.usepdb: raise ValueError, "--looponfailing together with --pdb not supported." @@ -35,7 +83,8 @@ def init_reporter(self, reporter, config, hosts): if reporter is None: - reporter = choose_reporter(config)(config, hosts) + reporter = choose_reporter(self.reporterclass, config)\ + (config, hosts) else: reporter = TestReporter(reporter) checkfun = lambda : self.config.option.exitfirst and \ @@ -47,11 +96,15 @@ A Session gets test Items from Collectors, executes the Items and sends the Outcome to the Reporter. """ + reporterclass = LocalReporter + def shouldclose(self): return False def header(self, colitems): """ setup any neccessary resources ahead of the test run. """ + self.reporter(repevent.TestStarted(None, self.config, + None)) if not self.config.option.nomagic: py.magic.invoke(assertion=1) @@ -60,91 +113,46 @@ py.test.collect.Function._state.teardown_all() if not self.config.option.nomagic: py.magic.revoke(assertion=1) - - def start(self, colitem): - """ hook invoked before each colitem.run() invocation. """ - - def finish(self, colitem, outcome): - """ hook invoked after each colitem.run() invocation. """ - self._memo.append((colitem, outcome)) - - def startiteration(self, colitem, subitems): - pass - - def getitemoutcomepairs(self, cls): - return [x for x in self._memo if isinstance(x[1], cls)] - - def main(self): + self.reporter(repevent.TestFinished()) + + def main(self, reporter=None): """ main loop for running tests. """ + config = self.config + self.reporter, shouldstop = self.init_reporter(reporter, config, None) + colitems = self.config.getcolitems() + self.header(colitems) + keyword = self.config.option.keyword + reporter = self.reporter + itemgenerator = itemgen(self, colitems, reporter, keyword) + failures = [] try: - self.header(colitems) - try: + while 1: try: - for colitem in colitems: - self.runtraced(colitem) - except KeyboardInterrupt: - raise - finally: - self.footer(colitems) - except Exit, ex: - pass + item = itemgenerator.next() + if shouldstop(): + return + outcome = self.run(item) + if outcome is not None: + if not outcome.passed and not outcome.skipped: + failures.append((item, outcome)) + reporter(repevent.ReceivedItemOutcome(None, item, outcome)) + except StopIteration: + break + finally: + self.footer(colitems) + return failures return self.getitemoutcomepairs(Failed) - def runtraced(self, colitem): - if self.shouldclose(): - raise Exit, "received external close signal" - - outcome = None - colitem.startcapture() - try: - self.start(colitem) - try: - try: - if colitem._stickyfailure: - raise colitem._stickyfailure - outcome = self.run(colitem) - except (KeyboardInterrupt, Exit): - raise - except Outcome, outcome: - if outcome.excinfo is None: - outcome.excinfo = py.code.ExceptionInfo() - except: - excinfo = py.code.ExceptionInfo() - outcome = Failed(excinfo=excinfo) - assert (outcome is None or - isinstance(outcome, (list, Outcome))) - finally: - self.finish(colitem, outcome) - if isinstance(outcome, Failed) and self.config.option.exitfirst: - py.test.exit("exit on first problem configured.", item=colitem) - finally: - colitem.finishcapture() - - def run(self, colitem): - if self.config.option.collectonly and isinstance(colitem, py.test.collect.Item): - return - if isinstance(colitem, py.test.collect.Item): - colitem._skipbykeyword(self._keyword) - if self.config.option.keyword_oneshot: - self._keyword = "" - res = colitem.run() - if res is None: - return Passed() - elif not isinstance(res, (list, tuple)): - raise TypeError("%r.run() returned neither " - "list, tuple nor None: %r" % (colitem, res)) - else: - finish = self.startiteration(colitem, res) - try: - for name in res: - obj = colitem.join(name) - assert obj is not None - self.runtraced(obj) - finally: - if finish: - finish() - return res + def run(self, item): + if not self.config.option.boxed: + executor = RunExecutor(item, self.config.option.usepdb, + self.reporter, self.config) + return ReprOutcome(executor.execute().make_repr()) + else: + executor = BoxExecutor(item, self.config.option.usepdb, + self.reporter, self.config) + return ReprOutcome(executor.execute()) class Exit(Exception): """ for immediate program exits without tracebacks and reporter/summary. """ From hpk at codespeak.net Fri Jan 25 16:54:04 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 25 Jan 2008 16:54:04 +0100 (CET) Subject: [py-svn] r51034 - in py/trunk/py: . apigen doc doc/example green misc test test/rsession test/terminal test/testing Message-ID: <20080125155404.AC0CB1684D0@codespeak.net> Author: hpk Date: Fri Jan 25 16:54:04 2008 New Revision: 51034 Added: py/trunk/py/__init__.py - copied unchanged from r51033, py/branch/reporter-merge/py/__init__.py py/trunk/py/apigen/ - copied from r51033, py/branch/reporter-merge/py/apigen/ py/trunk/py/doc/example/ - copied from r51033, py/branch/reporter-merge/py/doc/example/ py/trunk/py/doc/test_conftest.py - copied unchanged from r51033, py/branch/reporter-merge/py/doc/test_conftest.py py/trunk/py/green/ - copied from r51033, py/branch/reporter-merge/py/green/ py/trunk/py/misc/ - copied from r51033, py/branch/reporter-merge/py/misc/ py/trunk/py/test/box.py - copied unchanged from r51033, py/branch/reporter-merge/py/test/box.py py/trunk/py/test/collect.py - copied unchanged from r51033, py/branch/reporter-merge/py/test/collect.py py/trunk/py/test/collectonly.py - copied unchanged from r51033, py/branch/reporter-merge/py/test/collectonly.py py/trunk/py/test/config.py - copied unchanged from r51033, py/branch/reporter-merge/py/test/config.py py/trunk/py/test/defaultconftest.py - copied unchanged from r51033, py/branch/reporter-merge/py/test/defaultconftest.py py/trunk/py/test/executor.py - copied unchanged from r51033, py/branch/reporter-merge/py/test/executor.py py/trunk/py/test/outcome.py - copied unchanged from r51033, py/branch/reporter-merge/py/test/outcome.py py/trunk/py/test/repevent.py - copied unchanged from r51033, py/branch/reporter-merge/py/test/repevent.py py/trunk/py/test/reporter.py - copied unchanged from r51033, py/branch/reporter-merge/py/test/reporter.py py/trunk/py/test/representation.py - copied unchanged from r51033, py/branch/reporter-merge/py/test/representation.py py/trunk/py/test/rsession/ - copied from r51033, py/branch/reporter-merge/py/test/rsession/ py/trunk/py/test/session.py - copied unchanged from r51033, py/trunk/py/test/session.py.merge.tmp py/trunk/py/test/terminal/ - copied from r51033, py/branch/reporter-merge/py/test/terminal/ py/trunk/py/test/testing/ - copied from r51033, py/branch/reporter-merge/py/test/testing/ Removed: py/trunk/py/test/session.py.merge.tmp Log: merging in fijal's reporter-merge branch into the trunk, still needs refactoring as far as i am concernced. Deleted: /py/trunk/py/test/session.py.merge.tmp ============================================================================== --- /py/trunk/py/test/session.py.merge.tmp Fri Jan 25 16:54:04 2008 +++ (empty file) @@ -1,165 +0,0 @@ -import py -import sys -from py.__.test.outcome import Outcome, Failed, Passed, Skipped -from py.__.test.reporter import choose_reporter, TestReporter -from py.__.test import repevent -from py.__.test.outcome import SerializableOutcome, ReprOutcome -from py.__.test.reporter import LocalReporter -from py.__.test.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 -""" - -try: - GeneratorExit -except NameError: - GeneratorExit = StopIteration # I think - -def itemgen(session, colitems, reporter, keyword=None): - stopitems = py.test.collect.Item # XXX should be generator here as well - while 1: - if not colitems: - break - next = colitems.pop(0) - if reporter: - reporter(repevent.ItemStart(next)) - - if isinstance(next, stopitems): - try: - next._skipbykeyword(keyword) - yield next - except Skipped: - if session.config.option.keyword_oneshot: - keyword = None - excinfo = py.code.ExceptionInfo() - reporter(repevent.SkippedTryiter(excinfo, next)) - else: - try: - cols = [next.join(x) for x in next.run()] - for x in itemgen(session, cols, reporter, keyword): - yield x - except (KeyboardInterrupt, SystemExit, GeneratorExit): - raise - except: - excinfo = py.code.ExceptionInfo() - if excinfo.type is Skipped: - reporter(repevent.SkippedTryiter(excinfo, next)) - else: - reporter(repevent.FailedTryiter(excinfo, next)) - if reporter: - reporter(repevent.ItemFinish(next)) - -class AbstractSession(object): - """ An abstract session executes collectors/items through a runner. - """ - def __init__(self, config): - self.config = config - self._keyword = config.option.keyword - - def fixoptions(self): - """ check, fix and determine conflicting options. """ - option = self.config.option - if option.runbrowser and not option.startserver: - #print "--runbrowser implies --startserver" - option.startserver = True - if self.config.getvalue("dist_boxed") and option.dist: - option.boxed = True - # conflicting options - if option.looponfailing and option.usepdb: - raise ValueError, "--looponfailing together with --pdb not supported." - if option.looponfailing and option.dist: - 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" - - def init_reporter(self, reporter, config, hosts): - if reporter is None: - reporter = choose_reporter(self.reporterclass, config)\ - (config, hosts) - else: - reporter = TestReporter(reporter) - checkfun = lambda : self.config.option.exitfirst and \ - reporter.was_failure() - return reporter, checkfun - -class Session(AbstractSession): - """ - A Session gets test Items from Collectors, executes the - Items and sends the Outcome to the Reporter. - """ - reporterclass = LocalReporter - - def shouldclose(self): - return False - - def header(self, colitems): - """ setup any neccessary resources ahead of the test run. """ - self.reporter(repevent.TestStarted(None, self.config, - None)) - if not self.config.option.nomagic: - py.magic.invoke(assertion=1) - - def footer(self, colitems): - """ teardown any resources after a test run. """ - py.test.collect.Function._state.teardown_all() - if not self.config.option.nomagic: - py.magic.revoke(assertion=1) - self.reporter(repevent.TestFinished()) - - def main(self, reporter=None): - """ main loop for running tests. """ - config = self.config - self.reporter, shouldstop = self.init_reporter(reporter, config, None) - - colitems = self.config.getcolitems() - self.header(colitems) - keyword = self.config.option.keyword - reporter = self.reporter - itemgenerator = itemgen(self, colitems, reporter, keyword) - failures = [] - try: - while 1: - try: - item = itemgenerator.next() - if shouldstop(): - return - outcome = self.run(item) - if outcome is not None: - if not outcome.passed and not outcome.skipped: - failures.append((item, outcome)) - reporter(repevent.ReceivedItemOutcome(None, item, outcome)) - except StopIteration: - break - finally: - self.footer(colitems) - return failures - return self.getitemoutcomepairs(Failed) - - def run(self, item): - if not self.config.option.boxed: - executor = RunExecutor(item, self.config.option.usepdb, - self.reporter, self.config) - return ReprOutcome(executor.execute().make_repr()) - else: - executor = BoxExecutor(item, self.config.option.usepdb, - self.reporter, self.config) - return ReprOutcome(executor.execute()) - -class Exit(Exception): - """ for immediate program exits without tracebacks and reporter/summary. """ - def __init__(self, msg="unknown reason", item=None): - self.msg = msg - Exception.__init__(self, msg) - -def exit(msg, item=None): - raise Exit(msg=msg, item=item) - From hpk at codespeak.net Sat Jan 26 11:58:24 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 26 Jan 2008 11:58:24 +0100 (CET) Subject: [py-svn] r51056 - py/trunk/py/green Message-ID: <20080126105824.50654168441@codespeak.net> Author: hpk Date: Sat Jan 26 11:58:23 2008 New Revision: 51056 Modified: py/trunk/py/green/conftest.py Log: fijal: don't use py.test.skip directly in a conftest.py - this will get called very early during import time. This lead to windows not executing any py/ tests at all. Modified: py/trunk/py/green/conftest.py ============================================================================== --- py/trunk/py/green/conftest.py (original) +++ py/trunk/py/green/conftest.py Sat Jan 26 11:58:23 2008 @@ -1,4 +1,8 @@ import py, os -if os.name == 'nt': - py.test.skip("Cannot test green layer on windows") +class Directory(py.test.collect.Directory): + def run(self): + if os.name == 'nt': + py.test.skip("Cannot test green layer on windows") + else: + return super(Directory, self).run() From hpk at codespeak.net Sat Jan 26 12:33:32 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 26 Jan 2008 12:33:32 +0100 (CET) Subject: [py-svn] r51057 - py/trunk/py/doc Message-ID: <20080126113332.6DB0F168443@codespeak.net> Author: hpk Date: Sat Jan 26 12:33:32 2008 New Revision: 51057 Modified: py/trunk/py/doc/TODO.txt Log: review, refactor and write up for some 1.0 related TODOs Modified: py/trunk/py/doc/TODO.txt ============================================================================== --- py/trunk/py/doc/TODO.txt (original) +++ py/trunk/py/doc/TODO.txt Sat Jan 26 12:33:32 2008 @@ -1,11 +1,44 @@ Things to do for 1.0.0 ========================= +py.test +-------------- + +- review and refactor architecture of py.test with particular + respect to: + - writing (stacked) extensions / plugins (compared to Nose) + - event naming and processing + - porting existing extensions (htmlconftest / buildbot / + PyPy's conftest's ...) + - fast and stable distributed testing + - reliable cross-platform testing + +- fix reporting/usage degradation after reporter-merge merge: + - collapse skips with same reason and lineno into one line + +- fix and investigate win32 failures + +- (needs review) adjust py.test documentation to reflect new + collector/session architecture + +- document py.test's conftest.py approach + +py.execnet +-------------- +- cross-python version (2.2/2.3-2.5/6) and cross-platform testing of + setup/teardown semantics +- optimize general setup and rsync timing? +py.apigen +---------------- +- 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 ld (review and shift to above) @@ -14,9 +47,6 @@ refactorings ------------------ -- merge py.execnet-lessthreads branch (it's working relatively - nicely, already) (M995) - - session / collection unification (particularly tryiter and buildname2items) - reporting unification, i.e. use dist-testing Reporter class @@ -114,11 +144,6 @@ (guido tested all on win32, everything works except --dist (requires os.fork to work)) -distributed testing / RSession ------------------------------------- - -* (optional) see if more of py/test/session.py's Session can be reused - code quality ----------------- @@ -129,15 +154,9 @@ * review the pylib issue tracker (cfbolz: done: what has a 1.0.0 tag (or lower) should be looked at again) - py.test ------- -* (needs review) adjust py.test documentation to reflect new - collector/session architecture - -* (in-progress, NOT DONE) document py.test's conftest.py approach - * (postponed, likely) py.test fails to parse strangely formatted code after assertion failure Missing docstrings From hpk at codespeak.net Sat Jan 26 12:45:05 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 26 Jan 2008 12:45:05 +0100 (CET) Subject: [py-svn] r51058 - py/trunk/py/doc Message-ID: <20080126114505.44E2B168469@codespeak.net> Author: hpk Date: Sat Jan 26 12:45:03 2008 New Revision: 51058 Modified: py/trunk/py/doc/TODO.txt Log: fix ReST Modified: py/trunk/py/doc/TODO.txt ============================================================================== --- py/trunk/py/doc/TODO.txt (original) +++ py/trunk/py/doc/TODO.txt Sat Jan 26 12:45:03 2008 @@ -8,8 +8,7 @@ respect to: - writing (stacked) extensions / plugins (compared to Nose) - event naming and processing - - porting existing extensions (htmlconftest / buildbot / - PyPy's conftest's ...) + - porting existing extensions (htmlconftest / buildbot / PyPy's conftest's ...) - fast and stable distributed testing - reliable cross-platform testing From hpk at codespeak.net Sun Jan 27 12:55:29 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sun, 27 Jan 2008 12:55:29 +0100 (CET) Subject: [py-svn] r51077 - py/trunk/py Message-ID: <20080127115529.005231684E7@codespeak.net> Author: hpk Date: Sun Jan 27 12:55:27 2008 New Revision: 51077 Modified: py/trunk/py/__init__.py Log: bump version number Modified: py/trunk/py/__init__.py ============================================================================== --- py/trunk/py/__init__.py (original) +++ py/trunk/py/__init__.py Sun Jan 27 12:55:27 2008 @@ -7,7 +7,7 @@ """ from initpkg import initpkg -version = "0.9.1-alpha" +version = "1.0-pre-alpha" initpkg(__name__, description = "pylib and py.test: agile development and test support library", From hpk at codespeak.net Sun Jan 27 22:33:31 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sun, 27 Jan 2008 22:33:31 +0100 (CET) Subject: [py-svn] r51087 - py/trunk/py/test Message-ID: <20080127213331.0512716853A@codespeak.net> Author: hpk Date: Sun Jan 27 22:33:30 2008 New Revision: 51087 Modified: py/trunk/py/test/reporter.py Log: add a note that skip-reporting is broken after the branch-merge Modified: py/trunk/py/test/reporter.py ============================================================================== --- py/trunk/py/test/reporter.py (original) +++ py/trunk/py/test/reporter.py Sun Jan 27 22:33:30 2008 @@ -221,6 +221,9 @@ return host.hostid def skips(self): + # XXX review and test below, fix too many lines of + # skips that happen in the same file/lineno + # (this is correct in py-dist) texts = {} for event in self.skipped_tests_outcome: colitem = event.item From hpk at codespeak.net Wed Jan 30 12:22:20 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 30 Jan 2008 12:22:20 +0100 (CET) Subject: [py-svn] r51121 - py/branch/event Message-ID: <20080130112220.2EE7A168447@codespeak.net> Author: hpk Date: Wed Jan 30 12:22:19 2008 New Revision: 51121 Added: py/branch/event/ - copied from r51120, py/trunk/ Log: branch for refactoring towards a generalized event architecture (for test events, particularly) From hpk at codespeak.net Wed Jan 30 12:58:19 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 30 Jan 2008 12:58:19 +0100 (CET) Subject: [py-svn] r51122 - in py/branch/event/py/event: . testing Message-ID: <20080130115819.C7B0116844C@codespeak.net> Author: hpk Date: Wed Jan 30 12:58:16 2008 New Revision: 51122 Added: py/branch/event/py/event/ py/branch/event/py/event/testing/ Log: adding a general simple Event Hub (mirroring Jim's simple Zope3 zope.event mechanism) From hpk at codespeak.net Wed Jan 30 13:00:35 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 30 Jan 2008 13:00:35 +0100 (CET) Subject: [py-svn] r51123 - in py/branch/event/py/event: . testing Message-ID: <20080130120035.B6162168410@codespeak.net> Author: hpk Date: Wed Jan 30 13:00:34 2008 New Revision: 51123 Added: py/branch/event/py/event/__init__.py (contents, props changed) py/branch/event/py/event/hub.py (contents, props changed) py/branch/event/py/event/testing/__init__.py (contents, props changed) py/branch/event/py/event/testing/test_hub.py (contents, props changed) Modified: py/branch/event/py/event/ (props changed) py/branch/event/py/event/testing/ (props changed) Log: actually adding the code for the event hub. Added: py/branch/event/py/event/__init__.py ============================================================================== --- (empty file) +++ py/branch/event/py/event/__init__.py Wed Jan 30 13:00:34 2008 @@ -0,0 +1 @@ +# Added: py/branch/event/py/event/hub.py ============================================================================== --- (empty file) +++ py/branch/event/py/event/hub.py Wed Jan 30 13:00:34 2008 @@ -0,0 +1,6 @@ + +class Hub(list): + """ General Event Hub """ + def notify(self, event): + for subscriber in self: + subscriber(event) Added: py/branch/event/py/event/testing/__init__.py ============================================================================== --- (empty file) +++ py/branch/event/py/event/testing/__init__.py Wed Jan 30 13:00:34 2008 @@ -0,0 +1 @@ +# Added: py/branch/event/py/event/testing/test_hub.py ============================================================================== --- (empty file) +++ py/branch/event/py/event/testing/test_hub.py Wed Jan 30 13:00:34 2008 @@ -0,0 +1,33 @@ +import py + +class TestHub: + + def test_simple(self): + hub = py.event.Hub() + l = [] + hub.append(l.append) + hub.notify(1) + hub.notify(2) + hub.notify(3) + assert l == [1,2,3] + + def test_multi_sub(self): + hub = py.event.Hub() + l1 = [] + l2 = [] + hub.append(l1.append) + hub.append(l2.append) + hub.notify(1) + hub.notify(2) + hub.notify(3) + assert l1 == [1,2,3] + assert l2 == [1,2,3] + + def test_remove(self): + hub = py.event.Hub() + l = [] + hub.append(l.append) + hub.notify(1) + hub.remove(l.append) + hub.notify(2) + assert l == [1] From hpk at codespeak.net Wed Jan 30 13:05:55 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 30 Jan 2008 13:05:55 +0100 (CET) Subject: [py-svn] r51124 - in py/branch/event/py: . event event/testing Message-ID: <20080130120555.09F89168416@codespeak.net> Author: hpk Date: Wed Jan 30 13:05:54 2008 New Revision: 51124 Modified: py/branch/event/py/__init__.py py/branch/event/py/event/hub.py py/branch/event/py/event/testing/test_hub.py Log: adding a commented out global hub (not sure we need it) and enabling py.event namespace in py/__init__.py Modified: py/branch/event/py/__init__.py ============================================================================== --- py/branch/event/py/__init__.py (original) +++ py/branch/event/py/__init__.py Wed Jan 30 13:05:54 2008 @@ -51,6 +51,11 @@ 'test.collect.Item' : ('./test/item.py', 'Item'), 'test.collect.Function' : ('./test/item.py', 'Function'), + # Event related APIs + 'event.Hub' : ('./event/hub.py', 'Hub'), + #'event.hub' : ('./event/hub.py', 'hub'), + #'event.notify' : ('./event/hub.py', 'notify'), + # thread related API (still in early design phase) '_thread.WorkerPool' : ('./thread/pool.py', 'WorkerPool'), '_thread.NamedThreadPool' : ('./thread/pool.py', 'NamedThreadPool'), Modified: py/branch/event/py/event/hub.py ============================================================================== --- py/branch/event/py/event/hub.py (original) +++ py/branch/event/py/event/hub.py Wed Jan 30 13:05:54 2008 @@ -4,3 +4,8 @@ def notify(self, event): for subscriber in self: subscriber(event) + + +# XXX do we want a global hub? +#hub = Hub() +#notify = hub.notify Modified: py/branch/event/py/event/testing/test_hub.py ============================================================================== --- py/branch/event/py/event/testing/test_hub.py (original) +++ py/branch/event/py/event/testing/test_hub.py Wed Jan 30 13:05:54 2008 @@ -31,3 +31,4 @@ hub.remove(l.append) hub.notify(2) assert l == [1] + From hpk at codespeak.net Wed Jan 30 16:25:40 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 30 Jan 2008 16:25:40 +0100 (CET) Subject: [py-svn] r51132 - py/trunk/py/doc Message-ID: <20080130152540.C6390168410@codespeak.net> Author: hpk Date: Wed Jan 30 16:25:40 2008 New Revision: 51132 Modified: py/trunk/py/doc/TODO.txt Log: a todo/note on skip's and speed (inspired by exarkun on #pypy) Modified: py/trunk/py/doc/TODO.txt ============================================================================== --- py/trunk/py/doc/TODO.txt (original) +++ py/trunk/py/doc/TODO.txt Wed Jan 30 16:25:40 2008 @@ -22,6 +22,10 @@ - document py.test's conftest.py approach +- review and optimize skip-handling (it can be quite slow in + certain situations because e.g. setup/teardown is fully performed + although we have "skip by keyword" and could detect this early) + py.execnet -------------- From hpk at codespeak.net Wed Jan 30 16:53:22 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 30 Jan 2008 16:53:22 +0100 (CET) Subject: [py-svn] r51135 - in py/branch/event/py: . test test/testing Message-ID: <20080130155322.BED871683D0@codespeak.net> Author: hpk Date: Wed Jan 30 16:53:21 2008 New Revision: 51135 Modified: py/branch/event/py/__init__.py py/branch/event/py/test/item.py py/branch/event/py/test/testing/test_session.py Log: removing rather useless (IMO) py.test - 'notimplemented' and 'broken' logic Modified: py/branch/event/py/__init__.py ============================================================================== --- py/branch/event/py/__init__.py (original) +++ py/branch/event/py/__init__.py Wed Jan 30 16:53:21 2008 @@ -31,8 +31,6 @@ 'test.skip' : ('./test/item.py', 'skip'), 'test.fail' : ('./test/item.py', 'fail'), 'test.exit' : ('./test/session.py', 'exit'), - 'test.broken' : ('./test/item.py', 'Broken'), - 'test.notimplemented' : ('./test/item.py', '_NotImplemented'), 'test.pdb' : ('./test/custompdb.py', 'set_trace'), # configuration/initialization related test api Modified: py/branch/event/py/test/item.py ============================================================================== --- py/branch/event/py/test/item.py (original) +++ py/branch/event/py/test/item.py Wed Jan 30 16:53:21 2008 @@ -67,28 +67,9 @@ """ execute the given test function. """ target(*args) -# -# triggering specific outcomes while executing Items -# -class BaseReason(object): - def __init__(self, msg="unknown reason", **kwds): - self.msg = msg - self.__dict__.update(kwds) - - def __repr__(self): - return self.msg - -class Broken(BaseReason): - def __repr__(self): - return "Broken: %s" % (self.msg,) - -class _NotImplemented(BaseReason): - def __repr__(self): - return "Not implemented: %s" % (self.msg,) - # whatever comes here.... -def skip(msg=BaseReason()): +def skip(msg=""): """ skip with the given Message. """ __tracebackhide__ = True raise Skipped(msg=msg) Modified: py/branch/event/py/test/testing/test_session.py ============================================================================== --- py/branch/event/py/test/testing/test_session.py (original) +++ py/branch/event/py/test/testing/test_session.py Wed Jan 30 16:53:21 2008 @@ -277,23 +277,3 @@ out = l[1].excinfo.exconly() assert out.find("[unknown exception raised in repr()]") != -1 -def test_skip_reasons(): - tmp = py.test.ensuretemp("check_skip_reasons") - tmp.ensure("test_one.py").write(py.code.Source(""" - import py - def test_1(): - py.test.skip(py.test.broken('stuff')) - - def test_2(): - py.test.skip(py.test.notimplemented('stuff')) - """)) - tmp.ensure("__init__.py") - config = py.test.config._reparse([tmp]) - all = [] - session = config.initsession() - session.main(all.append) - skips = getskipped(all) - assert len(skips) == 2 - assert str(skips[0].skipped.value) == 'Broken: stuff' - assert str(skips[1].skipped.value) == 'Not implemented: stuff' - From hpk at codespeak.net Wed Jan 30 20:15:00 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 30 Jan 2008 20:15:00 +0100 (CET) Subject: [py-svn] r51142 - in py/branch/event/py: bin test/rsession/testing test/testing Message-ID: <20080130191500.60EB3168422@codespeak.net> Author: hpk Date: Wed Jan 30 20:14:58 2008 New Revision: 51142 Added: py/branch/event/py/bin/_maketest2.py Modified: py/branch/event/py/test/rsession/testing/test_hostmanage.py py/branch/event/py/test/testing/test_reporter.py Log: * add a script that should help to test py.test refactorings with py.test * skip/fix some tests Added: py/branch/event/py/bin/_maketest2.py ============================================================================== --- (empty file) +++ py/branch/event/py/bin/_maketest2.py Wed Jan 30 20:14:58 2008 @@ -0,0 +1,62 @@ +""" create a py/test2 hierarchy for use of refactoring + but still be able to use py.test as a testing tool for + doing the refactorings. +""" + +from _findpy import py + +def change_init(initfile): + l = [] + for line in initfile.readlines(): + newline = line + l.append(line) + newline = newline.replace("'test.", "'test2.") + newline = newline.replace("'./test/", "'./test2/") + if newline != line: + l.append(newline) + initfile.write("".join(l)) + +def perform_replace(directory): + for x in directory.visit("*.py", + rec=lambda x: x.check(dir=1, dotfile=0)): + if x.basename == "__init__.py": + continue + s = n = x.read() + n = n.replace("py.test.", "py.test2.") + #n = n.replace("py.test2.skip", "py.test.skip") + n = n.replace("py.test ", "py.test2 ") + n = n.replace("py.__.test.", "py.__.test2.") + n = n.replace("py.__.test ", "py.__.test2 ") + if x.basename.startswith("test_"): + n = n.replace("py.test2.skip(", "py.test.skip(") + + if s != n: + if n.find("TestCaseUnit") != -1: + n = n.replace("py.test2.collect", "py.test.collect") + print "writing modified", x + x.write(n) + +def cmd(command): + print "* executing:", command + return py.process.cmdexec(command) + +if __name__ == '__main__': + basedir = py.path.local(py.__file__).dirpath() + #st = py.path.svnwc(basedir).status() + #assert not st.modified + olddir = basedir.chdir() + try: + initfile = basedir.join("__init__.py") + cmd("svn revert %s" % initfile) + change_init(initfile) + + test2dir = basedir.join("test2") + cmd("svn revert -R test2") + cmd("rm -rf test2") + cmd("svn cp test test2") + perform_replace(test2dir) + + finally: + olddir.chdir() + + Modified: py/branch/event/py/test/rsession/testing/test_hostmanage.py ============================================================================== --- py/branch/event/py/test/rsession/testing/test_hostmanage.py (original) +++ py/branch/event/py/test/rsession/testing/test_hostmanage.py Wed Jan 30 20:14:58 2008 @@ -86,7 +86,7 @@ def test_initgateway_ssh_and_remotepath(self): option = py.test.config.option - if option.sshtarget is None: + if getattr(option, 'sshtarget', None) is None: py.test.skip("no known ssh target, use -S to set one") host = HostInfo("%s" % (option.sshtarget, )) # this test should be careful to not write/rsync anything Modified: py/branch/event/py/test/testing/test_reporter.py ============================================================================== --- py/branch/event/py/test/testing/test_reporter.py (original) +++ py/branch/event/py/test/testing/test_reporter.py Wed Jan 30 20:14:58 2008 @@ -227,6 +227,7 @@ assert output.endswith("FsF."), output def test_full_module(self): + py.test.skip("fix exact output matching test") received = self._test_full_module() expected_lst = ["repmod/test_one.py", "FAILED TO LOAD MODULE", "skipped", "reason"] @@ -261,6 +262,7 @@ assert val.find(expected) != -1 def test_full_module(self): + py.test.skip("fix exact output matching test") val = self._test_full_module() assert val.find("FAILED TO LOAD MODULE: repmod/test_three.py\n"\ "\nSkipped ('reason') repmod/test_two.py") != -1 From hpk at codespeak.net Wed Jan 30 20:26:52 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 30 Jan 2008 20:26:52 +0100 (CET) Subject: [py-svn] r51143 - py/branch/event/py/test/rsession Message-ID: <20080130192652.8495E168424@codespeak.net> Author: hpk Date: Wed Jan 30 20:26:51 2008 New Revision: 51143 Modified: py/branch/event/py/test/rsession/master.py Log: avoid relying on global config state here Modified: py/branch/event/py/test/rsession/master.py ============================================================================== --- py/branch/event/py/test/rsession/master.py (original) +++ py/branch/event/py/test/rsession/master.py Wed Jan 30 20:26:51 2008 @@ -43,9 +43,7 @@ def dispatch_loop(masternodes, itemgenerator, shouldstop, waiter = lambda: py.std.time.sleep(0.1), - max_tasks_per_node=None): - if not max_tasks_per_node: - max_tasks_per_node = py.test.config.getvalue("dist_taskspernode") + max_tasks_per_node=15): all_tests = {} while 1: try: From hpk at codespeak.net Wed Jan 30 20:30:17 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 30 Jan 2008 20:30:17 +0100 (CET) Subject: [py-svn] r51144 - py/branch/event/py/test/rsession Message-ID: <20080130193017.4F832168411@codespeak.net> Author: hpk Date: Wed Jan 30 20:30:16 2008 New Revision: 51144 Modified: py/branch/event/py/test/rsession/rsession.py Log: load dist_taskspernode config value here (see rev 51143 commit) Modified: py/branch/event/py/test/rsession/rsession.py ============================================================================== --- py/branch/event/py/test/rsession/rsession.py (original) +++ py/branch/event/py/test/rsession/rsession.py Wed Jan 30 20:30:16 2008 @@ -84,4 +84,6 @@ colitems = self.config.getcolitems() keyword = self.config.option.keyword itemgenerator = itemgen(self, colitems, reporter, keyword) - all_tests = dispatch_loop(nodes, itemgenerator, checkfun) + max_tasks_per_node = self.config.getvalue("dist_taskspernode") + all_tests = dispatch_loop(nodes, itemgenerator, checkfun, + max_tasks_per_node=max_tasks_per_node) From hpk at codespeak.net Wed Jan 30 20:38:16 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 30 Jan 2008 20:38:16 +0100 (CET) Subject: [py-svn] r51145 - in py/branch/event/py: . test2 test2/rsession test2/rsession/testing test2/terminal test2/testing test2/web Message-ID: <20080130193816.C4864168416@codespeak.net> Author: hpk Date: Wed Jan 30 20:38:14 2008 New Revision: 51145 Added: py/branch/event/py/test2/ - copied from r51144, py/branch/event/py/test/ Modified: py/branch/event/py/__init__.py py/branch/event/py/test2/box.py py/branch/event/py/test2/cmdline.py py/branch/event/py/test2/collect.py py/branch/event/py/test2/collectonly.py py/branch/event/py/test2/compat.py py/branch/event/py/test2/config.py py/branch/event/py/test2/conftesthandle.py py/branch/event/py/test2/defaultconftest.py py/branch/event/py/test2/doctest.py py/branch/event/py/test2/executor.py py/branch/event/py/test2/item.py py/branch/event/py/test2/raises.py py/branch/event/py/test2/repevent.py py/branch/event/py/test2/reporter.py py/branch/event/py/test2/representation.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/basetest.py py/branch/event/py/test2/rsession/testing/test_hostmanage.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_slave.py py/branch/event/py/test2/rsession/testing/test_web.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/terminal/remote.py py/branch/event/py/test2/testing/setupdata.py py/branch/event/py/test2/testing/test_boxing.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_compat.py py/branch/event/py/test2/testing/test_config.py py/branch/event/py/test2/testing/test_conftesthandle.py py/branch/event/py/test2/testing/test_deprecated.py py/branch/event/py/test2/testing/test_doctest.py py/branch/event/py/test2/testing/test_executor.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_remote.py py/branch/event/py/test2/testing/test_repevent.py py/branch/event/py/test2/testing/test_reporter.py py/branch/event/py/test2/testing/test_repr.py py/branch/event/py/test2/testing/test_session.py py/branch/event/py/test2/testing/test_session2.py py/branch/event/py/test2/web/webcheck.py Log: make a py.test2 namespace for incremental refactoring and to allow to use py.test itself for testing it. Modified: py/branch/event/py/__init__.py ============================================================================== --- py/branch/event/py/__init__.py (original) +++ py/branch/event/py/__init__.py Wed Jan 30 20:38:14 2008 @@ -26,28 +26,47 @@ exportdefs = { # helpers for use from test functions or collectors 'test.__doc__' : ('./test/__init__.py', '__doc__'), + 'test2.__doc__' : ('./test2/__init__.py', '__doc__'), 'test.raises' : ('./test/raises.py', 'raises'), + 'test2.raises' : ('./test2/raises.py', 'raises'), 'test.deprecated_call' : ('./test/deprecate.py', 'deprecated_call'), + 'test2.deprecated_call' : ('./test2/deprecate.py', 'deprecated_call'), 'test.skip' : ('./test/item.py', 'skip'), + 'test2.skip' : ('./test2/item.py', 'skip'), 'test.fail' : ('./test/item.py', 'fail'), + 'test2.fail' : ('./test2/item.py', 'fail'), 'test.exit' : ('./test/session.py', 'exit'), + 'test2.exit' : ('./test2/session.py', 'exit'), 'test.pdb' : ('./test/custompdb.py', 'set_trace'), + 'test2.pdb' : ('./test2/custompdb.py', 'set_trace'), # configuration/initialization related test api 'test.config' : ('./test/config.py', 'config_per_process'), + 'test2.config' : ('./test2/config.py', 'config_per_process'), 'test.ensuretemp' : ('./test/config.py', 'ensuretemp'), + 'test2.ensuretemp' : ('./test2/config.py', 'ensuretemp'), 'test.cmdline.main' : ('./test/cmdline.py', 'main'), + 'test2.cmdline.main' : ('./test2/cmdline.py', 'main'), # for customization of collecting/running tests 'test.collect.Collector' : ('./test/collect.py', 'Collector'), + 'test2.collect.Collector' : ('./test2/collect.py', 'Collector'), 'test.collect.Directory' : ('./test/collect.py', 'Directory'), + 'test2.collect.Directory' : ('./test2/collect.py', 'Directory'), 'test.collect.Module' : ('./test/collect.py', 'Module'), + 'test2.collect.Module' : ('./test2/collect.py', 'Module'), 'test.collect.DoctestFile' : ('./test/collect.py', 'DoctestFile'), + 'test2.collect.DoctestFile' : ('./test2/collect.py', 'DoctestFile'), 'test.collect.Class' : ('./test/collect.py', 'Class'), + 'test2.collect.Class' : ('./test2/collect.py', 'Class'), 'test.collect.Instance' : ('./test/collect.py', 'Instance'), + 'test2.collect.Instance' : ('./test2/collect.py', 'Instance'), 'test.collect.Generator' : ('./test/collect.py', 'Generator'), + 'test2.collect.Generator' : ('./test2/collect.py', 'Generator'), 'test.collect.Item' : ('./test/item.py', 'Item'), + 'test2.collect.Item' : ('./test2/item.py', 'Item'), 'test.collect.Function' : ('./test/item.py', 'Function'), + 'test2.collect.Function' : ('./test2/item.py', 'Function'), # Event related APIs 'event.Hub' : ('./event/hub.py', 'Hub'), Modified: py/branch/event/py/test2/box.py ============================================================================== --- py/branch/event/py/test/box.py (original) +++ py/branch/event/py/test2/box.py Wed Jan 30 20:38:14 2008 @@ -7,7 +7,7 @@ import os import sys import marshal -from py.__.test import config as pytestconfig +from py.__.test2 import config as pytestconfig PYTESTSTDOUT = "pyteststdout" PYTESTSTDERR = "pyteststderr" @@ -32,9 +32,9 @@ self.kwargs = kwargs def run(self, continuation=False): - # XXX we should not use py.test.ensuretemp here + # XXX we should not use py.test2.ensuretemp here count = counter() - tempdir = py.test.ensuretemp("box%d" % count) + tempdir = py.test2.ensuretemp("box%d" % count) self.tempdir = tempdir self.PYTESTRETVAL = tempdir.join('retval') self.PYTESTSTDOUT = tempdir.join('stdout') Modified: py/branch/event/py/test2/cmdline.py ============================================================================== --- py/branch/event/py/test/cmdline.py (original) +++ py/branch/event/py/test2/cmdline.py Wed Jan 30 20:38:14 2008 @@ -8,7 +8,7 @@ warn_about_missing_assertion() if args is None: args = py.std.sys.argv[1:] - config = py.test.config + config = py.test2.config config.parse(args) session = config.initsession() try: Modified: py/branch/event/py/test2/collect.py ============================================================================== --- py/branch/event/py/test/collect.py (original) +++ py/branch/event/py/test2/collect.py Wed Jan 30 20:38:14 2008 @@ -25,7 +25,7 @@ """ from __future__ import generators import py -from py.__.test.outcome import Skipped +from py.__.test2.outcome import Skipped def configproperty(name): def fget(self): @@ -45,7 +45,7 @@ def __init__(self, name, parent=None): self.name = name self.parent = parent - self._config = getattr(parent, '_config', py.test.config) + self._config = getattr(parent, '_config', py.test2.config) self.fspath = getattr(parent, 'fspath', None) Module = configproperty('Module') @@ -181,7 +181,7 @@ if eor: key = key[1:] if not (eor ^ self._matchonekeyword(key, chain)): - py.test.skip("test not selected by keyword %r" %(keyword,)) + py.test2.skip("test not selected by keyword %r" %(keyword,)) def _matchonekeyword(self, key, chain): elems = key.split(".") @@ -208,11 +208,11 @@ cases. """ if yieldtype is None: - yieldtype = py.test.collect.Item + yieldtype = py.test2.collect.Item if isinstance(self, yieldtype): yield self else: - if not isinstance(self, py.test.collect.Item): + if not isinstance(self, py.test2.collect.Item): try: for x in self.run(): for y in self.join(x)._tryiter(yieldtype): @@ -283,7 +283,7 @@ elif p.ext == '.txt': res = self.DoctestFile(p, parent=self) elif p.check(dir=1): - Directory = py.test.config.getvalue('Directory', p) + Directory = py.test2.config.getvalue('Directory', p) res = Directory(p, parent=self) name2items[name] = res return res @@ -430,7 +430,7 @@ except IOError: pass # fall back... - for x in self._tryiter((py.test.collect.Generator, py.test.collect.Item)): + for x in self._tryiter((py.test2.collect.Generator, py.test2.collect.Item)): return x._getsortvalue() class Instance(PyCollectorMixin, Collector): @@ -507,7 +507,7 @@ return [self.fspath.basename] def join(self, name): - from py.__.test.doctest import DoctestText + from py.__.test2.doctest import DoctestText if name == self.fspath.basename: item = DoctestText(self.fspath.basename, parent=self) item._content = self.fspath.read() Modified: py/branch/event/py/test2/collectonly.py ============================================================================== --- py/branch/event/py/test/collectonly.py (original) +++ py/branch/event/py/test2/collectonly.py Wed Jan 30 20:38:14 2008 @@ -3,8 +3,8 @@ """ import py -from py.__.test.session import Session -from py.__.test.reporter import LocalReporter +from py.__.test2.session import Session +from py.__.test2.reporter import LocalReporter class CollectReporter(LocalReporter): def __init__(self, *args, **kwds): Modified: py/branch/event/py/test2/compat.py ============================================================================== --- py/branch/event/py/test/compat.py (original) +++ py/branch/event/py/test2/compat.py Wed Jan 30 20:38:14 2008 @@ -1,5 +1,5 @@ import py -from py.__.test.outcome import Failed, Passed +from py.__.test2.outcome import Failed, Passed class TestCaseUnit(py.test.collect.Function): @@ -31,7 +31,7 @@ raise Failed(msg=msg) def assertRaises(self, excclass, func, *args, **kwargs): - py.test.raises(excclass, func, *args, **kwargs) + py.test2.raises(excclass, func, *args, **kwargs) failUnlessRaises = assertRaises # dynamically construct (redundant) methods Modified: py/branch/event/py/test2/config.py ============================================================================== --- py/branch/event/py/test/config.py (original) +++ py/branch/event/py/test2/config.py Wed Jan 30 20:38:14 2008 @@ -2,7 +2,7 @@ import py from conftesthandle import Conftest -from py.__.test.defaultconftest import adddefaultoptions +from py.__.test2.defaultconftest import adddefaultoptions optparse = py.compat.optparse @@ -173,13 +173,13 @@ """ this is used from tests that want to re-invoke parse(). """ #assert args # XXX should not be empty global config_per_process - oldconfig = py.test.config + oldconfig = py.test2.config try: - config_per_process = py.test.config = Config() + config_per_process = py.test2.config = Config() config_per_process.parse(args) return config_per_process finally: - config_per_process = py.test.config = oldconfig + config_per_process = py.test2.config = oldconfig def _makerepr(self, conftestnames, optnames=None): """ return a marshallable representation @@ -260,16 +260,16 @@ del colitem._capture colitem._captured_out, colitem._captured_err = capture.reset() -# this is the one per-process instance of py.test configuration +# this is the one per-process instance of py.test2 configuration config_per_process = Config() # default import paths for sessions -Session = 'py.__.test.session' -RemoteTerminalSession = 'py.__.test.terminal.remote' -RSession = 'py.__.test.rsession.rsession' -LSession = 'py.__.test.rsession.rsession' -CollectSession = 'py.__.test.collectonly' +Session = 'py.__.test2.session' +RemoteTerminalSession = 'py.__.test2.terminal.remote' +RSession = 'py.__.test2.rsession.rsession' +LSession = 'py.__.test2.rsession.rsession' +CollectSession = 'py.__.test2.collectonly' # # helpers Modified: py/branch/event/py/test2/conftesthandle.py ============================================================================== --- py/branch/event/py/test/conftesthandle.py (original) +++ py/branch/event/py/test2/conftesthandle.py Wed Jan 30 20:38:14 2008 @@ -3,7 +3,7 @@ class Conftest(object): """ the single place for accessing values and interacting - towards conftest modules from py.test objects. + towards conftest modules from py.test2 objects. Note that triggering Conftest instances to import conftest.py files may result in added cmdline options. Modified: py/branch/event/py/test2/defaultconftest.py ============================================================================== --- py/branch/event/py/test/defaultconftest.py (original) +++ py/branch/event/py/test2/defaultconftest.py Wed Jan 30 20:38:14 2008 @@ -1,12 +1,12 @@ import py -Module = py.test.collect.Module -DoctestFile = py.test.collect.DoctestFile -Directory = py.test.collect.Directory -Class = py.test.collect.Class -Generator = py.test.collect.Generator -Function = py.test.collect.Function -Instance = py.test.collect.Instance +Module = py.test2.collect.Module +DoctestFile = py.test2.collect.DoctestFile +Directory = py.test2.collect.Directory +Class = py.test2.collect.Class +Generator = py.test2.collect.Generator +Function = py.test2.collect.Function +Instance = py.test2.collect.Instance conf_iocapture = "fd" # overridable from conftest.py @@ -20,7 +20,7 @@ dist_taskspernode = 15 dist_boxed = False if hasattr(py.std.os, 'nice'): - dist_nicelevel = py.std.os.nice(0) # nice py.test works + dist_nicelevel = py.std.os.nice(0) # nice py.test2 works else: dist_nicelevel = 0 dist_rsync_ignore = [] Modified: py/branch/event/py/test2/doctest.py ============================================================================== --- py/branch/event/py/test/doctest.py (original) +++ py/branch/event/py/test2/doctest.py Wed Jan 30 20:38:14 2008 @@ -1,6 +1,6 @@ import py -class DoctestText(py.test.collect.Item): +class DoctestText(py.test2.collect.Item): def _setcontent(self, content): self._content = content @@ -29,5 +29,5 @@ mod.__doc__ = docstring failed, tot = py.compat.doctest.testmod(mod, verbose=1) if failed: - py.test.fail("doctest %s: %s failed out of %s" %( + py.test2.fail("doctest %s: %s failed out of %s" %( self.fspath, failed, tot)) Modified: py/branch/event/py/test2/executor.py ============================================================================== --- py/branch/event/py/test/executor.py (original) +++ py/branch/event/py/test2/executor.py Wed Jan 30 20:38:14 2008 @@ -3,11 +3,11 @@ import py, os, sys -from py.__.test.outcome import SerializableOutcome, ReprOutcome -from py.__.test.box import Box -from py.__.test import repevent -from py.__.test.outcome import Skipped, Failed -import py.__.test.custompdb +from py.__.test2.outcome import SerializableOutcome, ReprOutcome +from py.__.test2.box import Box +from py.__.test2 import repevent +from py.__.test2.outcome import Skipped, Failed +import py.__.test2.custompdb class RunExecutor(object): """ Same as in executor, but just running run @@ -48,7 +48,7 @@ excinfo = e.excinfo else: excinfo = py.code.ExceptionInfo() - if isinstance(self.item, py.test.collect.Function): + if isinstance(self.item, py.test2.collect.Function): fun = self.item.obj # hope this is stable code = py.code.Code(fun) excinfo.traceback = excinfo.traceback.cut( @@ -60,7 +60,7 @@ self.reporter(repevent.ImmediateFailure(self.item, ReprOutcome(outcome.make_repr (self.config.option.tbstyle)))) - py.__.test.custompdb.post_mortem(excinfo._excinfo[2]) + py.__.test2.custompdb.post_mortem(excinfo._excinfo[2]) # XXX hmm, we probably will not like to continue from that # point raise SystemExit() @@ -85,7 +85,7 @@ """ We want to trace *only* function objects here. Unsure what to do with custom collectors at all """ - if hasattr(self.item, 'obj') and type(self.item) is py.test.collect.Function: + if hasattr(self.item, 'obj') and type(self.item) is py.test2.collect.Function: self.item.execute = self.wrap_underlaying self.item.run() Modified: py/branch/event/py/test2/item.py ============================================================================== --- py/branch/event/py/test/item.py (original) +++ py/branch/event/py/test2/item.py Wed Jan 30 20:38:14 2008 @@ -1,8 +1,8 @@ import py from inspect import isclass, ismodule -from py.__.test.outcome import Skipped, Failed, Passed -from py.__.test.collect import FunctionMixin +from py.__.test2.outcome import Skipped, Failed, Passed +from py.__.test2.collect import FunctionMixin _dummy = object() @@ -31,7 +31,7 @@ col.setup() self.stack.append(col) -class Item(py.test.collect.Collector): +class Item(py.test2.collect.Collector): def startcapture(self): self._config._startcapture(self, path=self.fspath) Modified: py/branch/event/py/test2/raises.py ============================================================================== --- py/branch/event/py/test/raises.py (original) +++ py/branch/event/py/test2/raises.py Wed Jan 30 20:38:14 2008 @@ -1,6 +1,6 @@ import sys import py -from py.__.test.outcome import ExceptionFailure +from py.__.test2.outcome import ExceptionFailure def raises(ExpectedException, *args, **kwargs): """ raise AssertionError, if target code does not raise the expected Modified: py/branch/event/py/test2/repevent.py ============================================================================== --- py/branch/event/py/test/repevent.py (original) +++ py/branch/event/py/test2/repevent.py Wed Jan 30 20:38:14 2008 @@ -11,7 +11,7 @@ # pass ##def report_error(excinfo): -## if isinstance(excinfo, py.test.collect.Item.Skipped): +## if isinstance(excinfo, py.test2.collect.Item.Skipped): ## # we need to dispatch this info ## report(Skipped(excinfo)) ## else: Modified: py/branch/event/py/test2/reporter.py ============================================================================== --- py/branch/event/py/test/reporter.py (original) +++ py/branch/event/py/test2/reporter.py Wed Jan 30 20:38:14 2008 @@ -7,11 +7,11 @@ import py -from py.__.test.terminal.out import getout -from py.__.test import repevent -from py.__.test import outcome +from py.__.test2.terminal.out import getout +from py.__.test2 import repevent +from py.__.test2 import outcome from py.__.misc.terminal_helper import ansi_print, get_terminal_width -from py.__.test.representation import Presenter, repr_pythonversion,\ +from py.__.test2.representation import Presenter, repr_pythonversion,\ getrelpath import sys @@ -21,10 +21,10 @@ def choose_reporter(reporterclass, config): option = config.option if option.startserver or option.runbrowser: - from py.__.test.rsession.web import WebReporter + from py.__.test2.rsession.web import WebReporter return WebReporter if option.restreport: - from py.__.test.rsession.rest import RestReporter + from py.__.test2.rsession.rest import RestReporter return RestReporter else: return reporterclass @@ -378,7 +378,7 @@ def report_SkippedTryiter(self, event): #self.show_item(event.item, False) - if isinstance(event.item, py.test.collect.Module): + if isinstance(event.item, py.test2.collect.Module): self.out.write("- skipped (%s)" % event.excinfo.value) else: self.out.write("s") @@ -409,10 +409,10 @@ self.show_item(event.item) def show_item(self, item, count_elems = True): - if isinstance(item, py.test.collect.Module): + if isinstance(item, py.test2.collect.Module): self.show_Module(item) if self.config.option.verbose > 0 and\ - isinstance(item, py.test.collect.Item): + isinstance(item, py.test2.collect.Item): self.show_ItemVerbose(item) def show_ItemVerbose(self, item): Modified: py/branch/event/py/test2/representation.py ============================================================================== --- py/branch/event/py/test/representation.py (original) +++ py/branch/event/py/test2/representation.py Wed Jan 30 20:38:14 2008 @@ -51,14 +51,14 @@ self.out.line(prefix + source[i]) def repr_item_info(self, item): - """ This method represents py.test.collect.Item info (path and module) + """ This method represents py.test2.collect.Item info (path and module) """ root = item.fspath modpath = item._getmodpath() try: fn, lineno = item._getpathlineno() except TypeError: - assert isinstance(item.parent, py.test.collect.Generator) + assert isinstance(item.parent, py.test2.collect.Generator) # a generative test yielded a non-callable fn, lineno = item.parent._getpathlineno() if root == fn: Modified: py/branch/event/py/test2/rsession/hostmanage.py ============================================================================== --- py/branch/event/py/test/rsession/hostmanage.py (original) +++ py/branch/event/py/test2/rsession/hostmanage.py Wed Jan 30 20:38:14 2008 @@ -2,10 +2,10 @@ import py import time import thread, threading -from py.__.test.rsession.master import MasterNode -from py.__.test.rsession.slave import setup_slave +from py.__.test2.rsession.master import MasterNode +from py.__.test2.rsession.slave import setup_slave -from py.__.test import repevent +from py.__.test2 import repevent class HostInfo(object): """ Class trying to store all necessary attributes Modified: py/branch/event/py/test2/rsession/local.py ============================================================================== --- py/branch/event/py/test/rsession/local.py (original) +++ py/branch/event/py/test2/rsession/local.py Wed Jan 30 20:38:14 2008 @@ -3,10 +3,10 @@ """ import py -from py.__.test.executor import BoxExecutor, RunExecutor,\ +from py.__.test2.executor import BoxExecutor, RunExecutor,\ ApigenExecutor -from py.__.test import repevent -from py.__.test.outcome import ReprOutcome +from py.__.test2 import repevent +from py.__.test2.outcome import ReprOutcome # XXX copied from session.py def startcapture(session): Modified: py/branch/event/py/test2/rsession/master.py ============================================================================== --- py/branch/event/py/test/rsession/master.py (original) +++ py/branch/event/py/test2/rsession/master.py Wed Jan 30 20:38:14 2008 @@ -2,9 +2,9 @@ Node code for Master. """ import py -from py.__.test.outcome import ReprOutcome -from py.__.test import repevent -from py.__.test.outcome import Skipped +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): Modified: py/branch/event/py/test2/rsession/rest.py ============================================================================== --- py/branch/event/py/test/rsession/rest.py (original) +++ py/branch/event/py/test2/rsession/rest.py Wed Jan 30 20:38:14 2008 @@ -5,8 +5,8 @@ import py import sys from StringIO import StringIO -from py.__.test.reporter import AbstractReporter -from py.__.test import repevent +from py.__.test2.reporter import AbstractReporter +from py.__.test2 import repevent from py.__.rest.rst import * class RestReporter(AbstractReporter): @@ -71,7 +71,7 @@ def report_ItemStart(self, event): item = event.item - if isinstance(item, py.test.collect.Module): + if isinstance(item, py.test2.collect.Module): lgt = len(list(item._tryiter())) lns = item.listnames()[1:] name = "/".join(lns) Modified: py/branch/event/py/test2/rsession/rsession.py ============================================================================== --- py/branch/event/py/test/rsession/rsession.py (original) +++ py/branch/event/py/test2/rsession/rsession.py Wed Jan 30 20:38:14 2008 @@ -8,14 +8,14 @@ import re import time -from py.__.test import repevent -from py.__.test.rsession.master import MasterNode, dispatch_loop -from py.__.test.rsession.hostmanage import HostInfo, HostManager -from py.__.test.rsession.local import local_loop, plain_runner, apigen_runner,\ +from py.__.test2 import repevent +from py.__.test2.rsession.master import MasterNode, 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.__.test.reporter import LocalReporter, RemoteReporter, TestReporter -from py.__.test.session import AbstractSession, itemgen -from py.__.test.outcome import Skipped, Failed +from py.__.test2.reporter import LocalReporter, RemoteReporter, TestReporter +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/test/rsession/slave.py (original) +++ py/branch/event/py/test2/rsession/slave.py Wed Jan 30 20:38:14 2008 @@ -3,9 +3,9 @@ """ import py -from py.__.test.executor import RunExecutor, BoxExecutor, AsyncExecutor -from py.__.test.outcome import SerializableOutcome -from py.__.test.outcome import Skipped +from py.__.test2.executor import RunExecutor, BoxExecutor, AsyncExecutor +from py.__.test2.outcome import SerializableOutcome +from py.__.test2.outcome import Skipped import thread import os @@ -38,7 +38,7 @@ node = nodes.get(item[0], None) if node is not None: return node - col = py.test.collect.Directory(str(py.path.local(path).join(item[0]))) + col = py.test2.collect.Directory(str(py.path.local(path).join(item[0]))) if config.option.boxed: executor = BoxExecutor else: @@ -88,7 +88,7 @@ # setup defaults... sys.path.insert(0, basedir) import py - config = py.test.config + config = py.test2.config assert not config._initialized config._initdirect(basedir, config_repr) if hasattr(os, 'nice'): @@ -96,7 +96,7 @@ os.nice(nice_level) if not config.option.nomagic: py.magic.invoke(assertion=1) - from py.__.test.rsession.slave import slave_main + from py.__.test2.rsession.slave import slave_main slave_main(channel.receive, channel.send, basedir, config) if not config.option.nomagic: py.magic.revoke(assertion=1) Modified: py/branch/event/py/test2/rsession/testing/basetest.py ============================================================================== --- py/branch/event/py/test/rsession/testing/basetest.py (original) +++ py/branch/event/py/test2/rsession/testing/basetest.py Wed Jan 30 20:38:14 2008 @@ -14,7 +14,7 @@ raise AssertionError("hello world") def funcskip(): - py.test.skip("skipped") + py.test2.skip("skipped") def funcprint(): print "samfing" @@ -24,7 +24,7 @@ asddsa def funcoptioncustom(): - assert py.test.config.getvalue("custom") + assert py.test2.config.getvalue("custom") def funchang(): import time @@ -32,11 +32,11 @@ class BasicRsessionTest(object): def setup_class(cls): - tmpdir = py.test.ensuretemp(cls.__name__) + tmpdir = py.test2.ensuretemp(cls.__name__) source = py.code.Source(func_source)[1:].deindent() testonepath = tmpdir.ensure("test_one.py") testonepath.write(source) - cls.config = py.test.config._reparse([tmpdir]) + cls.config = py.test2.config._reparse([tmpdir]) cls.collector_test_one = cls.config._getcollector(testonepath) cls.doctest = tmpdir.ensure("xxx.txt").write(py.code.Source(""" Aha!!!!!! Modified: py/branch/event/py/test2/rsession/testing/test_hostmanage.py ============================================================================== --- py/branch/event/py/test/rsession/testing/test_hostmanage.py (original) +++ py/branch/event/py/test2/rsession/testing/test_hostmanage.py Wed Jan 30 20:38:14 2008 @@ -3,14 +3,14 @@ """ import py -from py.__.test.rsession.hostmanage import HostRSync, HostInfo, HostManager -from py.__.test.rsession.hostmanage import sethomedir, gethomedir, getpath_relto_home -from py.__.test import repevent +from py.__.test2.rsession.hostmanage import HostRSync, HostInfo, HostManager +from py.__.test2.rsession.hostmanage import sethomedir, gethomedir, getpath_relto_home +from py.__.test2 import repevent class DirSetup: def setup_method(self, method): name = "%s.%s" %(self.__class__.__name__, method.func_name) - self.tmpdir = py.test.ensuretemp(name) + self.tmpdir = py.test2.ensuretemp(name) self.source = self.tmpdir.ensure("source", dir=1) self.dest = self.tmpdir.join("dest") @@ -53,7 +53,7 @@ def test_non_existing_hosts(self): host = HostInfo("alskdjalsdkjasldkajlsd") - py.test.raises((py.process.cmdexec.Error, IOError, EOFError), + py.test2.raises((py.process.cmdexec.Error, IOError, EOFError), host.initgateway) def test_remote_has_homedir_as_currentdir(self): @@ -85,7 +85,7 @@ host.gw.exit() def test_initgateway_ssh_and_remotepath(self): - option = py.test.config.option + option = py.test2.config.option if getattr(option, 'sshtarget', None) is None: py.test.skip("no known ssh target, use -S to set one") host = HostInfo("%s" % (option.sshtarget, )) @@ -174,14 +174,14 @@ if dist_rsync_roots: l.append("dist_rsync_roots = %r" % dist_rsync_roots) self.source.join("conftest.py").write("\n".join(l)) - config = py.test.config._reparse([self.source]) + config = py.test2.config._reparse([self.source]) assert config.topdir == self.source hm = HostManager(config) assert hm.hosts return hm def test_hostmanager_custom_hosts(self): - config = py.test.config._reparse([self.source]) + config = py.test2.config._reparse([self.source]) hm = HostManager(config, hosts=[1,2,3]) assert hm.hosts == [1,2,3] @@ -220,7 +220,7 @@ self.source.join("conftest.py").write(py.code.Source(""" dist_rsync_roots = ['dir1/dir2'] """)) - config = py.test.config._reparse([self.source]) + config = py.test2.config._reparse([self.source]) hm = HostManager(config, hosts=[HostInfo("localhost:" + str(self.dest))]) events = [] @@ -237,7 +237,7 @@ self.source.join("conftest.py").write(py.code.Source(""" dist_rsync_ignore = ['dir1/dir2', 'dir5/dir6'] """)) - config = py.test.config._reparse([self.source]) + config = py.test2.config._reparse([self.source]) hm = HostManager(config, hosts=[HostInfo("localhost:" + str(self.dest))]) events = [] @@ -250,7 +250,7 @@ def test_hostmanage_optimise_localhost(self): hosts = [HostInfo("localhost") for i in range(3)] - config = py.test.config._reparse([self.source]) + config = py.test2.config._reparse([self.source]) hm = HostManager(config, hosts=hosts) events = [] hm.init_rsync(events.append) @@ -262,7 +262,7 @@ def XXXtest_ssh_rsync_samehost_twice(self): #XXX we have no easy way to have a temp directory remotely! - option = py.test.config.option + option = py.test2.config.option if option.sshtarget is None: py.test.skip("no known ssh target, use -S to set one") host1 = HostInfo("%s" % (option.sshtarget, )) Modified: py/branch/event/py/test2/rsession/testing/test_master.py ============================================================================== --- py/branch/event/py/test/rsession/testing/test_master.py (original) +++ py/branch/event/py/test2/rsession/testing/test_master.py Wed Jan 30 20:38:14 2008 @@ -9,17 +9,17 @@ if sys.platform == 'win32': py.test.skip("rsession is unsupported on Windows.") -from py.__.test.rsession.master import dispatch_loop, MasterNode -from py.__.test.rsession.slave import setup_slave -from py.__.test.outcome import ReprOutcome, SerializableOutcome -from py.__.test import repevent -from py.__.test.rsession.hostmanage import HostInfo +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.test.ensuretemp(mod.__name__) + mod.tmpdir = tmpdir = py.test2.ensuretemp(mod.__name__) # to avoid rsyncing - config = py.test.config._reparse([tmpdir]) + config = py.test2.config._reparse([tmpdir]) config.option.dist_taskspernode = 10 mod.rootcol = config._getcollector(tmpdir) @@ -49,7 +49,7 @@ def _getremoteerror(self): return "blah" -class Item(py.test.collect.Item): +class Item(py.test2.collect.Item): def _get_collector_trail(self): return (self.name,) @@ -77,7 +77,7 @@ reportlist = [] mnode = MasterNode(ch, reportlist.append) cap = py.io.StdCaptureFD() - py.test.raises(IOError, 'mnode.send(Item("ok"))') + py.test2.raises(IOError, 'mnode.send(Item("ok"))') out, err = cap.reset() assert out.find("blah") != -1 @@ -118,7 +118,7 @@ class TestSlave: def setup_class(cls): - cls.tmpdir = tmpdir = py.test.ensuretemp(cls.__name__) + 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(""" @@ -128,7 +128,7 @@ def funcfail(): raise AssertionError("hello world") """)) - cls.config = py.test.config._reparse([tmpdir]) + cls.config = py.test2.config._reparse([tmpdir]) assert cls.config.topdir == tmpdir cls.rootcol = cls.config._getcollector(tmpdir) @@ -153,7 +153,7 @@ host.gw_remotepath = '' host.gw = gw #gw.host.gw = gw - config = py.test.config._reparse([tmpdir]) + config = py.test2.config._reparse([tmpdir]) channel = setup_slave(host, config) mn = MasterNode(channel, simple_report) return mn @@ -182,13 +182,13 @@ gw = py.execnet.PopenGateway() gw.host = HostInfo("localhost") gw.host.gw = gw - config = py.test.config._reparse([tmpdir]) + 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.test.collect.Directory(pkgdir) + rootcol = py.test2.collect.Directory(pkgdir) funchang_item = rootcol._getitembynames(funchang_spec) mn.send(funchang_item) mn.send(StopIteration) Modified: py/branch/event/py/test2/rsession/testing/test_rest.py ============================================================================== --- py/branch/event/py/test/rsession/testing/test_rest.py (original) +++ py/branch/event/py/test2/rsession/testing/test_rest.py Wed Jan 30 20:38:14 2008 @@ -3,13 +3,13 @@ """ import py -from py.__.test.testing.test_reporter import AbstractTestReporter,\ +from py.__.test2.testing.test_reporter import AbstractTestReporter,\ DummyChannel -from py.__.test import repevent -from py.__.test.rsession.rest import RestReporter, NoLinkWriter +from py.__.test2 import repevent +from py.__.test2.rsession.rest import RestReporter, NoLinkWriter from py.__.rest.rst import * -from py.__.test.rsession.hostmanage import HostInfo -from py.__.test.outcome import SerializableOutcome +from py.__.test2.rsession.hostmanage import HostInfo +from py.__.test2.outcome import SerializableOutcome class Container(object): def __init__(self, **args): @@ -23,7 +23,7 @@ class TestRestUnits(object): def setup_method(self, method): - config = py.test.config._reparse(["some_sub"]) + config = py.test2.config._reparse(["some_sub"]) config.option.verbose = False self.config = config hosts = [HostInfo('localhost')] @@ -79,7 +79,7 @@ """ def test_report_ItemStart(self): - class FakeModule(py.test.collect.Module): + class FakeModule(py.test2.collect.Module): def __init__(self, parent): self.parent = parent self.fspath = py.path.local('.') Modified: py/branch/event/py/test2/rsession/testing/test_rsession.py ============================================================================== --- py/branch/event/py/test/rsession/testing/test_rsession.py (original) +++ py/branch/event/py/test2/rsession/testing/test_rsession.py Wed Jan 30 20:38:14 2008 @@ -3,11 +3,11 @@ """ import py -from py.__.test import repevent -from py.__.test.rsession.rsession import RSession -from py.__.test.rsession.hostmanage import HostManager, HostInfo -from py.__.test.rsession.testing.basetest import BasicRsessionTest -from py.__.test.rsession.testing.test_hostmanage import DirSetup +from py.__.test2 import repevent +from py.__.test2.rsession.rsession import RSession +from py.__.test2.rsession.hostmanage import HostManager, HostInfo +from py.__.test2.rsession.testing.basetest import BasicRsessionTest +from py.__.test2.rsession.testing.test_hostmanage import DirSetup def setup_module(mod): mod.pkgdir = py.path.local(py.__file__).dirpath() @@ -25,7 +25,7 @@ pass def test_x(): import py - py.test.skip("aaa") + py.test2.skip("aaa") def test_2(): assert 0 def test_3(): @@ -33,7 +33,7 @@ def test_4(someargs): pass """)) - config = py.test.config._reparse([self.source.join("sub"), '-x']) + config = py.test2.config._reparse([self.source.join("sub"), '-x']) allevents = [] rsession = RSession(config) rsession.main(allevents.append) @@ -42,7 +42,7 @@ assert len(testevents) == 3 def test_distribution_rsync_roots_example(self): - destdir = py.test.ensuretemp("example_dist_destdir") + destdir = py.test2.ensuretemp("example_dist_destdir") subdir = "sub_example_dist" tmpdir = self.source tmpdir.ensure(subdir, "conftest.py").write(py.code.Source(""" @@ -66,7 +66,7 @@ # assert py.__file__ != '%s' """ % (tmpdir.join(subdir), py.__file__))) destdir.join("py").mksymlinkto(py.path.local(py.__file__).dirpath()) - config = py.test.config._reparse([tmpdir.join(subdir)]) + config = py.test2.config._reparse([tmpdir.join(subdir)]) assert config.topdir == tmpdir assert not tmpdir.join("__init__.py").check() allevents = [] @@ -101,7 +101,7 @@ setup_events = [] teardown_events = [] tmpdir = self.source - config = py.test.config._reparse([tmpdir]) + config = py.test2.config._reparse([tmpdir]) hm = HostManager(config, hosts) nodes = hm.setup_hosts(setup_events.append) hm.teardown_hosts(teardown_events.append, @@ -129,7 +129,7 @@ hm = HostManager(self.config, hosts=hosts) nodes = hm.setup_hosts(allevents.append) - from py.__.test.testing.test_executor \ + from py.__.test2.testing.test_executor \ import ItemTestPassing, ItemTestFailing, ItemTestSkipping itempass = self.getexample("pass") @@ -175,7 +175,7 @@ assert os.nice(0) == 10 """) - config = py.test.config._reparse([tmpdir]) + config = py.test2.config._reparse([tmpdir]) rsession = RSession(config) rsession.main(allevents.append) testevents = [x for x in allevents @@ -184,7 +184,7 @@ assert len(passevents) == 1 def test_rsession_no_disthost(): - tmpdir = py.test.ensuretemp("rsession_no_disthost") + tmpdir = py.test2.ensuretemp("rsession_no_disthost") tmpdir.ensure("conftest.py") - config = py.test.config._reparse([str(tmpdir), '-d']) - py.test.raises(SystemExit, "config.initsession()") + config = py.test2.config._reparse([str(tmpdir), '-d']) + py.test2.raises(SystemExit, "config.initsession()") Modified: py/branch/event/py/test2/rsession/testing/test_slave.py ============================================================================== --- py/branch/event/py/test/rsession/testing/test_slave.py (original) +++ py/branch/event/py/test2/rsession/testing/test_slave.py Wed Jan 30 20:38:14 2008 @@ -1,9 +1,9 @@ """ Testing the slave side node code (in a local way). """ -from py.__.test.rsession.slave import SlaveNode, slave_main, setup -from py.__.test.outcome import ReprOutcome +from py.__.test2.rsession.slave import SlaveNode, slave_main, setup +from py.__.test2.outcome import ReprOutcome import py, sys -from py.__.test.rsession.testing.basetest import BasicRsessionTest +from py.__.test2.rsession.testing.basetest import BasicRsessionTest modlevel = [] import os @@ -13,7 +13,7 @@ # ---------------------------------------------------------------------- -from py.__.test.executor import RunExecutor +from py.__.test2.executor import RunExecutor class TestSlave(BasicRsessionTest): def gettestnode(self): Modified: py/branch/event/py/test2/rsession/testing/test_web.py ============================================================================== --- py/branch/event/py/test/rsession/testing/test_web.py (original) +++ py/branch/event/py/test2/rsession/testing/test_web.py Wed Jan 30 20:38:14 2008 @@ -15,14 +15,14 @@ mod.commproxy.USE_MOCHIKIT = False mod.rpython2javascript = rpython2javascript mod.commproxy = mod.commproxy - from py.__.test.rsession.web import TestHandler as _TestHandler - from py.__.test.rsession.web import MultiQueue + from py.__.test2.rsession.web import TestHandler as _TestHandler + from py.__.test2.rsession.web import MultiQueue mod._TestHandler = _TestHandler mod.MultiQueue = MultiQueue def test_js_generate(): - from py.__.test.rsession import webjs - from py.__.test.rsession.web import FUNCTION_LIST, IMPORTED_PYPY + from py.__.test2.rsession import webjs + from py.__.test2.rsession.web import FUNCTION_LIST, IMPORTED_PYPY source = rpython2javascript(webjs, FUNCTION_LIST, use_pdb=False) assert source @@ -36,7 +36,7 @@ assert h.parse_args('foo=bar%20baz') == {'foo': 'bar baz'} assert h.parse_args('foo%20bar=baz') == {'foo bar': 'baz'} assert h.parse_args('foo=bar%baz') == {'foo': 'bar\xbaz'} - py.test.raises(ValueError, 'h.parse_args("foo")') + py.test2.raises(ValueError, 'h.parse_args("foo")') class TestMultiQueue(object): def test_get_one_sessid(self): Modified: py/branch/event/py/test2/rsession/testing/test_webjs.py ============================================================================== --- py/branch/event/py/test/rsession/testing/test_webjs.py (original) +++ py/branch/event/py/test2/rsession/testing/test_webjs.py Wed Jan 30 20:38:14 2008 @@ -12,8 +12,8 @@ mod.dom = dom mod.schedule_callbacks = schedule_callbacks - from py.__.test.rsession import webjs - from py.__.test.rsession.web import exported_methods + from py.__.test2.rsession import webjs + from py.__.test2.rsession.web import exported_methods mod.webjs = webjs mod.exported_methods = exported_methods mod.here = py.magic.autopath().dirpath() @@ -28,8 +28,8 @@ mod.dom = dom dom.window = dom.Window(html) dom.document = dom.window.document - from py.__.test.rsession import webjs - from py.__.test.rsession.web import exported_methods + from py.__.test2.rsession import webjs + from py.__.test2.rsession.web import exported_methods mod.webjs = webjs mod.exported_methods = exported_methods Modified: py/branch/event/py/test2/rsession/web.py ============================================================================== --- py/branch/event/py/test/rsession/web.py (original) +++ py/branch/event/py/test2/rsession/web.py Wed Jan 30 20:38:14 2008 @@ -14,10 +14,10 @@ import socket import py -from py.__.test.rsession.rsession import RSession -from py.__.test import repevent -from py.__.test import collect -from py.__.test.rsession.webdata import json +from py.__.test2.rsession.rsession import RSession +from py.__.test2 import repevent +from py.__.test2 import collect +from py.__.test2.rsession.webdata import json DATADIR = py.path.local(__file__).dirpath("webdata") FUNCTION_LIST = ["main", "show_skip", "show_traceback", "show_info", "hide_info", @@ -59,7 +59,7 @@ return d class MultiQueue(object): - """ a tailor-made queue (internally using Queue) for py.test.rsession.web + """ a tailor-made queue (internally using Queue) for py.test2.rsession.web API-wise the main difference is that the get() method gets a sessid argument, which is used to determine what data to feed to the client @@ -290,7 +290,7 @@ self.pending_events.put(event) def report_ItemStart(self, event): - if isinstance(event.item, py.test.collect.Module): + if isinstance(event.item, py.test2.collect.Module): self.pending_events.put(event) def report_unknown(self, event): @@ -406,7 +406,7 @@ web_name = py.path.local(__file__).dirpath().join("webjs.py") if IMPORTED_PYPY and web_name.mtime() > js_name.mtime() or \ (not js_name.check()): - from py.__.test.rsession import webjs + from py.__.test2.rsession import webjs javascript_source = rpython2javascript(webjs, FUNCTION_LIST, use_pdb=False) Modified: py/branch/event/py/test2/rsession/webjs.py ============================================================================== --- py/branch/event/py/test/rsession/webjs.py (original) +++ py/branch/event/py/test2/rsession/webjs.py Wed Jan 30 20:38:14 2008 @@ -1,14 +1,14 @@ -""" javascript source for py.test distributed +""" javascript source for py.test2 distributed """ import py -from py.__.test.rsession.web import exported_methods +from py.__.test2.rsession.web import exported_methods try: from pypy.translator.js.modules import dom from pypy.translator.js.helper import __show_traceback except ImportError: - py.test.skip("PyPy not found") + py.test2.skip("PyPy not found") def create_elem(s): return dom.document.createElement(s) Modified: py/branch/event/py/test2/session.py ============================================================================== --- py/branch/event/py/test/session.py (original) +++ py/branch/event/py/test2/session.py Wed Jan 30 20:38:14 2008 @@ -1,11 +1,11 @@ import py import sys -from py.__.test.outcome import Outcome, Failed, Passed, Skipped -from py.__.test.reporter import choose_reporter, TestReporter -from py.__.test import repevent -from py.__.test.outcome import SerializableOutcome, ReprOutcome -from py.__.test.reporter import LocalReporter -from py.__.test.executor import RunExecutor, BoxExecutor +from py.__.test2.outcome import Outcome, Failed, Passed, Skipped +from py.__.test2.reporter import choose_reporter, TestReporter +from py.__.test2 import repevent +from py.__.test2.outcome import SerializableOutcome, ReprOutcome +from py.__.test2.reporter import LocalReporter +from py.__.test2.executor import RunExecutor, BoxExecutor """ The session implementation - reporter version: @@ -22,7 +22,7 @@ GeneratorExit = StopIteration # I think def itemgen(session, colitems, reporter, keyword=None): - stopitems = py.test.collect.Item # XXX should be generator here as well + stopitems = py.test2.collect.Item # XXX should be generator here as well while 1: if not colitems: break @@ -110,7 +110,7 @@ def footer(self, colitems): """ teardown any resources after a test run. """ - py.test.collect.Function._state.teardown_all() + py.test2.collect.Function._state.teardown_all() if not self.config.option.nomagic: py.magic.revoke(assertion=1) self.reporter(repevent.TestFinished()) Modified: py/branch/event/py/test2/terminal/remote.py ============================================================================== --- py/branch/event/py/test/terminal/remote.py (original) +++ py/branch/event/py/test2/terminal/remote.py Wed Jan 30 20:38:14 2008 @@ -1,8 +1,8 @@ from __future__ import generators import py -from py.__.test.session import Session -from py.__.test.terminal.out import getout -from py.__.test.outcome import Failed, Passed, Skipped +from py.__.test2.session import Session +from py.__.test2.terminal.out import getout +from py.__.test2.outcome import Failed, Passed, Skipped def checkpyfilechange(rootdir, statcache={}): """ wait until project files are changed. """ @@ -35,9 +35,9 @@ for rootpath, names in failures: root = py.path.local(rootpath) if root.check(dir=1): - current = py.test.collect.Directory(root).Directory(root) + current = py.test2.collect.Directory(root).Directory(root) elif root.check(file=1): - current = py.test.collect.Module(root).Module(root) + current = py.test2.collect.Module(root).Module(root) # root is fspath of names[0] -> pop names[0] # slicing works with empty lists names = names[1:] @@ -99,7 +99,7 @@ def run_remote_session(self, failures): gw, topdir = self._initslavegateway() channel = gw.remote_exec(""" - from py.__.test.terminal.remote import slaverun_TerminalSession + from py.__.test2.terminal.remote import slaverun_TerminalSession slaverun_TerminalSession(channel) """, stdout=self.out, stderr=self.out) try: @@ -123,7 +123,7 @@ print "SLAVE: initializing ..." topdir, repr, failures = channel.receive() print "SLAVE: received configuration, using topdir:", topdir - config = py.test.config + config = py.test2.config config._initdirect(topdir, repr, failures) config.option.session = None config.option.looponfailing = False Modified: py/branch/event/py/test2/testing/setupdata.py ============================================================================== --- py/branch/event/py/test/testing/setupdata.py (original) +++ py/branch/event/py/test2/testing/setupdata.py Wed Jan 30 20:38:14 2008 @@ -2,10 +2,10 @@ def setup_module(mod): mod.datadir = setupdatadir() - mod.tmpdir = py.test.ensuretemp(mod.__name__) + mod.tmpdir = py.test2.ensuretemp(mod.__name__) def setupdatadir(): - datadir = py.test.ensuretemp("datadir") + datadir = py.test2.ensuretemp("datadir") names = [x.basename for x in datadir.listdir()] for name, content in namecontent: if name not in names: @@ -55,7 +55,7 @@ def test_explicit_bad_repr(self): t = BrokenRepr1() - py.test.raises(Exception, 'repr(t)') + py.test2.raises(Exception, 'repr(t)') def test_implicit_bad_repr1(self): t = BrokenRepr1() Modified: py/branch/event/py/test2/testing/test_boxing.py ============================================================================== --- py/branch/event/py/test/testing/test_boxing.py (original) +++ py/branch/event/py/test2/testing/test_boxing.py Wed Jan 30 20:38:14 2008 @@ -7,12 +7,12 @@ if sys.platform == 'win32': py.test.skip("rsession is unsupported on Windows.") -from py.__.test.box import Box -from py.__.test.testing import example2 +from py.__.test2.box import Box +from py.__.test2.testing import example2 def setup_module(mod): - tmpdir = py.test.ensuretemp("boxtests") - mod.config = py.test.config._reparse([tmpdir]) + tmpdir = py.test2.ensuretemp("boxtests") + mod.config = py.test2.config._reparse([tmpdir]) def test_basic_boxing(): # XXX: because we do not have option transfer Modified: py/branch/event/py/test2/testing/test_collect.py ============================================================================== --- py/branch/event/py/test/testing/test_collect.py (original) +++ py/branch/event/py/test2/testing/test_collect.py Wed Jan 30 20:38:14 2008 @@ -1,9 +1,9 @@ from __future__ import generators import py from setupdata import setupdatadir -from py.__.test.outcome import Skipped, Failed, Passed, Outcome -from py.__.test.terminal.out import getout -from py.__.test.repevent import ReceivedItemOutcome +from py.__.test2.outcome import Skipped, Failed, Passed, Outcome +from py.__.test2.terminal.out import getout +from py.__.test2.repevent import ReceivedItemOutcome def getpassed(all): outcomes = [i.outcome for i in all if isinstance(i, ReceivedItemOutcome)] @@ -12,16 +12,16 @@ def setup_module(mod): mod.datadir = setupdatadir() - mod.tmpdir = py.test.ensuretemp('test_collect') + mod.tmpdir = py.test2.ensuretemp('test_collect') def test_failing_import_execfile(): dest = datadir / 'failingimport.py' - col = py.test.collect.Module(dest) - py.test.raises(ImportError, col.run) - py.test.raises(ImportError, col.run) + col = py.test2.collect.Module(dest) + py.test2.raises(ImportError, col.run) + py.test2.raises(ImportError, col.run) def test_collect_listnames_and_back(): - col1 = py.test.collect.Directory(datadir.dirpath()) + col1 = py.test2.collect.Directory(datadir.dirpath()) col2 = col1.join(datadir.basename) col3 = col2.join('filetest.py') l = col3.listnames() @@ -35,26 +35,26 @@ def test_finds_tests(): fn = datadir / 'filetest.py' - col = py.test.collect.Module(fn) + col = py.test2.collect.Module(fn) l = col.run() assert len(l) == 2 assert l[0] == 'test_one' assert l[1] == 'TestClass' def test_found_certain_testfiles(): - tmp = py.test.ensuretemp("found_certain_testfiles") + tmp = py.test2.ensuretemp("found_certain_testfiles") tmp.ensure('test_found.py') tmp.ensure('found_test.py') - colitem = py.test.collect.Directory(tmp) - items = list(colitem._tryiter(py.test.collect.Module)) + colitem = py.test2.collect.Directory(tmp) + items = list(colitem._tryiter(py.test2.collect.Module)) assert len(items) == 2 items = [item.name for item in items] assert 'test_found.py' in items assert 'found_test.py' in items def test_ignored_certain_directories(): - tmp = py.test.ensuretemp("ignore_certain_directories") + tmp = py.test2.ensuretemp("ignore_certain_directories") tmp.ensure("_darcs", 'test_notfound.py') tmp.ensure("CVS", 'test_notfound.py') tmp.ensure("{arch}", 'test_notfound.py') @@ -63,45 +63,45 @@ tmp.ensure("normal", 'test_found.py') tmp.ensure('test_found.py') - colitem = py.test.collect.Directory(tmp) - items = list(colitem._tryiter(py.test.collect.Module)) + colitem = py.test2.collect.Directory(tmp) + items = list(colitem._tryiter(py.test2.collect.Module)) assert len(items) == 2 for item in items: assert item.name == 'test_found.py' def test_failing_import_directory(): - class MyDirectory(py.test.collect.Directory): + class MyDirectory(py.test2.collect.Directory): def filefilter(self, p): return p.check(fnmatch='testspecial*.py') mydir = MyDirectory(datadir) l = mydir.run() assert len(l) == 1 item = mydir.join(l[0]) - assert isinstance(item, py.test.collect.Module) - py.test.raises(ImportError, item.run) + assert isinstance(item, py.test2.collect.Module) + py.test2.raises(ImportError, item.run) def test_module_file_not_found(): fn = datadir.join('nada','no') - col = py.test.collect.Module(fn) - py.test.raises(py.error.ENOENT, col.run) + col = py.test2.collect.Module(fn) + py.test2.raises(py.error.ENOENT, col.run) def test_syntax_error_in_module(): - p = py.test.ensuretemp("syntaxerror1").join('syntax_error.py') + p = py.test2.ensuretemp("syntaxerror1").join('syntax_error.py') p.write("\nthis is really not python\n") modpath = datadir.join('syntax_error.py') - col = py.test.collect.Module(modpath) - py.test.raises(SyntaxError, col.run) + col = py.test2.collect.Module(modpath) + py.test2.raises(SyntaxError, col.run) def test_disabled_class(): - col = py.test.collect.Module(datadir.join('disabled.py')) + col = py.test2.collect.Module(datadir.join('disabled.py')) l = col.run() assert len(l) == 1 colitem = col.join(l[0]) - assert isinstance(colitem, py.test.collect.Class) + assert isinstance(colitem, py.test2.collect.Class) assert not colitem.run() def test_disabled_module(): - col = py.test.collect.Module(datadir.join('disabled_module.py')) + col = py.test2.collect.Module(datadir.join('disabled_module.py')) l = col.run() assert len(l) == 0 @@ -112,7 +112,7 @@ #class TestWithCustomItem: -# class Item(py.test.collect.Item): +# class Item(py.test2.collect.Item): # flag = [] # def execute(self, target, *args): # self.flag.append(42) @@ -139,18 +139,18 @@ yield func1, 17, 3*5 yield func1, 42, 6*7 """)) - col = py.test.collect.Module(tfile) + col = py.test2.collect.Module(tfile) l = col.run() assert len(l) == 2 l = col.multijoin(l) generator = l[0] - assert isinstance(generator, py.test.collect.Generator) + assert isinstance(generator, py.test2.collect.Generator) l2 = generator.run() assert len(l2) == 2 l2 = generator.multijoin(l2) - assert isinstance(l2[0], py.test.collect.Function) - assert isinstance(l2[1], py.test.collect.Function) + assert isinstance(l2[0], py.test2.collect.Function) + assert isinstance(l2[1], py.test2.collect.Function) assert l2[0].name == '[0]' assert l2[1].name == '[1]' @@ -161,12 +161,12 @@ classlist = l[1].multijoin(classlist) cls = classlist[0] generator = cls.join(cls.run()[0]) - assert isinstance(generator, py.test.collect.Generator) + assert isinstance(generator, py.test2.collect.Generator) l2 = generator.run() assert len(l2) == 2 l2 = generator.multijoin(l2) - assert isinstance(l2[0], py.test.collect.Function) - assert isinstance(l2[1], py.test.collect.Function) + assert isinstance(l2[0], py.test2.collect.Function) + assert isinstance(l2[1], py.test2.collect.Function) assert l2[0].name == '[0]' assert l2[1].name == '[1]' @@ -174,9 +174,9 @@ o = tmpdir.ensure('customconfigtest', dir=1) o.ensure('conftest.py').write("""if 1: import py - class MyFunction(py.test.collect.Function): + class MyFunction(py.test2.collect.Function): pass - class Directory(py.test.collect.Directory): + class Directory(py.test2.collect.Directory): def filefilter(self, fspath): return fspath.check(basestarts='check_', ext='.py') class myfuncmixin: @@ -184,10 +184,10 @@ def funcnamefilter(self, name): return name.startswith('check_') - class Module(myfuncmixin, py.test.collect.Module): + class Module(myfuncmixin, py.test2.collect.Module): def classnamefilter(self, name): return name.startswith('CustomTestClass') - class Instance(myfuncmixin, py.test.collect.Instance): + class Instance(myfuncmixin, py.test2.collect.Instance): pass """) checkfile = o.ensure('somedir', 'check_something.py') @@ -200,16 +200,16 @@ """) for x in (o, checkfile, checkfile.dirpath()): - config = py.test.config._reparse([x]) + config = py.test2.config._reparse([x]) #print "checking that %s returns custom items" % (x,) col = config._getcollector(x) - assert len(list(col._tryiter(py.test.collect.Item))) == 2 + assert len(list(col._tryiter(py.test2.collect.Item))) == 2 #assert items[1].__class__.__name__ == 'MyFunction' # test that running a session works from the directories old = o.chdir() try: - config = py.test.config._reparse([]) + config = py.test2.config._reparse([]) all = [] session = config._getsessionclass()(config) session.main(all.append) @@ -219,7 +219,7 @@ old.chdir() # test that running the file directly works - config = py.test.config._reparse([str(checkfile)]) + config = py.test2.config._reparse([str(checkfile)]) all = [] session = config._getsessionclass()(config) session.main(all.append) @@ -230,11 +230,11 @@ o = tmpdir.ensure('customconfigtest_nonpython', dir=1) o.ensure('conftest.py').write("""if 1: import py - class CustomItem(py.test.collect.Item): + class CustomItem(py.test2.collect.Item): def run(self): pass - class Directory(py.test.collect.Directory): + class Directory(py.test2.collect.Directory): def filefilter(self, fspath): return fspath.check(basestarts='check_', ext='.txt') def join(self, name): @@ -248,15 +248,15 @@ for x in (o, checkfile, checkfile.dirpath()): print "checking that %s returns custom items" % (x,) - config = py.test.config._reparse([x]) + config = py.test2.config._reparse([x]) col = config._getcollector(x) - assert len(list(col._tryiter(py.test.collect.Item))) == 1 + assert len(list(col._tryiter(py.test2.collect.Item))) == 1 #assert items[1].__class__.__name__ == 'MyFunction' # test that running a session works from the directories old = o.chdir() try: - config = py.test.config._reparse([]) + config = py.test2.config._reparse([]) all = [] session = config._getsessionclass()(config) session.main(all.append) @@ -266,7 +266,7 @@ old.chdir() # test that running the file directly works - config = py.test.config._reparse([str(checkfile)]) + config = py.test2.config._reparse([str(checkfile)]) all = [] session = config._getsessionclass()(config) session.main(all.append) @@ -292,7 +292,7 @@ yield list_append, i yield assert_order_of_execution """)) - config = py.test.config._reparse([o]) + config = py.test2.config._reparse([o]) all = [] session = config.initsession() session.main(all.append) @@ -325,7 +325,7 @@ yield list_append_2 yield assert_order_of_execution """)) - config = py.test.config._reparse([o]) + config = py.test2.config._reparse([o]) all = [] session = config.initsession() session.main(all.append) @@ -341,60 +341,60 @@ old = conf.option.forcegen try: conf.option.forcegen = 1 - col = py.test.collect.Directory(rootdir) - x = list(col._tryiter(yieldtype=py.test.collect.Function)) + col = py.test2.collect.Directory(rootdir) + x = list(col._tryiter(yieldtype=py.test2.collect.Function)) finally: conf.option.forcegen = old def test__tryiter_ignores_skips(): - tmp = py.test.ensuretemp("_tryiterskip") + tmp = py.test2.ensuretemp("_tryiterskip") tmp.ensure("subdir", "conftest.py").write(py.code.Source(""" import py - class Directory(py.test.collect.Directory): + class Directory(py.test2.collect.Directory): def run(self): py.test.skip("intentional") """)) - col = py.test.collect.Directory(tmp) + col = py.test2.collect.Directory(tmp) try: list(col._tryiter()) except KeyboardInterrupt: raise except: exc = py.code.ExceptionInfo() - py.test.fail("should not have raised: %s" %(exc,)) + py.test2.fail("should not have raised: %s" %(exc,)) def test__tryiter_ignores_failing_collectors(): - tmp = py.test.ensuretemp("_tryiterfailing") + tmp = py.test2.ensuretemp("_tryiterfailing") tmp.ensure("subdir", "conftest.py").write(py.code.Source(""" bla bla bla """)) - col = py.test.collect.Directory(tmp) + col = py.test2.collect.Directory(tmp) try: list(col._tryiter()) except KeyboardInterrupt: raise except: exc = py.code.ExceptionInfo() - py.test.fail("should not have raised: %s" %(exc,)) + py.test2.fail("should not have raised: %s" %(exc,)) l = [] def test_tryiter_handles_keyboardinterrupt(): - tmp = py.test.ensuretemp("tryiterkeyboard") + tmp = py.test2.ensuretemp("tryiterkeyboard") tmp.ensure("subdir", "conftest.py").write(py.code.Source(""" raise KeyboardInterrupt() """)) - col = py.test.collect.Directory(tmp) - py.test.raises(KeyboardInterrupt, list, col._tryiter()) + col = py.test2.collect.Directory(tmp) + py.test2.raises(KeyboardInterrupt, list, col._tryiter()) def test_check_random_inequality(): - tmp = py.test.ensuretemp("ineq") + tmp = py.test2.ensuretemp("ineq") tmp.ensure("test_x.py").write(py.code.Source("""def test_one(): pass """)) - col = py.test.collect.Directory(tmp) + col = py.test2.collect.Directory(tmp) fn = col._tryiter().next() assert fn != 3 assert fn != col @@ -403,7 +403,7 @@ assert col != fn def test_check_generator_collect_problems(): - tmp = py.test.ensuretemp("gener_coll") + tmp = py.test2.ensuretemp("gener_coll") tmp.ensure("test_one.py").write(py.code.Source(""" def setup_module(mod): mod.x = [1,2,3] @@ -416,12 +416,12 @@ yield check, i """)) tmp.ensure("__init__.py") - col = py.test.collect.Module(tmp.join("test_one.py")) + col = py.test2.collect.Module(tmp.join("test_one.py")) assert len(col.join('test_one').run()) == 3 def test_generator_setup_invoked_twice(): py.test.skip("Test for generators not invoking setup, needs thinking") - tmp = py.test.ensuretemp("generator_setup_invoke") + tmp = py.test2.ensuretemp("generator_setup_invoke") tmp.ensure("test_one.py").write(py.code.Source(""" def setup_module(mod): mod.x = [] @@ -433,12 +433,12 @@ yield lambda: None """)) tmp.ensure("__init__.py") - col = py.test.collect.Module(tmp.join("test_one.py")) + col = py.test2.collect.Module(tmp.join("test_one.py")) l = list(col._tryiter()) assert not hasattr(col.obj, 'x') def test_check_collect_hashes(): - tmp = py.test.ensuretemp("check_collect_hashes") + tmp = py.test2.ensuretemp("check_collect_hashes") tmp.ensure("test_one.py").write(py.code.Source(""" def test_1(): pass @@ -454,7 +454,7 @@ pass """)) tmp.ensure("__init__.py") - col = py.test.collect.Directory(tmp) + col = py.test2.collect.Directory(tmp) l = list(col._tryiter()) assert len(l) == 4 for numi, i in enumerate(l): @@ -465,7 +465,7 @@ def test_check_directory_ordered(): - tmpdir = py.test.ensuretemp("test_check_directory_ordered") + tmpdir = py.test2.ensuretemp("test_check_directory_ordered") fnames = [] for i in range(9, -1, -1): x = tmpdir.ensure("xdir%d" %(i, ), dir=1) @@ -476,7 +476,7 @@ fnames.sort() tmpdir.ensure('adir', dir=1) fnames.insert(10, 'adir') - col = py.test.collect.Directory(tmpdir) + col = py.test2.collect.Directory(tmpdir) names = col.run() assert names == fnames Modified: py/branch/event/py/test2/testing/test_collectonly.py ============================================================================== --- py/branch/event/py/test/testing/test_collectonly.py (original) +++ py/branch/event/py/test2/testing/test_collectonly.py Wed Jan 30 20:38:14 2008 @@ -3,7 +3,7 @@ class TestCollectonly: def setup_class(cls): - tmp = py.test.ensuretemp('itemgentest') + tmp = py.test2.ensuretemp('itemgentest') tmp.ensure("__init__.py") tmp.ensure("test_one.py").write(py.code.Source(""" def test_one(): @@ -24,7 +24,7 @@ cls.tmp = tmp def test_collectonly(self): - config = py.test.config._reparse([self.tmp, '--collectonly']) + config = py.test2.config._reparse([self.tmp, '--collectonly']) session = config.initsession() # test it all in once cap = py.io.StdCaptureFD() Modified: py/branch/event/py/test2/testing/test_compat.py ============================================================================== --- py/branch/event/py/test/testing/test_compat.py (original) +++ py/branch/event/py/test2/testing/test_compat.py Wed Jan 30 20:38:14 2008 @@ -1,7 +1,7 @@ from __future__ import generators import py -from py.__.test.compat import TestCase -from py.__.test.outcome import Failed +from py.__.test2.compat import TestCase +from py.__.test2.outcome import Failed class TestCompatTestCaseSetupSemantics(TestCase): globlist = [] Modified: py/branch/event/py/test2/testing/test_config.py ============================================================================== --- py/branch/event/py/test/testing/test_config.py (original) +++ py/branch/event/py/test2/testing/test_config.py Wed Jan 30 20:38:14 2008 @@ -1,22 +1,22 @@ from __future__ import generators import py -from py.__.test.config import gettopdir +from py.__.test2.config import gettopdir def test_tmpdir(): - d1 = py.test.ensuretemp('hello') - d2 = py.test.ensuretemp('hello') + d1 = py.test2.ensuretemp('hello') + d2 = py.test2.ensuretemp('hello') assert d1 == d2 assert d1.check(dir=1) def test_config_cmdline_options(): - o = py.test.ensuretemp('configoptions') + o = py.test2.ensuretemp('configoptions') o.ensure("conftest.py").write(py.code.Source(""" import py def _callback(option, opt_str, value, parser, *args, **kwargs): option.tdest = True - Option = py.test.config.Option - option = py.test.config.addoptions("testing group", + Option = py.test2.config.Option + option = py.test2.config.addoptions("testing group", Option('-G', '--glong', action="store", default=42, type="int", dest="gdest", help="g value."), # XXX note: special case, option without a destination @@ -26,53 +26,53 @@ """)) old = o.chdir() try: - config = py.test.config._reparse(['-G', '17']) + config = py.test2.config._reparse(['-G', '17']) finally: old.chdir() assert config.option.gdest == 17 def test_config_cmdline_options_only_lowercase(): - o = py.test.ensuretemp('test_config_cmdline_options_only_lowercase') + o = py.test2.ensuretemp('test_config_cmdline_options_only_lowercase') o.ensure("conftest.py").write(py.code.Source(""" import py - Option = py.test.config.Option - options = py.test.config.addoptions("testing group", + Option = py.test2.config.Option + options = py.test2.config.addoptions("testing group", Option('-g', '--glong', action="store", default=42, type="int", dest="gdest", help="g value."), ) """)) old = o.chdir() try: - py.test.raises(ValueError, """ - py.test.config._reparse(['-g', '17']) + py.test2.raises(ValueError, """ + py.test2.config._reparse(['-g', '17']) """) finally: old.chdir() def test_parsing_again_fails(): - dir = py.test.ensuretemp("parsing_again_fails") - config = py.test.config._reparse([str(dir)]) - py.test.raises(AssertionError, "config.parse([])") + dir = py.test2.ensuretemp("parsing_again_fails") + config = py.test2.config._reparse([str(dir)]) + py.test2.raises(AssertionError, "config.parse([])") def test_config_getvalue_honours_conftest(): - o = py.test.ensuretemp('testconfigget') + o = py.test2.ensuretemp('testconfigget') o.ensure("conftest.py").write("x=1") o.ensure("sub", "conftest.py").write("x=2 ; y = 3") - config = py.test.config._reparse([str(o)]) + config = py.test2.config._reparse([str(o)]) assert config.getvalue("x") == 1 assert config.getvalue("x", o.join('sub')) == 2 - py.test.raises(KeyError, "config.getvalue('y')") - config = py.test.config._reparse([str(o.join('sub'))]) + py.test2.raises(KeyError, "config.getvalue('y')") + config = py.test2.config._reparse([str(o.join('sub'))]) assert config.getvalue("x") == 2 assert config.getvalue("y") == 3 assert config.getvalue("x", o) == 1 - py.test.raises(KeyError, 'config.getvalue("y", o)') + py.test2.raises(KeyError, 'config.getvalue("y", o)') def test_siblingconftest_fails_maybe(): - from py.__.test import config + from py.__.test2 import config cfg = config.Config() - o = py.test.ensuretemp('siblingconftest') + o = py.test2.ensuretemp('siblingconftest') o.ensure("__init__.py") o.ensure("sister1", "__init__.py") o.ensure("sister1", "conftest.py").write(py.code.Source(""" @@ -96,23 +96,23 @@ old.chdir() def test_config_overwrite(): - o = py.test.ensuretemp('testconfigget') + o = py.test2.ensuretemp('testconfigget') o.ensure("conftest.py").write("x=1") - config = py.test.config._reparse([str(o)]) + config = py.test2.config._reparse([str(o)]) assert config.getvalue('x') == 1 config.option.x = 2 assert config.getvalue('x') == 2 - config = py.test.config._reparse([str(o)]) + config = py.test2.config._reparse([str(o)]) assert config.getvalue('x') == 1 def test_gettopdir(): - tmp = py.test.ensuretemp("topdir") + tmp = py.test2.ensuretemp("topdir") assert gettopdir([tmp]) == tmp topdir =gettopdir([tmp.join("hello"), tmp.join("world")]) assert topdir == tmp def test_gettopdir_pypkg(): - tmp = py.test.ensuretemp("topdir2") + tmp = py.test2.ensuretemp("topdir2") a = tmp.ensure('a', dir=1) b = tmp.ensure('a', 'b', '__init__.py') c = tmp.ensure('a', 'b', 'c.py') @@ -122,19 +122,19 @@ def test_config_init_direct(): - tmp = py.test.ensuretemp("_initdirect") + tmp = py.test2.ensuretemp("_initdirect") tmp.ensure("__init__.py") tmp.ensure("conftest.py").write("x=1 ; y=2") hello = tmp.ensure("test_hello.py") - config = py.test.config._reparse([hello]) + config = py.test2.config._reparse([hello]) repr = config._makerepr(conftestnames=['x', 'y']) - config2 = py.test.config._reparse([tmp.dirpath()]) + config2 = py.test2.config._reparse([tmp.dirpath()]) config2._initialized = False # we have to do that from tests config2._initdirect(topdir=tmp.dirpath(), repr=repr) for col1, col2 in zip(config.getcolitems(), config2.getcolitems()): assert col1.fspath == col2.fspath - py.test.raises(AssertionError, "config2._initdirect(None, None)") - from py.__.test.config import Config + py.test2.raises(AssertionError, "config2._initdirect(None, None)") + from py.__.test2.config import Config config3 = Config() config3._initdirect(topdir=tmp.dirpath(), repr=repr, coltrails=[(tmp.basename, (hello.basename,))]) @@ -148,107 +148,107 @@ assert col.parent.parent is None def test_config_make_and__mergerepr(): - tmp = py.test.ensuretemp("reprconfig1") + tmp = py.test2.ensuretemp("reprconfig1") tmp.ensure("__init__.py") tmp.ensure("conftest.py").write("x=1") - config = py.test.config._reparse([tmp]) + config = py.test2.config._reparse([tmp]) repr = config._makerepr(conftestnames=['x']) config.option.verbose = 42 repr2 = config._makerepr(conftestnames=[], optnames=['verbose']) - config = py.test.config._reparse([tmp.dirpath()]) - py.test.raises(KeyError, "config.getvalue('x')") + config = py.test2.config._reparse([tmp.dirpath()]) + py.test2.raises(KeyError, "config.getvalue('x')") config._mergerepr(repr) assert config.getvalue('x') == 1 config._mergerepr(repr2) assert config.option.verbose == 42 def test_config_marshability(): - tmp = py.test.ensuretemp("configmarshal") + tmp = py.test2.ensuretemp("configmarshal") tmp.ensure("__init__.py") tmp.ensure("conftest.py").write("a = object()") - config = py.test.config._reparse([tmp]) - py.test.raises(ValueError, "config._makerepr(conftestnames=['a'])") + config = py.test2.config._reparse([tmp]) + py.test2.raises(ValueError, "config._makerepr(conftestnames=['a'])") config.option.hello = lambda x: None - py.test.raises(ValueError, "config._makerepr(conftestnames=[])") + py.test2.raises(ValueError, "config._makerepr(conftestnames=[])") config._makerepr(conftestnames=[], optnames=[]) def test_config_rconfig(): - tmp = py.test.ensuretemp("rconfigopt") + tmp = py.test2.ensuretemp("rconfigopt") tmp.ensure("__init__.py") tmp.ensure("conftest.py").write(py.code.Source(""" import py - Option = py.test.config.Option - option = py.test.config.addoptions("testing group", + Option = py.test2.config.Option + option = py.test2.config.addoptions("testing group", Option('-G', '--glong', action="store", default=42, type="int", dest="gdest", help="g value.")) """)) - config = py.test.config._reparse([tmp, "-G", "11"]) + config = py.test2.config._reparse([tmp, "-G", "11"]) assert config.option.gdest == 11 repr = config._makerepr(conftestnames=[]) - config = py.test.config._reparse([tmp.dirpath()]) - py.test.raises(AttributeError, "config.option.gdest") + config = py.test2.config._reparse([tmp.dirpath()]) + py.test2.raises(AttributeError, "config.option.gdest") config._mergerepr(repr) assert config.option.gdest == 11 class TestSessionAndOptions: def setup_class(cls): - cls.tmproot = py.test.ensuretemp(cls.__name__) + cls.tmproot = py.test2.ensuretemp(cls.__name__) def setup_method(self, method): self.tmpdir = self.tmproot.ensure(method.__name__, dir=1) def test_sessionname_default(self): - config = py.test.config._reparse([self.tmpdir]) + config = py.test2.config._reparse([self.tmpdir]) assert config._getsessionname() == 'Session' def test_sessionname_dist(self): - config = py.test.config._reparse([self.tmpdir, '--dist']) + config = py.test2.config._reparse([self.tmpdir, '--dist']) assert config._getsessionname() == 'RSession' def test_implied_lsession(self): #optnames = 'startserver runbrowser apigen=x rest boxed'.split() #for x in optnames: - # config = py.test.config._reparse([self.tmpdir, '--%s' % x]) + # config = py.test2.config._reparse([self.tmpdir, '--%s' % x]) # assert config._getsessionname() == 'LSession' for x in 'startserver runbrowser rest'.split(): - config = py.test.config._reparse([self.tmpdir, '--dist', '--%s' % x]) + config = py.test2.config._reparse([self.tmpdir, '--dist', '--%s' % x]) assert config._getsessionname() == 'RSession' def test_implied_different_sessions(self): - config = py.test.config._reparse([self.tmpdir, '--looponfailing']) + config = py.test2.config._reparse([self.tmpdir, '--looponfailing']) assert config._getsessionname() == 'RemoteTerminalSession' - config = py.test.config._reparse([self.tmpdir, '--exec=x']) + config = py.test2.config._reparse([self.tmpdir, '--exec=x']) assert config._getsessionname() == 'RemoteTerminalSession' - config = py.test.config._reparse([self.tmpdir, '--dist', '--exec=x']) + config = py.test2.config._reparse([self.tmpdir, '--dist', '--exec=x']) assert config._getsessionname() == 'RSession' - config = py.test.config._reparse([self.tmpdir, '--collectonly']) + config = py.test2.config._reparse([self.tmpdir, '--collectonly']) assert config._getsessionname() == 'CollectSession' def test_sessionname_lookup_custom(self): self.tmpdir.join("conftest.py").write(py.code.Source(""" - from py.__.test.session import Session + from py.__.test2.session import Session class MySession(Session): def __init__(self, config, reporter=None): self.config = config """)) - config = py.test.config._reparse(["--session=MySession", self.tmpdir]) + config = py.test2.config._reparse(["--session=MySession", self.tmpdir]) session = config.initsession() assert session.__class__.__name__ == 'MySession' def test_initsession(self): - config = py.test.config._reparse([self.tmpdir]) + config = py.test2.config._reparse([self.tmpdir]) session = config.initsession() assert session.config is config def test_boxed_option_default(self): self.tmpdir.join("conftest.py").write("dist_hosts=[]") tmpdir = self.tmpdir.ensure("subdir", dir=1) - config = py.test.config._reparse([tmpdir]) + config = py.test2.config._reparse([tmpdir]) config.initsession() assert not config.option.boxed - config = py.test.config._reparse(['--dist', tmpdir]) + config = py.test2.config._reparse(['--dist', tmpdir]) config.initsession() assert not config.option.boxed @@ -259,7 +259,7 @@ dist_hosts = [] dist_boxed = True """)) - config = py.test.config._reparse(['--dist', tmpdir]) + config = py.test2.config._reparse(['--dist', tmpdir]) config.initsession() assert config.option.boxed @@ -268,21 +268,21 @@ tmpdir.join("conftest.py").write(py.code.Source(""" dist_boxed = False """)) - config = py.test.config._reparse([tmpdir, '--box']) + config = py.test2.config._reparse([tmpdir, '--box']) assert config.option.boxed config.initsession() assert config.option.boxed def test_dist_session_no_capturedisable(self): - config = py.test.config._reparse([self.tmpdir, '-d', '-s']) - py.test.raises(SystemExit, "config.initsession()") + config = py.test2.config._reparse([self.tmpdir, '-d', '-s']) + py.test2.raises(SystemExit, "config.initsession()") def test_getvalue_pathlist(self): tmpdir = self.tmpdir somepath = tmpdir.join("x", "y", "z") p = tmpdir.join("conftest.py") p.write("pathlist = ['.', %r]" % str(somepath)) - config = py.test.config._reparse([p]) + config = py.test2.config._reparse([p]) assert config.getvalue_pathlist('notexist') is None pl = config.getvalue_pathlist('pathlist') print pl @@ -296,13 +296,13 @@ def test_config_iocapturing(self): self.tmpdir - config = py.test.config._reparse([self.tmpdir]) + config = py.test2.config._reparse([self.tmpdir]) assert config.getvalue("conf_iocapture") tmpdir = self.tmpdir.ensure("sub-with-conftest", dir=1) tmpdir.join("conftest.py").write(py.code.Source(""" conf_iocapture = "sys" """)) - config = py.test.config._reparse([tmpdir]) + config = py.test2.config._reparse([tmpdir]) assert config.getvalue("conf_iocapture") == "sys" class dummy: pass config._startcapture(dummy) @@ -311,7 +311,7 @@ config._finishcapture(dummy) assert dummy._captured_out.strip() == "42" - config = py.test.config._reparse([tmpdir.dirpath()]) + config = py.test2.config._reparse([tmpdir.dirpath()]) config._startcapture(dummy, path=tmpdir) print 42 py.std.os.write(1, "23") @@ -320,22 +320,22 @@ class TestConfigColitems: def setup_class(cls): - cls.tmproot = py.test.ensuretemp(cls.__name__) + cls.tmproot = py.test2.ensuretemp(cls.__name__) def setup_method(self, method): self.tmpdir = self.tmproot.mkdir(method.__name__) def test_getcolitems_onedir(self): - config = py.test.config._reparse([self.tmpdir]) + config = py.test2.config._reparse([self.tmpdir]) colitems = config.getcolitems() assert len(colitems) == 1 col = colitems[0] - assert isinstance(col, py.test.collect.Directory) + assert isinstance(col, py.test2.collect.Directory) for col in col.listchain(): assert col._config is config def test_getcolitems_twodirs(self): - config = py.test.config._reparse([self.tmpdir, self.tmpdir]) + config = py.test2.config._reparse([self.tmpdir, self.tmpdir]) colitems = config.getcolitems() assert len(colitems) == 2 col1, col2 = colitems @@ -344,7 +344,7 @@ def test_getcolitems_curdir_and_subdir(self): a = self.tmpdir.ensure("a", dir=1) - config = py.test.config._reparse([self.tmpdir, a]) + config = py.test2.config._reparse([self.tmpdir, a]) colitems = config.getcolitems() assert len(colitems) == 2 col1, col2 = colitems @@ -356,9 +356,9 @@ def test__getcol_global_file(self): x = self.tmpdir.ensure("x.py") - config = py.test.config._reparse([x]) + config = py.test2.config._reparse([x]) col = config._getcollector(x) - assert isinstance(col, py.test.collect.Module) + assert isinstance(col, py.test2.collect.Module) assert col.name == 'x.py' assert col.parent.name == self.tmpdir.basename assert col.parent.parent is None @@ -367,9 +367,9 @@ def test__getcol_global_dir(self): x = self.tmpdir.ensure("a", dir=1) - config = py.test.config._reparse([x]) + config = py.test2.config._reparse([x]) col = config._getcollector(x) - assert isinstance(col, py.test.collect.Directory) + assert isinstance(col, py.test2.collect.Directory) print col.listchain() assert col.name == 'a' assert col.parent is None @@ -378,9 +378,9 @@ def test__getcol_pkgfile(self): x = self.tmpdir.ensure("x.py") self.tmpdir.ensure("__init__.py") - config = py.test.config._reparse([x]) + config = py.test2.config._reparse([x]) col = config._getcollector(x) - assert isinstance(col, py.test.collect.Module) + assert isinstance(col, py.test2.collect.Module) assert col.name == 'x.py' assert col.parent.name == x.dirpath().basename assert col.parent.parent is None @@ -391,7 +391,7 @@ a = self.tmpdir.ensure("a", dir=1) self.tmpdir.ensure("a", "__init__.py") x = self.tmpdir.ensure("a", "trail.py") - config = py.test.config._reparse([x]) + config = py.test2.config._reparse([x]) col = config._getcollector(x) trail = config.get_collector_trail(col) assert len(trail) == 2 @@ -401,7 +401,7 @@ assert col2.listnames() == col.listnames() def test_get_collector_trail_topdir_and_beyond(self): - config = py.test.config._reparse([self.tmpdir]) + config = py.test2.config._reparse([self.tmpdir]) col = config._getcollector(config.topdir) trail = config.get_collector_trail(col) assert len(trail) == 2 @@ -411,6 +411,6 @@ assert col2.fspath == config.topdir assert len(col2.listchain()) == 1 col3 = config._getcollector(config.topdir.dirpath()) - py.test.raises(ValueError, + py.test2.raises(ValueError, "config.get_collector_trail(col3)") Modified: py/branch/event/py/test2/testing/test_conftesthandle.py ============================================================================== --- py/branch/event/py/test/testing/test_conftesthandle.py (original) +++ py/branch/event/py/test2/testing/test_conftesthandle.py Wed Jan 30 20:38:14 2008 @@ -1,5 +1,5 @@ import py -from py.__.test.conftesthandle import Conftest +from py.__.test2.conftesthandle import Conftest class TestConftestValueAccessGlobal: def setup_class(cls): @@ -7,7 +7,7 @@ # and thus no further import scope) it should still all work # because "global" conftests are imported with a # mangled module name (related to their actual path) - cls.basedir = d = py.test.ensuretemp(cls.__name__) + cls.basedir = d = py.test2.ensuretemp(cls.__name__) d.ensure("adir/conftest.py").write("a=1 ; Directory = 3") d.ensure("adir/b/conftest.py").write("b=2 ; a = 1.5") @@ -30,18 +30,18 @@ def test_default_Module_setting_is_visible_always(self): for path in self.basedir.parts(): conftest = Conftest(path) - #assert conftest.lget("Module") == py.test.collect.Module - assert conftest.rget("Module") == py.test.collect.Module + #assert conftest.lget("Module") == py.test2.collect.Module + assert conftest.rget("Module") == py.test2.collect.Module def test_default_has_lower_prio(self): conftest = Conftest(self.basedir.join("adir")) assert conftest.rget('Directory') == 3 - #assert conftest.lget('Directory') == py.test.collect.Directory + #assert conftest.lget('Directory') == py.test2.collect.Directory def test_value_access_not_existing(self): conftest = Conftest(self.basedir) - py.test.raises(KeyError, "conftest.rget('a')") - #py.test.raises(KeyError, "conftest.lget('a')") + py.test2.raises(KeyError, "conftest.rget('a')") + #py.test2.raises(KeyError, "conftest.lget('a')") def test_value_access_by_path(self): conftest = Conftest(self.basedir) @@ -50,7 +50,7 @@ assert conftest.rget("a", self.basedir.join('adir', 'b')) == 1.5 #assert conftest.lget("a", self.basedir.join('adir', 'b')) == 1 #assert conftest.lget("b", self.basedir.join('adir', 'b')) == 2 - #assert py.test.raises(KeyError, + #assert py.test2.raises(KeyError, # 'conftest.lget("b", self.basedir.join("a"))' #) Modified: py/branch/event/py/test2/testing/test_deprecated.py ============================================================================== --- py/branch/event/py/test/testing/test_deprecated.py (original) +++ py/branch/event/py/test2/testing/test_deprecated.py Wed Jan 30 20:38:14 2008 @@ -11,11 +11,11 @@ filename="hello", lineno=3) def test_deprecated_call_raises(): - py.test.raises(AssertionError, - "py.test.deprecated_call(dep, 3)") + py.test2.raises(AssertionError, + "py.test2.deprecated_call(dep, 3)") def test_deprecated_call(): - py.test.deprecated_call(dep, 0) + py.test2.deprecated_call(dep, 0) def test_deprecated_call_preserves(): r = py.std.warnings.onceregistry.copy() @@ -26,10 +26,10 @@ assert f == py.std.warnings.filters def test_deprecated_explicit_call_raises(): - py.test.raises(AssertionError, - "py.test.deprecated_call(dep_explicit, 3)") + py.test2.raises(AssertionError, + "py.test2.deprecated_call(dep_explicit, 3)") def test_deprecated_explicit_call(): - py.test.deprecated_call(dep_explicit, 0) - py.test.deprecated_call(dep_explicit, 0) + py.test2.deprecated_call(dep_explicit, 0) + py.test2.deprecated_call(dep_explicit, 0) Modified: py/branch/event/py/test2/testing/test_doctest.py ============================================================================== --- py/branch/event/py/test/testing/test_doctest.py (original) +++ py/branch/event/py/test2/testing/test_doctest.py Wed Jan 30 20:38:14 2008 @@ -1,7 +1,7 @@ import py -from py.__.test.doctest import DoctestText -from py.__.test.outcome import Skipped, Failed, Passed, Outcome +from py.__.test2.doctest import DoctestText +from py.__.test2.outcome import Skipped, Failed, Passed, Outcome def test_simple_docteststring(): testitem = DoctestText(name="dummy", parent=None) @@ -20,11 +20,11 @@ >>> i + 1 2 """) - py.test.raises(Failed, "testitem.run()") + py.test2.raises(Failed, "testitem.run()") def test_collect_doctest_files_with_test_prefix(): - o = py.test.ensuretemp("testdoctest") + o = py.test2.ensuretemp("testdoctest") checkfile = o.ensure("test_something.txt") o.ensure("whatever.txt") checkfile.write(py.code.Source(""" @@ -35,9 +35,9 @@ """)) for x in (o, checkfile): #print "checking that %s returns custom items" % (x,) - config = py.test.config._reparse([x]) + config = py.test2.config._reparse([x]) col = config._getcollector(x) - items = list(col._tryiter(py.test.collect.Item)) + items = list(col._tryiter(py.test2.collect.Item)) assert len(items) == 1 assert isinstance(items[0], DoctestText) Modified: py/branch/event/py/test2/testing/test_executor.py ============================================================================== --- py/branch/event/py/test/testing/test_executor.py (original) +++ py/branch/event/py/test2/testing/test_executor.py Wed Jan 30 20:38:14 2008 @@ -2,17 +2,17 @@ import py import example1 -from py.__.test.executor import RunExecutor, BoxExecutor,\ +from py.__.test2.executor import RunExecutor, BoxExecutor,\ AsyncExecutor, ApigenExecutor -from py.__.test.outcome import ReprOutcome -from py.__.test.rsession.testing.basetest import BasicRsessionTest -from py.__.test.outcome import Failed +from py.__.test2.outcome import ReprOutcome +from py.__.test2.rsession.testing.basetest import BasicRsessionTest +from py.__.test2.outcome import Failed def setup_module(mod): if py.std.sys.platform == "win32": py.test.skip("skipping executor tests (some require os.fork)") -class Item(py.test.collect.Item): +class Item(py.test2.collect.Item): def __init__(self, name, config): super(Item, self).__init__(name) self._config = config @@ -27,7 +27,7 @@ class ItemTestSkipping(Item): def run(self): - py.test.skip("hello") + py.test2.skip("hello") class ItemTestPrinting(Item): def run(self): @@ -39,7 +39,7 @@ class ItemTestFailingExplicitEmpty(Item): def run(self): - py.test.raises(ValueError, lambda : 123) + py.test2.raises(ValueError, lambda : 123) class TestExecutor(BasicRsessionTest): def test_run_executor(self): @@ -118,7 +118,7 @@ def end_tracing(self): self.ends += 1 - tmpdir = py.test.ensuretemp("apigen_executor") + tmpdir = py.test2.ensuretemp("apigen_executor") tmpdir.ensure("__init__.py") tmpdir.ensure("test_one.py").write(py.code.Source(""" def g(): @@ -137,7 +137,7 @@ def test_raise(self): 1/0 """)) - config = py.test.config._reparse([tmpdir]) + config = py.test2.config._reparse([tmpdir]) rootcol = config._getcollector(tmpdir) tracer = Tracer() item = rootcol._getitembynames("test_one.py/test_1") Modified: py/branch/event/py/test2/testing/test_itemgen.py ============================================================================== --- py/branch/event/py/test/testing/test_itemgen.py (original) +++ py/branch/event/py/test2/testing/test_itemgen.py Wed Jan 30 20:38:14 2008 @@ -1,7 +1,7 @@ import py -from py.__.test.session import itemgen -from py.__.test import repevent +from py.__.test2.session import itemgen +from py.__.test2 import repevent class TestItemgen: def setup_class(cls): @@ -20,14 +20,15 @@ """)) tmp.ensure("test_two.py").write(py.code.Source(""" import py - py.test.skip('xxx') + py.test2.skip('xxx') """)) tmp.ensure("test_three.py").write("xxxdsadsadsadsa") cls.tmp = tmp def test_itemgen(self): + py.test.skip("itemgen test needs revamp but itemgen needs refactoring anyway") l = [] - colitems = [py.test.collect.Directory(self.tmp)] + 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 Modified: py/branch/event/py/test2/testing/test_outcome.py ============================================================================== --- py/branch/event/py/test/testing/test_outcome.py (original) +++ py/branch/event/py/test2/testing/test_outcome.py Wed Jan 30 20:38:14 2008 @@ -1,6 +1,6 @@ import py -from py.__.test.outcome import SerializableOutcome, ReprOutcome, ExcInfoRepr +from py.__.test2.outcome import SerializableOutcome, ReprOutcome, ExcInfoRepr import marshal import py Modified: py/branch/event/py/test2/testing/test_remote.py ============================================================================== --- py/branch/event/py/test/testing/test_remote.py (original) +++ py/branch/event/py/test2/testing/test_remote.py Wed Jan 30 20:38:14 2008 @@ -1,5 +1,5 @@ import py -from py.__.test.testing.setupdata import setup_module +from py.__.test2.testing.setupdata import setup_module class TestRemote: def test_exec(self): @@ -10,7 +10,7 @@ assert 1 == 0 """)) print py.std.sys.executable - config = py.test.config._reparse( + config = py.test2.config._reparse( ['--exec=' + py.std.sys.executable, o]) cls = config._getsessionclass() @@ -21,7 +21,7 @@ if s.find('1 failed') != -1: break else: - py.test.fail("did not see test_1 failure in output") + py.test2.fail("did not see test_1 failure in output") assert failures def test_looponfailing(self): @@ -32,7 +32,7 @@ assert 1 == 0 """)) print py.std.sys.executable - config = py.test.config._reparse(['--looponfailing', str(o)]) + config = py.test2.config._reparse(['--looponfailing', str(o)]) cls = config._getsessionclass() out = py.std.Queue.Queue() session = cls(config, out.put) @@ -44,7 +44,7 @@ break print s else: - py.test.fail("did not see test_1 failure") + py.test2.fail("did not see test_1 failure") # XXX we would like to have a cleaner way to finish try: reply.get(timeout=5.0) Modified: py/branch/event/py/test2/testing/test_repevent.py ============================================================================== --- py/branch/event/py/test/testing/test_repevent.py (original) +++ py/branch/event/py/test2/testing/test_repevent.py Wed Jan 30 20:38:14 2008 @@ -1,7 +1,7 @@ """ test reporting functionality. """ import py -from py.__.test import repevent +from py.__.test2 import repevent def test_wrapcall_ok(): l = [] @@ -19,7 +19,7 @@ l = [] def fail(x): raise ValueError - py.test.raises(ValueError, "repevent.wrapcall(l.append, fail, 1)") + py.test2.raises(ValueError, "repevent.wrapcall(l.append, fail, 1)") assert len(l) == 2 assert isinstance(l[0], repevent.CallStart) assert isinstance(l[1], repevent.CallException) @@ -27,7 +27,7 @@ def test_reporter_methods_sanity(): """ Checks if all the methods of reporter are sane """ - from py.__.test.reporter import RemoteReporter + from py.__.test2.reporter import RemoteReporter for method in dir(RemoteReporter): @@ -35,7 +35,7 @@ assert method[len('report_'):] in repevent.__dict__ def test_repevent_failures(): - from py.__.test.outcome import SerializableOutcome, ReprOutcome + from py.__.test2.outcome import SerializableOutcome, ReprOutcome assert not repevent.ReportEvent().is_failure() assert not repevent.CallEvent(None, None, None).is_failure() Modified: py/branch/event/py/test2/testing/test_reporter.py ============================================================================== --- py/branch/event/py/test/testing/test_reporter.py (original) +++ py/branch/event/py/test2/testing/test_reporter.py Wed Jan 30 20:38:14 2008 @@ -18,13 +18,13 @@ import py, os -from py.__.test.session import AbstractSession, itemgen -from py.__.test.reporter import RemoteReporter, LocalReporter, choose_reporter -from py.__.test import repevent -from py.__.test.outcome import ReprOutcome, SerializableOutcome -from py.__.test.rsession.hostmanage import HostInfo -from py.__.test.box import Box -from py.__.test.rsession.testing.basetest import BasicRsessionTest +from py.__.test2.session import AbstractSession, itemgen +from py.__.test2.reporter import RemoteReporter, LocalReporter, choose_reporter +from py.__.test2 import repevent +from py.__.test2.outcome import ReprOutcome, SerializableOutcome +from py.__.test2.rsession.hostmanage import HostInfo +from py.__.test2.box import Box +from py.__.test2.rsession.testing.basetest import BasicRsessionTest import sys from StringIO import StringIO @@ -113,7 +113,7 @@ return out def _test_full_module(self): - tmpdir = py.test.ensuretemp("repmod") + tmpdir = py.test2.ensuretemp("repmod") tmpdir.ensure("__init__.py") tmpdir.ensure("test_one.py").write(py.code.Source(""" def test_x(): @@ -128,8 +128,8 @@ """)) def boxfun(): - config = py.test.config._reparse([str(tmpdir)]) - rootcol = py.test.collect.Directory(tmpdir) + config = py.test2.config._reparse([str(tmpdir)]) + rootcol = py.test2.collect.Directory(tmpdir) hosts = self.get_hosts() r = self.reporter(config, hosts) list(itemgen(MockSession(r), [rootcol], r.report)) @@ -141,14 +141,14 @@ return out def test_failed_to_load(self): - tmpdir = py.test.ensuretemp("failedtoload") + tmpdir = py.test2.ensuretemp("failedtoload") tmpdir.ensure("__init__.py") tmpdir.ensure("test_three.py").write(py.code.Source(""" sadsadsa """)) def boxfun(): - config = py.test.config._reparse([str(tmpdir)]) - rootcol = py.test.collect.Directory(tmpdir) + config = py.test2.config._reparse([str(tmpdir)]) + rootcol = py.test2.collect.Directory(tmpdir) hosts = self.get_hosts() r = self.reporter(config, hosts) r.report(repevent.TestStarted(hosts, config, ["a"])) @@ -165,16 +165,16 @@ assert out.find("NameError: name 'sadsadsa' is not defined") != -1 def _test_verbose(self): - tmpdir = py.test.ensuretemp("reporterverbose") + tmpdir = py.test2.ensuretemp("reporterverbose") tmpdir.ensure("__init__.py") tmpdir.ensure("test_one.py").write("def test_x(): pass") cap = py.io.StdCaptureFD() - config = py.test.config._reparse([str(tmpdir), '-v']) + config = py.test2.config._reparse([str(tmpdir), '-v']) hosts = self.get_hosts() r = self.reporter(config, hosts) r.report(repevent.TestStarted(hosts, config, [])) r.report(repevent.RsyncFinished()) - rootcol = py.test.collect.Directory(tmpdir) + rootcol = py.test2.collect.Directory(tmpdir) list(itemgen(MockSession(r), [rootcol], r.report)) r.report(repevent.TestFinished()) out, err = cap.reset() @@ -183,10 +183,10 @@ assert i in out def _test_still_to_go(self): - tmpdir = py.test.ensuretemp("stilltogo") + tmpdir = py.test2.ensuretemp("stilltogo") tmpdir.ensure("__init__.py") cap = py.io.StdCaptureFD() - config = py.test.config._reparse([str(tmpdir)]) + config = py.test2.config._reparse([str(tmpdir)]) hosts = [HostInfo(i) for i in ["host1", "host2", "host3"]] for host in hosts: host.gw_remotepath = '' @@ -268,13 +268,13 @@ "\nSkipped ('reason') repmod/test_two.py") != -1 def test_reporter_choice(): - from py.__.test.rsession.web import WebReporter - from py.__.test.rsession.rest import RestReporter + from py.__.test2.rsession.web import WebReporter + from py.__.test2.rsession.rest import RestReporter choices = [ (['-d', '--rest'], RestReporter), (['-w'], WebReporter), (['-r'], WebReporter)] for opts, reporter in choices: - config = py.test.config._reparse(['xxx'] + opts) + config = py.test2.config._reparse(['xxx'] + opts) assert choose_reporter(None, config) is reporter Modified: py/branch/event/py/test2/testing/test_repr.py ============================================================================== --- py/branch/event/py/test/testing/test_repr.py (original) +++ py/branch/event/py/test2/testing/test_repr.py Wed Jan 30 20:38:14 2008 @@ -1,15 +1,15 @@ import py -from py.__.test.representation import Presenter -from py.__.test.terminal.out import getout +from py.__.test2.representation import Presenter +from py.__.test2.terminal.out import getout from StringIO import StringIO import sys def newconfig(*args): - tmpdir = py.test.ensuretemp("newconfig") + tmpdir = py.test2.ensuretemp("newconfig") args = list(args) args.append(tmpdir) - return py.test.config._reparse(args) + return py.test2.config._reparse(args) def test_repr_source(): source = py.code.Source(""" @@ -58,7 +58,7 @@ def XXXtest_repr_traceback_long(): py.test.skip("unfinished") - config = py.test.config._reparse([]) + config = py.test2.config._reparse([]) s = StringIO() out = getout(s) p = Presenter(out, config) Modified: py/branch/event/py/test2/testing/test_session.py ============================================================================== --- py/branch/event/py/test/testing/test_session.py (original) +++ py/branch/event/py/test2/testing/test_session.py Wed Jan 30 20:38:14 2008 @@ -1,8 +1,8 @@ import py from setupdata import setup_module # sets up global 'tmpdir' -from py.__.test.outcome import Skipped, Failed, Passed, Outcome -from py.__.test.terminal.out import getout -from py.__.test.repevent import ReceivedItemOutcome, SkippedTryiter,\ +from py.__.test2.outcome import Skipped, Failed, Passed, Outcome +from py.__.test2.terminal.out import getout +from py.__.test2.repevent import ReceivedItemOutcome, SkippedTryiter,\ FailedTryiter implied_options = { @@ -38,8 +38,8 @@ def check_conflict_option(opts): print "testing if options conflict:", " ".join(opts) - config = py.test.config._reparse(opts + [datadir/'filetest.py']) - py.test.raises((ValueError, SystemExit), """ + config = py.test2.config._reparse(opts + [datadir/'filetest.py']) + py.test2.raises((ValueError, SystemExit), """ config.initsession() """) @@ -48,7 +48,7 @@ yield check_implied_option, [key], expr def check_implied_option(opts, expr): - config = py.test.config._reparse(opts + [datadir/'filetest.py']) + config = py.test2.config._reparse(opts + [datadir/'filetest.py']) session = config.initsession() assert eval(expr, session.config.option.__dict__) @@ -59,7 +59,7 @@ yield runfiletest, opts def runfiletest(opts): - config = py.test.config._reparse(opts + [datadir/'filetest.py']) + config = py.test2.config._reparse(opts + [datadir/'filetest.py']) all = [] session = config.initsession() session.main(all.append) @@ -67,13 +67,13 @@ assert not getskipped(all) def test_is_not_boxed_by_default(): - config = py.test.config._reparse([datadir]) + config = py.test2.config._reparse([datadir]) assert not config.option.boxed class TestKeywordSelection: def test_select_simple(self): def check(keyword, name): - config = py.test.config._reparse([datadir/'filetest.py', + config = py.test2.config._reparse([datadir/'filetest.py', '-s', '-k', keyword]) all = [] session = config._getsessionclass()(config) @@ -99,13 +99,13 @@ """)) conftest = o.join('conftest.py').write(py.code.Source(""" import py - class Class(py.test.collect.Class): + class Class(py.test2.collect.Class): def _keywords(self): return ['xxx', self.name] """)) for keyword in ('xxx', 'xxx test_2', 'TestClass', 'xxx -test_1', 'TestClass test_2', 'xxx TestClass test_2',): - config = py.test.config._reparse([o, '-s', '-k', keyword]) + config = py.test2.config._reparse([o, '-s', '-k', keyword]) all = [] session = config._getsessionclass()(config) session.main(all.append) @@ -118,7 +118,7 @@ assert l[0].item.name == 'test_1' def test_select_starton(self): - config = py.test.config._reparse([datadir/'testmore.py', + config = py.test2.config._reparse([datadir/'testmore.py', '-j', '-k', "test_two"]) all = [] session = config._getsessionclass()(config) @@ -129,9 +129,9 @@ class TestTerminalSession: def mainsession(self, *args): - from py.__.test.session import Session - from py.__.test.terminal.out import getout - config = py.test.config._reparse(list(args)) + from py.__.test2.session import Session + from py.__.test2.terminal.out import getout + config = py.test2.config._reparse(list(args)) all = [] session = Session(config) session.main(all.append) @@ -186,7 +186,7 @@ """)) conftest = o.join('conftest.py').write(py.code.Source(""" import py - class Function(py.test.collect.Function): + class Function(py.test2.collect.Function): def startcapture(self): self._mycapture = None @@ -202,7 +202,7 @@ assert hasattr(item, '_testmycapture') print item._testmycapture - assert isinstance(item.parent, py.test.collect.Module) + assert isinstance(item.parent, py.test2.collect.Module) def test_raises_output(self): o = tmpdir.ensure('raisestest', dir=1) @@ -210,14 +210,14 @@ tfile.write(py.code.Source(""" import py def test_raises_doesnt(): - py.test.raises(ValueError, int, "3") + py.test2.raises(ValueError, int, "3") """)) session, all = self.mainsession(o) outcomes = getoutcomes(all) out = outcomes[0].excinfo.exconly() if not out.find("DID NOT RAISE") != -1: print out - py.test.fail("incorrect raises() output") + py.test2.fail("incorrect raises() output") def test_order_of_execution(self): o = tmpdir.ensure('ordertest', dir=1) @@ -267,7 +267,7 @@ def test_safe_repr(self): session, all = self.mainsession(datadir/'brokenrepr.py') - #print 'Output of simulated "py.test brokenrepr.py":' + #print 'Output of simulated "py.test2 brokenrepr.py":' #print all l = getfailed(all) Modified: py/branch/event/py/test2/testing/test_session2.py ============================================================================== --- py/branch/event/py/test/testing/test_session2.py (original) +++ py/branch/event/py/test2/testing/test_session2.py Wed Jan 30 20:38:14 2008 @@ -1,15 +1,15 @@ -""" test of local version of py.test distributed +""" test of local version of py.test2 distributed """ import py -from py.__.test import repevent -#from py.__.test.rsession.local import box_runner, plain_runner, apigen_runner -import py.__.test.custompdb -from py.__.test.session import Session +from py.__.test2 import repevent +#from py.__.test2.rsession.local import box_runner, plain_runner, apigen_runner +import py.__.test2.custompdb +from py.__.test2.session import Session def setup_module(mod): - mod.tmp = py.test.ensuretemp("lsession_module") + mod.tmp = py.test2.ensuretemp("lsession_module") class TestSession(object): # XXX: Some tests of that should be run as well on RSession, while @@ -35,7 +35,7 @@ args = [str(tmpdir.join(dirname))] if boxed: args.append('--boxed') - config = py.test.config._reparse(args) + config = py.test2.config._reparse(args) lsession = Session(config) allevents = [] lsession.main(reporter=allevents.append) @@ -82,7 +82,7 @@ """)) args = [str(tmpdir.join(dirname))] args.append('--boxed') - config = py.test.config._reparse(args) + config = py.test2.config._reparse(args) lsession = Session(config) allevents = [] lsession.main(reporter=allevents.append) @@ -108,10 +108,10 @@ l.append(args) try: - post_mortem = py.__.test.custompdb.post_mortem - py.__.test.custompdb.post_mortem = some_fun + post_mortem = py.__.test2.custompdb.post_mortem + py.__.test2.custompdb.post_mortem = some_fun args = [str(tmpdir.join(subdir)), '--pdb'] - config = py.test.config._reparse(args) + config = py.test2.config._reparse(args) lsession = Session(config) allevents = [] #try: @@ -119,13 +119,13 @@ #except SystemExit: # pass #else: - # py.test.fail("Didn't raise system exit") + # py.test2.fail("Didn't raise system exit") failure_events = [event for event in allevents if isinstance(event, repevent.ImmediateFailure)] assert len(failure_events) == 1 assert len(l) == 1 finally: - py.__.test.custompdb.post_mortem = post_mortem + py.__.test2.custompdb.post_mortem = post_mortem def test_minus_x(self): if not hasattr(py.std.os, 'fork'): @@ -144,7 +144,7 @@ pass """)) args = [str(tmpdir.join(subdir)), '-x'] - config = py.test.config._reparse(args) + config = py.test2.config._reparse(args) assert config.option.exitfirst lsession = Session(config) allevents = [] @@ -174,7 +174,7 @@ pass """)) args = [str(tmpdir.join("sub3")), '-k', 'test_one'] - config = py.test.config._reparse(args) + config = py.test2.config._reparse(args) lsession = Session(config) allevents = [] @@ -202,7 +202,7 @@ """)) args = [str(tmpdir.join("sub4"))] - config = py.test.config._reparse(args) + config = py.test2.config._reparse(args) lsession = Session(config) allevents = [] allruns = [] @@ -228,7 +228,7 @@ """)) args = [str(tmpdir.join("sub5"))] - config = py.test.config._reparse(args) + config = py.test2.config._reparse(args) lsession = Session(config) allevents = [] lsession.main(reporter=allevents.append) @@ -254,7 +254,7 @@ assert [0] == x """)) args = [str(tmpdir.join("sub6"))] - config = py.test.config._reparse(args) + config = py.test2.config._reparse(args) lsession = Session(config) allevents = [] lsession.main(reporter=allevents.append) @@ -275,7 +275,7 @@ print 3 """)) args = [str(tmpdir.join("sub7"))] - config = py.test.config._reparse(args) + config = py.test2.config._reparse(args) lsession = Session(config) allevents = [] lsession.main(reporter=allevents.append) Modified: py/branch/event/py/test2/web/webcheck.py ============================================================================== --- py/branch/event/py/test/web/webcheck.py (original) +++ py/branch/event/py/test2/web/webcheck.py Wed Jan 30 20:38:14 2008 @@ -6,7 +6,7 @@ def check_html(string): """check an HTML string for wellformedness and validity""" - tempdir = py.test.ensuretemp('check_html') + tempdir = py.test2.ensuretemp('check_html') filename = 'temp%s.html' % (hash(string), ) tempfile = tempdir.join(filename) tempfile.write(string) @@ -22,7 +22,7 @@ valid = match.group(1) is None text = match.group(2).strip() if not valid: - temp = py.test.ensuretemp('/w3_results_%s.html' % hash(html), dir=0) + temp = py.test2.ensuretemp('/w3_results_%s.html' % hash(html), dir=0) temp.write(html) raise HTMLError( "The html is not valid. See the report file at '%s'" % temp) From hpk at codespeak.net Thu Jan 31 10:48:39 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 31 Jan 2008 10:48:39 +0100 (CET) Subject: [py-svn] r51150 - in py/branch/event/py/test2: . rsession rsession/testing testing Message-ID: <20080131094839.B5640168449@codespeak.net> Author: hpk Date: Thu Jan 31 10:48:37 2008 New Revision: 51150 Modified: py/branch/event/py/test2/config.py py/branch/event/py/test2/executor.py 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/test_hostmanage.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/session.py py/branch/event/py/test2/testing/test_collect.py py/branch/event/py/test2/testing/test_repevent.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: * intermediate checkin * refactoring towards using general events * py/test2/testing passes apart from output-checking tests * py/test2/rsession is still too messy ... Modified: py/branch/event/py/test2/config.py ============================================================================== --- py/branch/event/py/test2/config.py (original) +++ py/branch/event/py/test2/config.py Thu Jan 31 10:48:37 2008 @@ -34,6 +34,7 @@ usage="usage: %prog [options] [query] [filenames of tests]") self._conftest = Conftest() self._initialized = False + self.hub = py.event.Hub() def parse(self, args): """ parse cmdline arguments into this config object. Modified: py/branch/event/py/test2/executor.py ============================================================================== --- py/branch/event/py/test2/executor.py (original) +++ py/branch/event/py/test2/executor.py Thu Jan 31 10:48:37 2008 @@ -14,12 +14,9 @@ """ wraps = False - def __init__(self, item, usepdb=False, reporter=None, config=None): + def __init__(self, item, config): self.item = item - self.usepdb = usepdb - self.reporter = reporter self.config = config - assert self.config def run(self, capture=True): if capture: @@ -55,11 +52,10 @@ path=code.path, firstlineno=code.firstlineno) outcome = SerializableOutcome(excinfo=excinfo, setupfailure=False) outcome.stdout, outcome.stderr = self.item._getouterr() - if self.usepdb: - if self.reporter is not None: - self.reporter(repevent.ImmediateFailure(self.item, - ReprOutcome(outcome.make_repr - (self.config.option.tbstyle)))) + if self.config.option.usepdb: + self.config.hub.notify( + repevent.ImmediateFailure(self.item, + ReprOutcome(outcome.make_repr(self.config.option.tbstyle)))) py.__.test2.custompdb.post_mortem(excinfo._excinfo[2]) # XXX hmm, we probably will not like to continue from that # point Modified: py/branch/event/py/test2/repevent.py ============================================================================== --- py/branch/event/py/test2/repevent.py (original) +++ py/branch/event/py/test2/repevent.py Thu Jan 31 10:48:37 2008 @@ -7,27 +7,6 @@ def basic_report(msg_type, message): print msg_type, message -#def report(msg_type, message): -# pass - -##def report_error(excinfo): -## if isinstance(excinfo, py.test2.collect.Item.Skipped): -## # we need to dispatch this info -## report(Skipped(excinfo)) -## else: -## report("itererror", excinfo) - -def wrapcall(reporter, func, *args, **kwargs): - reporter(CallStart(func, args, kwargs)) - try: - retval = func(*args, **kwargs) - except: - reporter(CallException(func, args, kwargs)) - raise - else: - reporter(CallFinish(func, args, kwargs)) - return retval - # ---------------------------------------------------------------------- # Reporting Events # ---------------------------------------------------------------------- @@ -59,25 +38,25 @@ def is_failure(self): return not (self.outcome.passed or self.outcome.skipped) -class CallEvent(ReportEvent): - def __init__(self, func, args, kwargs): - self.func = func - self.args = args - self.kwargs = kwargs - - def __repr__(self): - call = "%s args=%s, kwargs=%s" %(self.func.__name__, - self.args, self.kwargs) - return '<%s %s>' %(self.__class__.__name__, call) - -class CallStart(CallEvent): - pass - -class CallException(CallEvent): - pass - -class CallFinish(CallEvent): - pass +#class CallEvent(ReportEvent): +# def __init__(self, func, args, kwargs): +# self.func = func +# self.args = args +# self.kwargs = kwargs +# +# def __repr__(self): +# call = "%s args=%s, kwargs=%s" %(self.func.__name__, +# self.args, self.kwargs) +# return '<%s %s>' %(self.__class__.__name__, call) +# +#class CallStart(CallEvent): +# pass +# +#class CallException(CallEvent): +# pass +# +#class CallFinish(CallEvent): +# pass class HostRSyncing(ReportEvent): def __init__(self, host, root, remotepath, synced): 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 Thu Jan 31 10:48:37 2008 @@ -93,7 +93,7 @@ else: return True - def add_target_host(self, host, destrelpath="", reporter=lambda x: None): + def add_target_host(self, host, destrelpath="", notify=None): remotepath = host.gw_remotepath key = host.hostname, host.relpath if host.inplacelocal: @@ -102,10 +102,14 @@ elif destrelpath: remotepath = os.path.join(remotepath, destrelpath) synced = key in self._synced - reporter(repevent.HostRSyncing(host, py.path.local(self._sourcedir), - remotepath, synced)) + if notify: + notify( + repevent.HostRSyncing(host, py.path.local(self._sourcedir), + remotepath, synced)) def hostrsynced(host=host): - reporter(repevent.HostRSyncRootReady(host, self._sourcedir)) + if notify: + notify( + repevent.HostRSyncRootReady(host, self._sourcedir)) if key in self._synced: hostrsynced() return @@ -131,16 +135,16 @@ hosts = [HostInfo(x, addrel) for x in hosts] self.hosts = hosts - def prepare_gateways(self, reporter): + def prepare_gateways(self): python = self.config.getvalue("dist_remotepython") for host in self.hosts: host.initgateway(python=python) - reporter(repevent.HostGatewayReady(host, self.roots)) + self.config.hub.notify(repevent.HostGatewayReady(host, self.roots)) host.gw.host = host - def init_rsync(self, reporter): + def init_rsync(self): ignores = self.config.getvalue_pathlist("dist_rsync_ignore") - self.prepare_gateways(reporter) + self.prepare_gateways() # send each rsync root for root in self.roots: rsync = HostRSync(root, ignores=ignores, @@ -150,22 +154,24 @@ else: destrelpath = root.basename for host in self.hosts: - rsync.add_target_host(host, destrelpath, reporter) + rsync.add_target_host(host, destrelpath) rsync.send(raises=False) - def setup_hosts(self, reporter): - self.init_rsync(reporter) + 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, reporter)) + nodes.append(MasterNode(ch, self.config.hub.notify)) return nodes - def teardown_hosts(self, reporter, channels, nodes, + def teardown_hosts(self, channels, nodes, waiter=lambda : time.sleep(.1), exitfirst=False): for channel in channels: channel.send(None) + # XXX + return clean = exitfirst while not clean: @@ -174,17 +180,19 @@ if node.pending: clean = False waiter() - self.teardown_gateways(reporter, channels) + self.teardown_gateways(channels) def kill_channels(self, channels): for channel in channels: channel.send(42) - def teardown_gateways(self, reporter, channels): + def teardown_gateways(self, channels): + return + self.config.hub.notify("tear down %r" %(channels,)) for channel in channels: #try: try: - repevent.wrapcall(reporter, channel.waitclose, 1) + channel.waitclose(1.0) except IOError: # timeout # force closing channel.close() 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 Thu Jan 31 10:48:37 2008 @@ -8,9 +8,9 @@ from py.builtin import GeneratorExit class MasterNode(object): - def __init__(self, channel, reporter): + def __init__(self, channel, notify): + self.notify = notify self.channel = channel - self.reporter = reporter self.pending = [] channel.setcallback(self._callback) @@ -21,8 +21,8 @@ def receive_result(self, outcomestring, item): repr_outcome = ReprOutcome(outcomestring) # send finish report - self.reporter(repevent.ReceivedItemOutcome( - self.channel, item, repr_outcome)) + self.notify(repevent.ReceivedItemOutcome( + self.channel, item, repr_outcome)) def send(self, item): try: @@ -33,7 +33,7 @@ #itemspec = item.listnames()[1:] self.channel.send(item._get_collector_trail()) # send start report - self.reporter(repevent.SendItem(self.channel, item)) + self.notify(repevent.SendItem(self.channel, item)) except IOError: print "Sending error, channel IOError" print self.channel._getremoteerror() @@ -41,7 +41,7 @@ # of hanging nodes and such raise -def dispatch_loop(masternodes, itemgenerator, shouldstop, +def dispatch_loop(masternodes, itemgenerator, #shouldstop, waiter = lambda: py.std.time.sleep(0.1), max_tasks_per_node=15): all_tests = {} @@ -51,10 +51,10 @@ 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 + #if shouldstop(): + # for _node in masternodes: + # _node.send(StopIteration) # magic connector + # return None node.send(item) except StopIteration: break Modified: py/branch/event/py/test2/rsession/rsession.py ============================================================================== --- py/branch/event/py/test2/rsession/rsession.py (original) +++ py/branch/event/py/test2/rsession/rsession.py Thu Jan 31 10:48:37 2008 @@ -9,19 +9,16 @@ import time from py.__.test2 import repevent -from py.__.test2.rsession.master import MasterNode, dispatch_loop +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.reporter import LocalReporter, RemoteReporter, TestReporter from py.__.test2.session import AbstractSession, itemgen from py.__.test2.outcome import Skipped, Failed class RSession(AbstractSession): """ Remote version of session """ - reporterclass = RemoteReporter - def fixoptions(self): super(RSession, self).fixoptions() option = self.config.option @@ -43,47 +40,42 @@ print "see also: http://codespeak.net/py/current/doc/test.html#automated-distributed-testing" raise SystemExit - def main(self, reporter=None): + def main(self): """ main loop for running tests. """ - config = self.config - hm = HostManager(config) - reporter, checkfun = self.init_reporter(reporter, config, hm.hosts) - - reporter(repevent.TestStarted(hm.hosts, self.config, - hm.roots)) - self.reporter = reporter - + hm = HostManager(self.config) + hub = self.config.hub + hub.notify(repevent.TestStarted(hm.hosts, self.config, hm.roots)) try: - nodes = hm.setup_hosts(reporter) - reporter(repevent.RsyncFinished()) + nodes = hm.setup_hosts() + hub.notify(repevent.RsyncFinished()) try: - self.dispatch_tests(nodes, reporter, checkfun) + 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(reporter, channels) + hm.teardown_gateways(channels) print >>sys.stderr, "... Done" raise + print "tearing down nodes" channels = [node.channel for node in nodes] - hm.teardown_hosts(reporter, channels, nodes, - exitfirst=self.config.option.exitfirst) - reporter(repevent.Nodes(nodes)) - retval = reporter(repevent.TestFinished()) - return retval + hm.teardown_hosts(channels, nodes) + hub.notify(repevent.Nodes(nodes)) + # XXX retval = reporter(repevent.TestFinished()) + hub.notify(repevent.TestFinished()) except (KeyboardInterrupt, SystemExit): - reporter(repevent.InterruptedExecution()) + hub.notify(repevent.InterruptedExecution()) raise except: - reporter(repevent.CrashedExecution()) + hub.notify(repevent.CrashedExecution()) raise - def dispatch_tests(self, nodes, reporter, checkfun): + def dispatch_tests(self, nodes): colitems = self.config.getcolitems() keyword = self.config.option.keyword - itemgenerator = itemgen(self, colitems, reporter, keyword) + itemgenerator = itemgen(self, colitems, keyword) max_tasks_per_node = self.config.getvalue("dist_taskspernode") - all_tests = dispatch_loop(nodes, itemgenerator, checkfun, + all_tests = dispatch_loop(nodes, itemgenerator, max_tasks_per_node=max_tasks_per_node) 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 Thu Jan 31 10:48:37 2008 @@ -11,7 +11,6 @@ class SlaveNode(object): def __init__(self, config, executor): - #self.rootcollector = rootcollector self.config = config self.executor = executor @@ -21,8 +20,6 @@ return ex.execute() def run(self, itemspec): - #outcome = self.execute(itemspec) - #return outcome.make_repr() outcome = self.execute(itemspec) if self.executor.wraps: return outcome 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 Thu Jan 31 10:48:37 2008 @@ -130,7 +130,7 @@ events = [] rsync = HostRSync(self.source) h1.initgateway() - rsync.add_target_host(h1, reporter=events.append) + rsync.add_target_host(h1, notify=events.append) assert events l = [x for x in events if isinstance(x, repevent.HostRSyncing)] @@ -192,7 +192,7 @@ dist_hosts = ["localhost:%s" % self.dest] ) assert hm.config.topdir == self.source - hm.init_rsync([].append) + hm.init_rsync() dest = self.dest.join(self.source.basename) assert dest.join("dir1").check() assert dest.join("dir1", "dir2").check() @@ -206,7 +206,7 @@ dist_rsync_roots = [str(self.source)] ) assert hm.config.topdir == self.source - hm.init_rsync([].append) + hm.init_rsync() dest = self.dest.join(self.source.basename) assert dest.join("dir1").check() assert dest.join("dir1", "dir2").check() @@ -223,8 +223,7 @@ config = py.test2.config._reparse([self.source]) hm = HostManager(config, hosts=[HostInfo("localhost:" + str(self.dest))]) - events = [] - hm.init_rsync(reporter=events.append) + hm.init_rsync() assert self.dest.join("dir2").check() assert not self.dest.join("dir1").check() assert not self.dest.join("bogus").check() @@ -240,9 +239,7 @@ config = py.test2.config._reparse([self.source]) hm = HostManager(config, hosts=[HostInfo("localhost:" + str(self.dest))]) - events = [] - print events - hm.init_rsync(reporter=events.append) + hm.init_rsync() assert self.dest.join("dir1").check() assert not self.dest.join("dir1", "dir2").check() assert self.dest.join("dir5","file").check() @@ -252,13 +249,11 @@ hosts = [HostInfo("localhost") for i in range(3)] config = py.test2.config._reparse([self.source]) hm = HostManager(config, hosts=hosts) - events = [] - hm.init_rsync(events.append) + hm.init_rsync() for host in hosts: assert host.inplacelocal assert host.gw_remotepath is None assert not host.relpath - assert events def XXXtest_ssh_rsync_samehost_twice(self): #XXX we have no easy way to have a temp directory remotely! 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 Thu Jan 31 10:48:37 2008 @@ -114,7 +114,7 @@ def waiter(): for node in masternodes: node.pending.pop() - dispatch_loop(masternodes, itemgenerator, shouldstop, waiter=waiter) + dispatch_loop(masternodes, itemgenerator, waiter=waiter) class TestSlave: def setup_class(cls): 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 Thu Jan 31 10:48:37 2008 @@ -3,6 +3,9 @@ """ import py + +py.test.skip("refactor ReST reporter tests") + from py.__.test2.testing.test_reporter import AbstractTestReporter,\ DummyChannel from py.__.test2 import repevent 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 Thu Jan 31 10:48:37 2008 @@ -9,6 +9,8 @@ from py.__.test2.rsession.testing.basetest import BasicRsessionTest from py.__.test2.rsession.testing.test_hostmanage import DirSetup +from py.__.test2.testing.test_session import getevents_runmain + def setup_module(mod): mod.pkgdir = py.path.local(py.__file__).dirpath() if py.std.sys.platform == "win32": @@ -34,9 +36,11 @@ pass """)) config = py.test2.config._reparse([self.source.join("sub"), '-x']) - allevents = [] rsession = RSession(config) - rsession.main(allevents.append) + def f(ev): + print ev + config.hub.append(f) + allevents = getevents_runmain(rsession) testevents = [x for x in allevents if isinstance(x, repevent.ReceivedItemOutcome)] assert len(testevents) == 3 @@ -69,9 +73,8 @@ config = py.test2.config._reparse([tmpdir.join(subdir)]) assert config.topdir == tmpdir assert not tmpdir.join("__init__.py").check() - allevents = [] rsession = RSession(config) - rsession.main(allevents.append) + allevents = getevents_runmain(rsession) testevents = [x for x in allevents if isinstance(x, repevent.ReceivedItemOutcome)] assert len(testevents) @@ -103,9 +106,12 @@ tmpdir = self.source config = py.test2.config._reparse([tmpdir]) hm = HostManager(config, hosts) - nodes = hm.setup_hosts(setup_events.append) - hm.teardown_hosts(teardown_events.append, - [node.channel for node in nodes], nodes) + + config.hub.append(setup_events.append) + nodes = hm.setup_hosts() + + config.hub.append(teardown_events.append) + hm.teardown_hosts([node.channel for node in nodes], nodes) count_rsyn_calls = [i for i in setup_events if isinstance(i, repevent.HostRSyncing)] @@ -125,12 +131,9 @@ def test_setup_teardown_run_ssh(self): hosts = [HostInfo('localhost:%s' % self.dest)] allevents = [] - + self.config.hub.append(allevents.append) hm = HostManager(self.config, hosts=hosts) - nodes = hm.setup_hosts(allevents.append) - - from py.__.test2.testing.test_executor \ - import ItemTestPassing, ItemTestFailing, ItemTestSkipping + nodes = hm.setup_hosts() itempass = self.getexample("pass") itemfail = self.getexample("fail") @@ -144,7 +147,7 @@ node.send(itemskip) node.send(itemprint) - hm.teardown_hosts(allevents.append, [node.channel for node in nodes], nodes) + hm.teardown_hosts([node.channel for node in nodes], nodes) events = [i for i in allevents if isinstance(i, repevent.ReceivedItemOutcome)] @@ -152,6 +155,7 @@ if i.outcome.passed] skipped = [i for i in events if i.outcome.skipped] + for x in allevents: print x assert len(passed) == 2 * len(nodes) assert len(skipped) == len(nodes) assert len(events) == 4 * len(nodes) @@ -162,7 +166,6 @@ def test_nice_level(self): """ Tests if nice level behaviour is ok """ - allevents = [] hosts = [HostInfo('localhost:%s' % self.dest)] tmpdir = self.source tmpdir.ensure("__init__.py") @@ -177,7 +180,7 @@ config = py.test2.config._reparse([tmpdir]) rsession = RSession(config) - rsession.main(allevents.append) + 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] Modified: py/branch/event/py/test2/session.py ============================================================================== --- py/branch/event/py/test2/session.py (original) +++ py/branch/event/py/test2/session.py Thu Jan 31 10:48:37 2008 @@ -1,7 +1,6 @@ import py import sys from py.__.test2.outcome import Outcome, Failed, Passed, Skipped -from py.__.test2.reporter import choose_reporter, TestReporter from py.__.test2 import repevent from py.__.test2.outcome import SerializableOutcome, ReprOutcome from py.__.test2.reporter import LocalReporter @@ -21,15 +20,14 @@ except NameError: GeneratorExit = StopIteration # I think -def itemgen(session, colitems, reporter, keyword=None): +def itemgen(session, colitems, keyword=None): + hub = session.config.hub stopitems = py.test2.collect.Item # XXX should be generator here as well while 1: if not colitems: break next = colitems.pop(0) - if reporter: - reporter(repevent.ItemStart(next)) - + hub.notify(repevent.ItemStart(next)) if isinstance(next, stopitems): try: next._skipbykeyword(keyword) @@ -38,22 +36,21 @@ if session.config.option.keyword_oneshot: keyword = None excinfo = py.code.ExceptionInfo() - reporter(repevent.SkippedTryiter(excinfo, next)) + hub.notify(repevent.SkippedTryiter(excinfo, next)) else: try: cols = [next.join(x) for x in next.run()] - for x in itemgen(session, cols, reporter, keyword): + for x in itemgen(session, cols, keyword): yield x except (KeyboardInterrupt, SystemExit, GeneratorExit): raise except: excinfo = py.code.ExceptionInfo() if excinfo.type is Skipped: - reporter(repevent.SkippedTryiter(excinfo, next)) + hub.notify(repevent.SkippedTryiter(excinfo, next)) else: - reporter(repevent.FailedTryiter(excinfo, next)) - if reporter: - reporter(repevent.ItemFinish(next)) + hub.notify(repevent.FailedTryiter(excinfo, next)) + hub.notify(repevent.ItemFinish(next)) class AbstractSession(object): """ An abstract session executes collectors/items through a runner. @@ -81,16 +78,6 @@ if option.keyword_oneshot and not option.keyword: raise ValueError, "--keyword-oneshot makes sense only when --keyword is supplied" - def init_reporter(self, reporter, config, hosts): - if reporter is None: - reporter = choose_reporter(self.reporterclass, config)\ - (config, hosts) - else: - reporter = TestReporter(reporter) - checkfun = lambda : self.config.option.exitfirst and \ - reporter.was_failure() - return reporter, checkfun - class Session(AbstractSession): """ A Session gets test Items from Collectors, executes the @@ -103,8 +90,7 @@ def header(self, colitems): """ setup any neccessary resources ahead of the test run. """ - self.reporter(repevent.TestStarted(None, self.config, - None)) + self.config.hub.notify(repevent.TestStarted(None, self.config, None)) if not self.config.option.nomagic: py.magic.invoke(assertion=1) @@ -113,30 +99,25 @@ py.test2.collect.Function._state.teardown_all() if not self.config.option.nomagic: py.magic.revoke(assertion=1) - self.reporter(repevent.TestFinished()) + self.config.hub.notify(repevent.TestFinished()) - def main(self, reporter=None): + def main(self): """ main loop for running tests. """ config = self.config - self.reporter, shouldstop = self.init_reporter(reporter, config, None) - colitems = self.config.getcolitems() self.header(colitems) keyword = self.config.option.keyword - reporter = self.reporter - itemgenerator = itemgen(self, colitems, reporter, keyword) + itemgenerator = itemgen(self, colitems, keyword) failures = [] try: while 1: try: item = itemgenerator.next() - if shouldstop(): - return outcome = self.run(item) if outcome is not None: if not outcome.passed and not outcome.skipped: failures.append((item, outcome)) - reporter(repevent.ReceivedItemOutcome(None, item, outcome)) + self.config.hub.notify(repevent.ReceivedItemOutcome(None, item, outcome)) except StopIteration: break finally: @@ -146,12 +127,10 @@ def run(self, item): if not self.config.option.boxed: - executor = RunExecutor(item, self.config.option.usepdb, - self.reporter, self.config) + executor = RunExecutor(item, config=self.config) return ReprOutcome(executor.execute().make_repr()) else: - executor = BoxExecutor(item, self.config.option.usepdb, - self.reporter, self.config) + executor = BoxExecutor(item, config=self.config) return ReprOutcome(executor.execute()) class Exit(Exception): 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 Thu Jan 31 10:48:37 2008 @@ -5,10 +5,18 @@ from py.__.test2.terminal.out import getout from py.__.test2.repevent import ReceivedItemOutcome -def getpassed(all): - outcomes = [i.outcome for i in all if isinstance(i, ReceivedItemOutcome)] - l = [i for i in outcomes if i.passed] - return l +def getpassed(session): + hub = session.config.hub + all = [] + hub.append(all.append) + 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 + finally: + hub.pop() def setup_module(mod): mod.datadir = setupdatadir() @@ -210,20 +218,16 @@ old = o.chdir() try: config = py.test2.config._reparse([]) - all = [] session = config._getsessionclass()(config) - session.main(all.append) - l = getpassed(all) + l = getpassed(session) assert len(l) == 2 finally: old.chdir() # test that running the file directly works config = py.test2.config._reparse([str(checkfile)]) - all = [] session = config._getsessionclass()(config) - session.main(all.append) - l = getpassed(all) + l = getpassed(session) assert len(l) == 2 def test_custom_NONpython_collection_from_conftest(): @@ -257,20 +261,16 @@ old = o.chdir() try: config = py.test2.config._reparse([]) - all = [] session = config._getsessionclass()(config) - session.main(all.append) - l = getpassed(all) + l = getpassed(session) assert len(l) == 1 finally: old.chdir() # test that running the file directly works config = py.test2.config._reparse([str(checkfile)]) - all = [] session = config._getsessionclass()(config) - session.main(all.append) - l = getpassed(all) + l = getpassed(session) assert len(l) == 1 def test_order_of_execution_generator_same_codeline(): @@ -293,10 +293,8 @@ yield assert_order_of_execution """)) config = py.test2.config._reparse([o]) - all = [] session = config.initsession() - session.main(all.append) - l = getpassed(all) + l = getpassed(session) assert len(l) == 7 def test_order_of_execution_generator_different_codeline(): @@ -326,10 +324,8 @@ yield assert_order_of_execution """)) config = py.test2.config._reparse([o]) - all = [] session = config.initsession() - session.main(all.append) - l = getpassed(all) + l = getpassed(session) assert len(l) == 4 Modified: py/branch/event/py/test2/testing/test_repevent.py ============================================================================== --- py/branch/event/py/test2/testing/test_repevent.py (original) +++ py/branch/event/py/test2/testing/test_repevent.py Thu Jan 31 10:48:37 2008 @@ -3,26 +3,6 @@ import py from py.__.test2 import repevent -def test_wrapcall_ok(): - l = [] - def ok(x): - return x+1 - i = repevent.wrapcall(l.append, ok, 1) - assert i == 2 - assert len(l) == 2 - assert isinstance(l[0], repevent.CallStart) - assert isinstance(l[1], repevent.CallFinish) - assert repr(l[0]) - assert repr(l[1]) - -def test_wrapcall_exception(): - l = [] - def fail(x): - raise ValueError - py.test2.raises(ValueError, "repevent.wrapcall(l.append, fail, 1)") - assert len(l) == 2 - assert isinstance(l[0], repevent.CallStart) - assert isinstance(l[1], repevent.CallException) def test_reporter_methods_sanity(): """ Checks if all the methods of reporter are sane 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 Thu Jan 31 10:48:37 2008 @@ -1,4 +1,3 @@ - """ reporter tests. XXX there are a few disabled reporting tests because @@ -18,6 +17,9 @@ import py, os + +py.test.skip("rewrite reporter tests completely, take existing as hints") + from py.__.test2.session import AbstractSession, itemgen from py.__.test2.reporter import RemoteReporter, LocalReporter, choose_reporter from py.__.test2 import repevent 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 Thu Jan 31 10:48:37 2008 @@ -5,6 +5,8 @@ from py.__.test2.repevent import ReceivedItemOutcome, SkippedTryiter,\ FailedTryiter +from test_session2 import getevents_runmain + implied_options = { '-v': 'verbose', '-l': 'showlocals', @@ -60,9 +62,8 @@ def runfiletest(opts): config = py.test2.config._reparse(opts + [datadir/'filetest.py']) - all = [] session = config.initsession() - session.main(all.append) + all = getevents_runmain(session) assert len(getfailed(all)) == 2 assert not getskipped(all) @@ -75,9 +76,8 @@ def check(keyword, name): config = py.test2.config._reparse([datadir/'filetest.py', '-s', '-k', keyword]) - all = [] session = config._getsessionclass()(config) - session.main(all.append) + all = getevents_runmain(session) outcomes = [i for i in all if isinstance(i, ReceivedItemOutcome)] assert len(getfailed(all)) == 1 assert outcomes[0].item.name == name @@ -106,9 +106,8 @@ for keyword in ('xxx', 'xxx test_2', 'TestClass', 'xxx -test_1', 'TestClass test_2', 'xxx TestClass test_2',): config = py.test2.config._reparse([o, '-s', '-k', keyword]) - all = [] session = config._getsessionclass()(config) - session.main(all.append) + all = getevents_runmain(session) print "keyword", repr(keyword) l = getpassed(all) outcomes = [i for i in all if isinstance(i, ReceivedItemOutcome)] @@ -120,9 +119,8 @@ def test_select_starton(self): config = py.test2.config._reparse([datadir/'testmore.py', '-j', '-k', "test_two"]) - all = [] session = config._getsessionclass()(config) - session.main(all.append) + all = getevents_runmain(session) assert len(getpassed(all)) == 2 assert len(getskipped(all)) == 1 @@ -132,9 +130,8 @@ from py.__.test2.session import Session from py.__.test2.terminal.out import getout config = py.test2.config._reparse(list(args)) - all = [] session = Session(config) - session.main(all.append) + all = getevents_runmain(session) return session, all def test_terminal(self): Modified: py/branch/event/py/test2/testing/test_session2.py ============================================================================== --- py/branch/event/py/test2/testing/test_session2.py (original) +++ py/branch/event/py/test2/testing/test_session2.py Thu Jan 31 10:48:37 2008 @@ -8,6 +8,17 @@ import py.__.test2.custompdb from py.__.test2.session import Session +def getevents_runmain(session): + hub = session.config.hub + allevents = [] + hub.append(allevents.append) + try: + session.main() + return allevents + finally: + hub.remove(allevents.append) + + def setup_module(mod): mod.tmp = py.test2.ensuretemp("lsession_module") @@ -37,8 +48,7 @@ args.append('--boxed') config = py.test2.config._reparse(args) lsession = Session(config) - allevents = [] - lsession.main(reporter=allevents.append) + allevents = getevents_runmain(lsession) testevents = [x for x in allevents if isinstance(x, repevent.ReceivedItemOutcome)] assert len(testevents) @@ -84,8 +94,7 @@ args.append('--boxed') config = py.test2.config._reparse(args) lsession = Session(config) - allevents = [] - lsession.main(reporter=allevents.append) + allevents = getevents_runmain(lsession) testevents = [x for x in allevents if isinstance(x, repevent.ReceivedItemOutcome)] assert len(testevents) @@ -113,9 +122,8 @@ args = [str(tmpdir.join(subdir)), '--pdb'] config = py.test2.config._reparse(args) lsession = Session(config) - allevents = [] #try: - lsession.main(reporter=allevents.append) + allevents = getevents_runmain(lsession) #except SystemExit: # pass #else: @@ -147,9 +155,7 @@ config = py.test2.config._reparse(args) assert config.option.exitfirst lsession = Session(config) - allevents = [] - - lsession.main(reporter=allevents.append) + allevents = getevents_runmain(lsession) testevents = [x for x in allevents if isinstance(x, repevent.ReceivedItemOutcome)] assert len(testevents) @@ -176,9 +182,8 @@ args = [str(tmpdir.join("sub3")), '-k', 'test_one'] config = py.test2.config._reparse(args) lsession = Session(config) - allevents = [] - lsession.main(reporter=allevents.append) + allevents = getevents_runmain(lsession) testevents = [x for x in allevents if isinstance(x, repevent.ReceivedItemOutcome)] assert len(testevents) @@ -204,10 +209,8 @@ args = [str(tmpdir.join("sub4"))] config = py.test2.config._reparse(args) lsession = Session(config) - allevents = [] allruns = [] - lsession.main(reporter=allevents.append) - + allevents = getevents_runmain(lsession) testevents = [x for x in allevents if isinstance(x, repevent.ReceivedItemOutcome)] assert len(testevents) == 4 @@ -230,8 +233,7 @@ args = [str(tmpdir.join("sub5"))] config = py.test2.config._reparse(args) lsession = Session(config) - allevents = [] - lsession.main(reporter=allevents.append) + allevents = getevents_runmain(lsession) testevents = [x for x in allevents if isinstance(x, repevent.ReceivedItemOutcome)] assert len(testevents) == 0 @@ -256,8 +258,7 @@ args = [str(tmpdir.join("sub6"))] config = py.test2.config._reparse(args) lsession = Session(config) - allevents = [] - lsession.main(reporter=allevents.append) + allevents = getevents(lsession) testevents = [x for x in allevents if isinstance(x, repevent.ReceivedItemOutcome)] failevents = [i for i in testevents if i.outcome.excinfo] @@ -277,8 +278,7 @@ args = [str(tmpdir.join("sub7"))] config = py.test2.config._reparse(args) lsession = Session(config) - allevents = [] - lsession.main(reporter=allevents.append) + allevents = getevents_runmain(lsession.main) testevents = [x for x in allevents if isinstance(x, repevent.ReceivedItemOutcome)] assert len(testevents) == 1 From hpk at codespeak.net Thu Jan 31 13:58:44 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 31 Jan 2008 13:58:44 +0100 (CET) Subject: [py-svn] r51152 - in py/branch/event/py/test2: . rsession rsession/testing testing Message-ID: <20080131125844.7FD4B168036@codespeak.net> Author: hpk Date: Thu Jan 31 13:58:41 2008 New Revision: 51152 Modified: py/branch/event/py/test2/repevent.py py/branch/event/py/test2/reporter.py py/branch/event/py/test2/rsession/hostmanage.py py/branch/event/py/test2/rsession/rsession.py py/branch/event/py/test2/rsession/testing/test_rsession.py py/branch/event/py/test2/session.py py/branch/event/py/test2/testing/test_repevent.py Log: tweaking more things and tests to work with new event arch Modified: py/branch/event/py/test2/repevent.py ============================================================================== --- py/branch/event/py/test2/repevent.py (original) +++ py/branch/event/py/test2/repevent.py Thu Jan 31 13:58:41 2008 @@ -17,9 +17,6 @@ for key, value in self.__dict__.items()] return "<%s %s>" %(self.__class__.__name__, " ".join(l),) - def is_failure(self): - return False - class SendItem(ReportEvent): def __init__(self, channel, item): self.item = item @@ -35,9 +32,6 @@ self.item = item self.outcome = outcome - def is_failure(self): - return not (self.outcome.passed or self.outcome.skipped) - #class CallEvent(ReportEvent): # def __init__(self, func, args, kwargs): # self.func = func @@ -100,8 +94,6 @@ self.excinfo = excinfo self.item = item - def is_failure(self): - return True class ItemStart(ReportEvent): """ This class shows most of the start stuff, like directory, module, class Modified: py/branch/event/py/test2/reporter.py ============================================================================== --- py/branch/event/py/test2/reporter.py (original) +++ py/branch/event/py/test2/reporter.py Thu Jan 31 13:58:41 2008 @@ -39,8 +39,8 @@ self.flag = False def report(self, event): - if event.is_failure(): - self.flag = True + #if event.is_failure(): + # self.flag = True self.reportfun(event) __call__ = report 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 Thu Jan 31 13:58:41 2008 @@ -156,6 +156,7 @@ for host in self.hosts: rsync.add_target_host(host, destrelpath) rsync.send(raises=False) + self.config.hub.notify(repevent.RsyncFinished()) def setup_hosts(self): self.init_rsync() @@ -166,37 +167,35 @@ nodes.append(MasterNode(ch, self.config.hub.notify)) return nodes - def teardown_hosts(self, channels, nodes, - waiter=lambda : time.sleep(.1), exitfirst=False): - for channel in channels: - channel.send(None) - # XXX + def teardown_hosts(self, nodes, timeout=1.0): return - - clean = exitfirst + for node in nodes: + node.channel.send(None) + clean = False while not clean: clean = True for node in nodes: if node.pending: clean = False - waiter() - self.teardown_gateways(channels) + # 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, channels): + def teardown_gateways(self, nodes): return - self.config.hub.notify("tear down %r" %(channels,)) - for channel in channels: + self.config.hub.notify("teardown gateways %r" %(nodes,)) + for node in nodes: #try: try: - channel.waitclose(1.0) + node.channel.waitclose(1.0) except IOError: # timeout # force closing - channel.close() - channel.gateway.exit() + node.channel.close() + node.channel.gateway.exit() def gethomedir(): import os Modified: py/branch/event/py/test2/rsession/rsession.py ============================================================================== --- py/branch/event/py/test2/rsession/rsession.py (original) +++ py/branch/event/py/test2/rsession/rsession.py Thu Jan 31 13:58:41 2008 @@ -41,14 +41,12 @@ raise SystemExit def main(self): - """ main loop for running tests. """ hm = HostManager(self.config) hub = self.config.hub hub.notify(repevent.TestStarted(hm.hosts, self.config, hm.roots)) try: nodes = hm.setup_hosts() - hub.notify(repevent.RsyncFinished()) try: self.dispatch_tests(nodes) except (KeyboardInterrupt, SystemExit): @@ -60,8 +58,7 @@ raise print "tearing down nodes" - channels = [node.channel for node in nodes] - hm.teardown_hosts(channels, nodes) + hm.teardown_hosts(nodes) hub.notify(repevent.Nodes(nodes)) # XXX retval = reporter(repevent.TestFinished()) hub.notify(repevent.TestFinished()) 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 Thu Jan 31 13:58:41 2008 @@ -98,64 +98,33 @@ 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_ssh(self): - hosts = [HostInfo('localhost:%s' % self.dest)] - setup_events = [] - teardown_events = [] - tmpdir = self.source - config = py.test2.config._reparse([tmpdir]) - hm = HostManager(config, hosts) - - config.hub.append(setup_events.append) - nodes = hm.setup_hosts() - - config.hub.append(teardown_events.append) - hm.teardown_hosts([node.channel for node in nodes], nodes) - - count_rsyn_calls = [i for i in setup_events - if isinstance(i, repevent.HostRSyncing)] - assert len(count_rsyn_calls) == len([i for i in hosts]) - count_ready_calls = [i for i in setup_events - if isinstance(i, repevent.HostRSyncRootReady)] - assert len(count_ready_calls) == len([i for i in hosts]) - - # same for teardown events - teardown_wait_starts = [i for i in teardown_events - if isinstance(i, repevent.CallStart)] - teardown_wait_ends = [i for i in teardown_events - if isinstance(i, repevent.CallFinish)] - assert len(teardown_wait_starts) == len(hosts) - assert len(teardown_wait_ends) == len(hosts) def test_setup_teardown_run_ssh(self): hosts = [HostInfo('localhost:%s' % self.dest)] - allevents = [] - self.config.hub.append(allevents.append) + + queue = py.std.Queue.Queue() + self.config.hub.append(queue.put) hm = HostManager(self.config, hosts=hosts) nodes = hm.setup_hosts() - itempass = self.getexample("pass") - itemfail = self.getexample("fail") - itemskip = self.getexample("skip") - itemprint = self.getexample("print") - # actually run some tests for node in nodes: - node.send(itempass) - node.send(itemfail) - node.send(itemskip) - node.send(itemprint) - - hm.teardown_hosts([node.channel for node in nodes], nodes) - - events = [i for i in allevents - if isinstance(i, repevent.ReceivedItemOutcome)] + node.send(self.getexample("pass")) + node.send(self.getexample("fail")) + node.send(self.getexample("skip")) + node.send(self.getexample("print")) + + events = [] + while len(events) < 4 * len(nodes): + item = queue.get(timeout=0.5) + if isinstance(item, repevent.ReceivedItemOutcome): + 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] - for x in allevents: print x assert len(passed) == 2 * len(nodes) assert len(skipped) == len(nodes) assert len(events) == 4 * len(nodes) Modified: py/branch/event/py/test2/session.py ============================================================================== --- py/branch/event/py/test2/session.py (original) +++ py/branch/event/py/test2/session.py Thu Jan 31 13:58:41 2008 @@ -52,6 +52,7 @@ hub.notify(repevent.FailedTryiter(excinfo, next)) hub.notify(repevent.ItemFinish(next)) + class AbstractSession(object): """ An abstract session executes collectors/items through a runner. """ @@ -114,10 +115,12 @@ try: item = itemgenerator.next() outcome = self.run(item) + self.config.hub.notify(repevent.ReceivedItemOutcome(None, item, outcome)) if outcome is not None: if not outcome.passed and not outcome.skipped: failures.append((item, outcome)) - self.config.hub.notify(repevent.ReceivedItemOutcome(None, item, outcome)) + if self.config.option.exitfirst: + raise StopIteration() except StopIteration: break finally: Modified: py/branch/event/py/test2/testing/test_repevent.py ============================================================================== --- py/branch/event/py/test2/testing/test_repevent.py (original) +++ py/branch/event/py/test2/testing/test_repevent.py Thu Jan 31 13:58:41 2008 @@ -14,7 +14,8 @@ if method.startswith("report_") and method != "report_unknown": assert method[len('report_'):] in repevent.__dict__ -def test_repevent_failures(): +def XXXbrokentest_repevent_failures(): + # probably this thing here is a bad idea from py.__.test2.outcome import SerializableOutcome, ReprOutcome assert not repevent.ReportEvent().is_failure() From hpk at codespeak.net Thu Jan 31 15:24:02 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 31 Jan 2008 15:24:02 +0100 (CET) Subject: [py-svn] r51153 - in py/branch/event/py/test2: . rsession testing Message-ID: <20080131142402.821C71684C2@codespeak.net> Author: hpk Date: Thu Jan 31 15:24:01 2008 New Revision: 51153 Removed: py/branch/event/py/test2/testing/test_repevent.py Modified: py/branch/event/py/test2/collectonly.py py/branch/event/py/test2/config.py py/branch/event/py/test2/repevent.py py/branch/event/py/test2/rsession/rsession.py py/branch/event/py/test2/session.py py/branch/event/py/test2/testing/test_collectonly.py py/branch/event/py/test2/testing/test_config.py py/branch/event/py/test2/testing/test_remote.py py/branch/event/py/test2/testing/test_session2.py Log: a bit of renaming and streamlining of event handling (both in tests and code) Modified: py/branch/event/py/test2/collectonly.py ============================================================================== --- py/branch/event/py/test2/collectonly.py (original) +++ py/branch/event/py/test2/collectonly.py Thu Jan 31 15:24:01 2008 @@ -30,8 +30,3 @@ def summary(self): self.out.sep("=", "Total time: %.1f" % (self.timeend - self.timestart)) -class CollectSession(Session): - reporterclass = CollectReporter - - def run(self, item): - pass Modified: py/branch/event/py/test2/config.py ============================================================================== --- py/branch/event/py/test2/config.py (original) +++ py/branch/event/py/test2/config.py Thu Jan 31 15:24:01 2008 @@ -163,8 +163,6 @@ name = 'Session' if self.option.dist: name = 'RSession' - elif self.option.collectonly: - name = 'CollectSession' else: if self.option.looponfailing or self.option.executable: name = 'RemoteTerminalSession' Modified: py/branch/event/py/test2/repevent.py ============================================================================== --- py/branch/event/py/test2/repevent.py (original) +++ py/branch/event/py/test2/repevent.py Thu Jan 31 15:24:01 2008 @@ -17,13 +17,6 @@ for key, value in self.__dict__.items()] return "<%s %s>" %(self.__class__.__name__, " ".join(l),) -class SendItem(ReportEvent): - def __init__(self, channel, item): - self.item = item - self.channel = channel - if channel: - self.host = channel.gateway.host - class ReceivedItemOutcome(ReportEvent): def __init__(self, channel, item, outcome): self.channel = channel @@ -32,25 +25,12 @@ self.item = item self.outcome = outcome -#class CallEvent(ReportEvent): -# def __init__(self, func, args, kwargs): -# self.func = func -# self.args = args -# self.kwargs = kwargs -# -# def __repr__(self): -# call = "%s args=%s, kwargs=%s" %(self.func.__name__, -# self.args, self.kwargs) -# return '<%s %s>' %(self.__class__.__name__, call) -# -#class CallStart(CallEvent): -# pass -# -#class CallException(CallEvent): -# pass -# -#class CallFinish(CallEvent): -# pass +class SendItem(ReportEvent): + def __init__(self, channel, item): + self.item = item + self.channel = channel + if channel: + self.host = channel.gateway.host class HostRSyncing(ReportEvent): def __init__(self, host, root, remotepath, synced): @@ -80,10 +60,6 @@ def __init__(self): self.timeend = time.time() -class Nodes(ReportEvent): - def __init__(self, nodes): - self.nodes = nodes - class SkippedTryiter(ReportEvent): def __init__(self, excinfo, item): self.excinfo = excinfo @@ -94,6 +70,13 @@ self.excinfo = excinfo self.item = item +class CollectionStart(ReportEvent): + def __init__(self, collector): + self.collector = collector + +class CollectionFinish(ReportEvent): + def __init__(self, collector): + self.collector = collector class ItemStart(ReportEvent): """ This class shows most of the start stuff, like directory, module, class Modified: py/branch/event/py/test2/rsession/rsession.py ============================================================================== --- py/branch/event/py/test2/rsession/rsession.py (original) +++ py/branch/event/py/test2/rsession/rsession.py Thu Jan 31 15:24:01 2008 @@ -59,8 +59,6 @@ print "tearing down nodes" hm.teardown_hosts(nodes) - hub.notify(repevent.Nodes(nodes)) - # XXX retval = reporter(repevent.TestFinished()) hub.notify(repevent.TestFinished()) except (KeyboardInterrupt, SystemExit): hub.notify(repevent.InterruptedExecution()) Modified: py/branch/event/py/test2/session.py ============================================================================== --- py/branch/event/py/test2/session.py (original) +++ py/branch/event/py/test2/session.py Thu Jan 31 15:24:01 2008 @@ -27,7 +27,6 @@ if not colitems: break next = colitems.pop(0) - hub.notify(repevent.ItemStart(next)) if isinstance(next, stopitems): try: next._skipbykeyword(keyword) @@ -38,6 +37,7 @@ excinfo = py.code.ExceptionInfo() hub.notify(repevent.SkippedTryiter(excinfo, next)) else: + hub.notify(repevent.CollectionStart(next)) try: cols = [next.join(x) for x in next.run()] for x in itemgen(session, cols, keyword): @@ -50,8 +50,7 @@ hub.notify(repevent.SkippedTryiter(excinfo, next)) else: hub.notify(repevent.FailedTryiter(excinfo, next)) - hub.notify(repevent.ItemFinish(next)) - + hub.notify(repevent.CollectionFinish(next)) class AbstractSession(object): """ An abstract session executes collectors/items through a runner. @@ -114,13 +113,14 @@ while 1: try: item = itemgenerator.next() - outcome = self.run(item) - self.config.hub.notify(repevent.ReceivedItemOutcome(None, item, outcome)) - if outcome is not None: - if not outcome.passed and not outcome.skipped: - failures.append((item, outcome)) - if self.config.option.exitfirst: - raise StopIteration() + if not self.config.option.collectonly: + outcome = self.run(item) + self.config.hub.notify(repevent.ReceivedItemOutcome(None, item, outcome)) + if outcome is not None: + if not outcome.passed and not outcome.skipped: + failures.append((item, outcome)) + if self.config.option.exitfirst: + raise StopIteration() except StopIteration: break finally: Modified: py/branch/event/py/test2/testing/test_collectonly.py ============================================================================== --- py/branch/event/py/test2/testing/test_collectonly.py (original) +++ py/branch/event/py/test2/testing/test_collectonly.py Thu Jan 31 15:24:01 2008 @@ -1,6 +1,10 @@ import py + +from test_session import getevents_runmain +from py.__.test2 import repevent + class TestCollectonly: def setup_class(cls): tmp = py.test2.ensuretemp('itemgentest') @@ -27,23 +31,14 @@ config = py.test2.config._reparse([self.tmp, '--collectonly']) session = config.initsession() # test it all in once - cap = py.io.StdCaptureFD() - session.main() - out, err = cap.reset() - # XXX exact output matching - lines = """ - - - - - - - - - - - FAILED TO LOAD MODULE - - - - skipped - -""" - for line in lines: - assert line in out + allevents = getevents_runmain(session) + started = finished = 0 + for event in allevents: + assert not isinstance(event, repevent.ReceivedItemOutcome) + if isinstance(event, repevent.CollectionStart): + started += 1 + elif isinstance(event, repevent.CollectionFinish): + finished += 1 + + print started + assert started == finished Modified: py/branch/event/py/test2/testing/test_config.py ============================================================================== --- py/branch/event/py/test2/testing/test_config.py (original) +++ py/branch/event/py/test2/testing/test_config.py Thu Jan 31 15:24:01 2008 @@ -223,8 +223,6 @@ assert config._getsessionname() == 'RemoteTerminalSession' config = py.test2.config._reparse([self.tmpdir, '--dist', '--exec=x']) assert config._getsessionname() == 'RSession' - config = py.test2.config._reparse([self.tmpdir, '--collectonly']) - assert config._getsessionname() == 'CollectSession' def test_sessionname_lookup_custom(self): self.tmpdir.join("conftest.py").write(py.code.Source(""" Modified: py/branch/event/py/test2/testing/test_remote.py ============================================================================== --- py/branch/event/py/test2/testing/test_remote.py (original) +++ py/branch/event/py/test2/testing/test_remote.py Thu Jan 31 15:24:01 2008 @@ -1,5 +1,6 @@ import py from py.__.test2.testing.setupdata import setup_module +from test_session import getevents_runmain class TestRemote: def test_exec(self): @@ -13,15 +14,11 @@ config = py.test2.config._reparse( ['--exec=' + py.std.sys.executable, o]) - cls = config._getsessionclass() - out = [] # out = py.std.Queue.Queue() - session = cls(config, out.append) - failures = session.main() - for s in out: - if s.find('1 failed') != -1: - break - else: - py.test2.fail("did not see test_1 failure in output") + session = config.initsession() + allevents = getevents_runmain(session) + print allevents + failures = [x for x in allevents + if isinstance(x, repevent.ReceivedItemOutcome)] assert failures def test_looponfailing(self): Deleted: /py/branch/event/py/test2/testing/test_repevent.py ============================================================================== --- /py/branch/event/py/test2/testing/test_repevent.py Thu Jan 31 15:24:01 2008 +++ (empty file) @@ -1,34 +0,0 @@ -""" test reporting functionality. """ - -import py -from py.__.test2 import repevent - - -def test_reporter_methods_sanity(): - """ Checks if all the methods of reporter are sane - """ - from py.__.test2.reporter import RemoteReporter - - for method in dir(RemoteReporter): - - if method.startswith("report_") and method != "report_unknown": - assert method[len('report_'):] in repevent.__dict__ - -def XXXbrokentest_repevent_failures(): - # probably this thing here is a bad idea - from py.__.test2.outcome import SerializableOutcome, ReprOutcome - - assert not repevent.ReportEvent().is_failure() - assert not repevent.CallEvent(None, None, None).is_failure() - assert repevent.FailedTryiter(None, None).is_failure() - out = ReprOutcome(SerializableOutcome().make_repr()) - assert not repevent.ReceivedItemOutcome(None, None, out).is_failure() - out = ReprOutcome(SerializableOutcome(skipped="xxx").make_repr()) - assert not repevent.ReceivedItemOutcome(None, None, out).is_failure() - try: - 1/0 - except: - exc = py.code.ExceptionInfo() - out = ReprOutcome(SerializableOutcome(excinfo=exc).make_repr()) - assert repevent.ReceivedItemOutcome(None, None, out).is_failure() - Modified: py/branch/event/py/test2/testing/test_session2.py ============================================================================== --- py/branch/event/py/test2/testing/test_session2.py (original) +++ py/branch/event/py/test2/testing/test_session2.py Thu Jan 31 15:24:01 2008 @@ -258,7 +258,7 @@ args = [str(tmpdir.join("sub6"))] config = py.test2.config._reparse(args) lsession = Session(config) - allevents = getevents(lsession) + allevents = getevents_runmain(lsession) testevents = [x for x in allevents if isinstance(x, repevent.ReceivedItemOutcome)] failevents = [i for i in testevents if i.outcome.excinfo] From hpk at codespeak.net Thu Jan 31 15:35:53 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 31 Jan 2008 15:35:53 +0100 (CET) Subject: [py-svn] r51157 - in py/branch/event/py/test2: . rsession testing Message-ID: <20080131143553.0F2101684C2@codespeak.net> Author: hpk Date: Thu Jan 31 15:35:52 2008 New Revision: 51157 Modified: py/branch/event/py/test2/repevent.py py/branch/event/py/test2/reporter.py py/branch/event/py/test2/rsession/rest.py py/branch/event/py/test2/rsession/rsession.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_reporter.py Log: some more renaming Modified: py/branch/event/py/test2/repevent.py ============================================================================== --- py/branch/event/py/test2/repevent.py (original) +++ py/branch/event/py/test2/repevent.py Thu Jan 31 15:35:52 2008 @@ -49,14 +49,14 @@ self.host = host self.root = root -class TestStarted(ReportEvent): +class SessionStart(ReportEvent): def __init__(self, hosts, config, roots): self.hosts = hosts self.roots = roots self.timestart = time.time() self.config = config -class TestFinished(ReportEvent): +class SessionFinish(ReportEvent): def __init__(self): self.timeend = time.time() Modified: py/branch/event/py/test2/reporter.py ============================================================================== --- py/branch/event/py/test2/reporter.py (original) +++ py/branch/event/py/test2/reporter.py Thu Jan 31 15:35:52 2008 @@ -146,7 +146,7 @@ self.out.line() self.repr_failure(event.item, event.outcome) - def report_TestFinished(self, item): + def report_SessionFinish(self, item): self.out.line() assert hasattr(self, 'timestart') self.timeend = item.timeend @@ -157,8 +157,8 @@ self.summary() return len(self.failed_tests_outcome) > 0 - report_InterruptedExecution = report_TestFinished - report_CrashedExecution = report_TestFinished + report_InterruptedExecution = report_SessionFinish + report_CrashedExecution = report_SessionFinish def hangs(self): h = [] 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 Thu Jan 31 15:35:52 2008 @@ -58,7 +58,7 @@ self.add_rest(Title(txt, abovechar='=', belowchar='=')) self.timestart = event.timestart - def report_TestFinished(self, item): + def report_TestSessionFinish(self, item): self.timeend = item.timeend self.summary() return len(self.failed_tests_outcome) > 0 Modified: py/branch/event/py/test2/rsession/rsession.py ============================================================================== --- py/branch/event/py/test2/rsession/rsession.py (original) +++ py/branch/event/py/test2/rsession/rsession.py Thu Jan 31 15:35:52 2008 @@ -44,7 +44,7 @@ """ main loop for running tests. """ hm = HostManager(self.config) hub = self.config.hub - hub.notify(repevent.TestStarted(hm.hosts, self.config, hm.roots)) + hub.notify(repevent.SessionStart(hm.hosts, self.config, hm.roots)) try: nodes = hm.setup_hosts() try: @@ -59,7 +59,7 @@ print "tearing down nodes" hm.teardown_hosts(nodes) - hub.notify(repevent.TestFinished()) + hub.notify(repevent.SessionFinish()) except (KeyboardInterrupt, SystemExit): hub.notify(repevent.InterruptedExecution()) raise 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 Thu Jan 31 15:35:52 2008 @@ -237,7 +237,7 @@ args['hostkey'] = '' elif isinstance(event, repevent.ItemStart): args = add_item(event) - elif isinstance(event, repevent.TestFinished): + elif isinstance(event, repevent.TestSessionFinish): args = {} args['run'] = str(self.all) args['fails'] = str(len(self.fail_reasons)) @@ -321,12 +321,12 @@ self.start_event.set() self.pending_events.put(event) - def report_TestFinished(self, event): + def report_TestSessionFinish(self, event): self.pending_events.put(event) kill_server() - report_InterruptedExecution = report_TestFinished - report_CrashedExecution = report_TestFinished + report_InterruptedExecution = report_TestSessionFinish + report_CrashedExecution = report_TestSessionFinish def report(self, what): repfun = getattr(self, "report_" + what.__class__.__name__, 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 Thu Jan 31 15:35:52 2008 @@ -199,7 +199,7 @@ return True add_received_item_outcome(msg, module_part) - elif msg['type'] == 'TestFinished': + elif msg['type'] == 'TestSessionFinish': text = "FINISHED %s run, %s failures, %s skipped" % (msg['run'], msg['fails'], msg['skips']) glob.finished = True dom.document.title = "Py.test %s" % text Modified: py/branch/event/py/test2/session.py ============================================================================== --- py/branch/event/py/test2/session.py (original) +++ py/branch/event/py/test2/session.py Thu Jan 31 15:35:52 2008 @@ -90,7 +90,7 @@ def header(self, colitems): """ setup any neccessary resources ahead of the test run. """ - self.config.hub.notify(repevent.TestStarted(None, self.config, None)) + self.config.hub.notify(repevent.SessionStart(None, self.config, None)) if not self.config.option.nomagic: py.magic.invoke(assertion=1) @@ -99,7 +99,7 @@ py.test2.collect.Function._state.teardown_all() if not self.config.option.nomagic: py.magic.revoke(assertion=1) - self.config.hub.notify(repevent.TestFinished()) + self.config.hub.notify(repevent.SessionFinish()) def main(self): """ main loop for running tests. """ 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 Thu Jan 31 15:35:52 2008 @@ -156,7 +156,7 @@ r.report(repevent.TestStarted(hosts, config, ["a"])) r.report(repevent.RsyncFinished()) list(itemgen(MockSession(r), [rootcol], r.report)) - r.report(repevent.TestFinished()) + r.report(repevent.TestSessionFinish()) return r cap = py.io.StdCaptureFD() @@ -178,7 +178,7 @@ r.report(repevent.RsyncFinished()) rootcol = py.test2.collect.Directory(tmpdir) list(itemgen(MockSession(r), [rootcol], r.report)) - r.report(repevent.TestFinished()) + r.report(repevent.TestSessionFinish()) out, err = cap.reset() assert not err for i in ['+ testmodule:', 'test_one.py[1]']: # XXX finish