From jan at codespeak.net Thu Jun 1 00:47:23 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Thu, 1 Jun 2006 00:47:23 +0200 (CEST) Subject: [py-svn] r28041 - py/dist/py/path/svn/testing Message-ID: <20060531224723.BCC191005A@code0.codespeak.net> Author: jan Date: Thu Jun 1 00:47:21 2006 New Revision: 28041 Modified: py/dist/py/path/svn/testing/svntestbase.py py/dist/py/path/svn/testing/test_wccommand.py Log: added tests for escaping svnwc names/currently disabled Modified: py/dist/py/path/svn/testing/svntestbase.py ============================================================================== --- py/dist/py/path/svn/testing/svntestbase.py (original) +++ py/dist/py/path/svn/testing/svntestbase.py Thu Jun 1 00:47:21 2006 @@ -11,7 +11,6 @@ # cache previously obtained wcs! # def getrepowc(): - #repo = py.test.ensuretemp('repo$*hehe') repo = py.test.ensuretemp('repo') wcdir = py.test.ensuretemp('wc') if not repo.listdir(): Modified: py/dist/py/path/svn/testing/test_wccommand.py ============================================================================== --- py/dist/py/path/svn/testing/test_wccommand.py (original) +++ py/dist/py/path/svn/testing/test_wccommand.py Thu Jun 1 00:47:21 2006 @@ -6,6 +6,14 @@ except py.error.ENOENT: py.test.skip("cannot test py.path.svn, 'svn' binary not found") +class disable_TestWCSvnCommandPathEscapeString(CommonSvnTests): + + def setup_class(cls): + escape_string = 'df01c67e48$dc4d5b00$7f0aa8c0 at codespeak.net' + root = py.test.ensuretemp(escape_string) + cls.root = py.path.svnwc(root) + + class TestWCSvnCommandPath(CommonSvnTests): def setup_class(cls): From guido at codespeak.net Sat Jun 3 12:40:59 2006 From: guido at codespeak.net (guido at codespeak.net) Date: Sat, 3 Jun 2006 12:40:59 +0200 (CEST) Subject: [py-svn] r28145 - py/dist/py/path/svn Message-ID: <20060603104059.D664C10070@code0.codespeak.net> Author: guido Date: Sat Jun 3 12:40:58 2006 New Revision: 28145 Modified: py/dist/py/path/svn/urlcommand.py Log: Fixed support for parsing Subversion's 1.3 ls output which has different field sizes from 1.2. Modified: py/dist/py/path/svn/urlcommand.py ============================================================================== --- py/dist/py/path/svn/urlcommand.py (original) +++ py/dist/py/path/svn/urlcommand.py Sat Jun 3 12:40:58 2006 @@ -220,27 +220,31 @@ #01234567890123456789012345678901234567890123467 # 2256 hpk 165 Nov 24 17:55 __init__.py +# XXX spotted by Guido, SVN 1.3.0 has different aligning, breaks the code!!! +# 1312 johnny 1627 May 05 14:32 test_decorators.py # class InfoSvnCommand: - #lspattern = re.compile(r'(\D*)(\d*)\s*(\w*)\s*( + # the '0?' part in the middle is an indication of whether the resource is + # locked, see 'svn help ls' + lspattern = re.compile( + r'^ *(?P\d+) +(?P\w+) +(0? *(?P\d+))? ' + '*(?P\w+ +\d{2} +[\d:]+) +(?P.*)$') def __init__(self, line): # this is a typical line from 'svn ls http://...' #_ 1127 jum 0 Jul 13 15:28 branch/ - l = [line[:7], line[7:16], line[16:27], line[27:40], line[41:]] - l = map(str.lstrip, l) - - self._name = l.pop() + match = self.lspattern.match(line) + data = match.groupdict() + self._name = data['file'] if self._name[-1] == '/': self._name = self._name[:-1] self.kind = 'dir' else: self.kind = 'file' #self.has_props = l.pop(0) == 'P' - self.created_rev = int(l[0]) - self.last_author = l[1] - self.size = l[2] and int(l[2]) or 0 - datestr = l[3] - self.mtime = parse_time_with_missing_year(datestr) + self.created_rev = data['rev'] + self.last_author = data['author'] + self.size = data['size'] and int(data['size']) or 0 + self.mtime = parse_time_with_missing_year(data['date']) self.time = self.mtime * 1000000 def __eq__(self, other): From jan at codespeak.net Sat Jun 3 12:45:37 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Sat, 3 Jun 2006 12:45:37 +0200 (CEST) Subject: [py-svn] r28146 - py/dist/py/path/svn/testing Message-ID: <20060603104537.7148A10070@code0.codespeak.net> Author: jan Date: Sat Jun 3 12:45:36 2006 New Revision: 28146 Modified: py/dist/py/path/svn/testing/test_urlcommand.py Log: added tests for the InfoSvnCommand fix in urlcommand.py Modified: py/dist/py/path/svn/testing/test_urlcommand.py ============================================================================== --- py/dist/py/path/svn/testing/test_urlcommand.py (original) +++ py/dist/py/path/svn/testing/test_urlcommand.py Sat Jun 3 12:45:36 2006 @@ -1,4 +1,5 @@ import py +from py.__.path.svn.urlcommand import InfoSvnCommand from py.__.path.svn.testing.svntestbase import CommonCommandAndBindingTests, getrepowc try: @@ -24,3 +25,25 @@ from time import gmtime t = gmtime(res[0].date) assert t.tm_year == 2003 and t.tm_mon == 7 and t.tm_mday == 17 + + +class TestSvnInfoCommand: + + def test_svn_1_2(self): + line = " 2256 hpk 165 Nov 24 17:55 __init__.py" + info = InfoSvnCommand(line) + assert info.last_author == 'hpk' + assert info.created_rev == 2256 + assert info.kind == 'file' + assert info.mtime == 1132851300.0 + assert info.size == 165 + assert info.time == 1132851300000000.0 + + py.std.pprint.pprint(info.__dict__) + assert 0 + + def test_svn_1_3(self): + line =" 4784 hpk 2 Jun 01 2004 __init__.py" + info = InfoSvnCommand(line) + assert info.last_author == 'hpk' + assert info.kind == 'file' From guido at codespeak.net Sat Jun 3 12:47:56 2006 From: guido at codespeak.net (guido at codespeak.net) Date: Sat, 3 Jun 2006 12:47:56 +0200 (CEST) Subject: [py-svn] r28147 - py/dist/py/path/svn Message-ID: <20060603104756.0F1DE10070@code0.codespeak.net> Author: guido Date: Sat Jun 3 12:47:55 2006 New Revision: 28147 Modified: py/dist/py/path/svn/urlcommand.py Log: Revision should have been an integer. Modified: py/dist/py/path/svn/urlcommand.py ============================================================================== --- py/dist/py/path/svn/urlcommand.py (original) +++ py/dist/py/path/svn/urlcommand.py Sat Jun 3 12:47:55 2006 @@ -241,7 +241,7 @@ else: self.kind = 'file' #self.has_props = l.pop(0) == 'P' - self.created_rev = data['rev'] + self.created_rev = int(data['rev']) self.last_author = data['author'] self.size = data['size'] and int(data['size']) or 0 self.mtime = parse_time_with_missing_year(data['date']) From jan at codespeak.net Sat Jun 3 12:51:39 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Sat, 3 Jun 2006 12:51:39 +0200 (CEST) Subject: [py-svn] r28149 - py/dist/py/path/svn/testing Message-ID: <20060603105139.3914E10070@code0.codespeak.net> Author: jan Date: Sat Jun 3 12:51:38 2006 New Revision: 28149 Modified: py/dist/py/path/svn/testing/test_wccommand.py Log: aehm, removed debugging code Modified: py/dist/py/path/svn/testing/test_wccommand.py ============================================================================== --- py/dist/py/path/svn/testing/test_wccommand.py (original) +++ py/dist/py/path/svn/testing/test_wccommand.py Sat Jun 3 12:51:38 2006 @@ -1,6 +1,6 @@ import py from py.__.path.svn.testing.svntestbase import CommonSvnTests, getrepowc - +from py.__.path.svn.wccommand import InfoSvnWCCommand try: svnversion = py.path.local.sysfind('svn') except py.error.ENOENT: @@ -209,3 +209,54 @@ # assert wcpath.info().rev > 2100 # finally: # wcpath.localpath.remove(rec=1) + + +class TestInfoSvnWCCommand: + + def test_svn_1_2(self): + output = """ + Path: wccommand.py + Name: wccommand.py + URL: http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py + Repository UUID: fd0d7bf2-dfb6-0310-8d31-b7ecfe96aada + Revision: 28137 + Node Kind: file + Schedule: normal + Last Changed Author: jan + Last Changed Rev: 27939 + Last Changed Date: 2006-05-30 20:45:26 +0200 (Tue, 30 May 2006) + Text Last Updated: 2006-06-01 00:42:53 +0200 (Thu, 01 Jun 2006) + Properties Last Updated: 2006-05-23 11:54:59 +0200 (Tue, 23 May 2006) + Checksum: 357e44880e5d80157cc5fbc3ce9822e3 + """ + + info = InfoSvnWCCommand(output) + py.std.pprint.pprint(info.__dict__) + assert info.last_author == 'jan' + assert info.kind == 'file' + assert info.mtime == 1149014726.0 + assert info.url == 'http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py' + assert info.time == 1132851300000000.0 + + def test_svn_1_3(self): + output = """ + Path: wccommand.py + Name: wccommand.py + URL: http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py + Repository Root: http://codespeak.net/svn + Repository UUID: fd0d7bf2-dfb6-0310-8d31-b7ecfe96aada + Revision: 28124 + Node Kind: file + Schedule: normal + Last Changed Author: jan + Last Changed Rev: 27939 + Last Changed Date: 2006-05-30 20:45:26 +0200 (Tue, 30 May 2006) + Text Last Updated: 2006-06-02 23:46:11 +0200 (Fri, 02 Jun 2006) + Properties Last Updated: 2006-06-02 23:45:28 +0200 (Fri, 02 Jun 2006) + Checksum: 357e44880e5d80157cc5fbc3ce9822e3 + """ + info = InfoSvnWCCommand(output) + assert info.last_author == 'hpk' + assert info.kind == 'file' + assert info.mtime == 1132851300.0 + assert info.time == 1132851300000000.0 From guido at codespeak.net Sat Jun 3 12:58:25 2006 From: guido at codespeak.net (guido at codespeak.net) Date: Sat, 3 Jun 2006 12:58:25 +0200 (CEST) Subject: [py-svn] r28150 - py/dist/py/path/svn/testing Message-ID: <20060603105825.7A27110060@code0.codespeak.net> Author: guido Date: Sat Jun 3 12:58:24 2006 New Revision: 28150 Modified: py/dist/py/path/svn/testing/test_wccommand.py Log: Fixed some temp values. Modified: py/dist/py/path/svn/testing/test_wccommand.py ============================================================================== --- py/dist/py/path/svn/testing/test_wccommand.py (original) +++ py/dist/py/path/svn/testing/test_wccommand.py Sat Jun 3 12:58:24 2006 @@ -236,7 +236,7 @@ assert info.kind == 'file' assert info.mtime == 1149014726.0 assert info.url == 'http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py' - assert info.time == 1132851300000000.0 + assert info.time == 1149014726000000.0 def test_svn_1_3(self): output = """ @@ -256,7 +256,7 @@ Checksum: 357e44880e5d80157cc5fbc3ce9822e3 """ info = InfoSvnWCCommand(output) - assert info.last_author == 'hpk' + assert info.last_author == 'jan' assert info.kind == 'file' - assert info.mtime == 1132851300.0 - assert info.time == 1132851300000000.0 + assert info.mtime == 1149014726.0 + assert info.time == 1149014726000000.0 From jan at codespeak.net Sat Jun 3 13:11:05 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Sat, 3 Jun 2006 13:11:05 +0200 (CEST) Subject: [py-svn] r28151 - py/dist/py/path/svn/testing Message-ID: <20060603111105.B8E4E1006B@code0.codespeak.net> Author: jan Date: Sat Jun 3 13:11:04 2006 New Revision: 28151 Modified: py/dist/py/path/svn/testing/test_urlcommand.py py/dist/py/path/svn/testing/test_wccommand.py Log: test for InfoSvnWCCommand in svn/wccommand.py, and some more checks for SvnInfoCommand Modified: py/dist/py/path/svn/testing/test_urlcommand.py ============================================================================== --- py/dist/py/path/svn/testing/test_urlcommand.py (original) +++ py/dist/py/path/svn/testing/test_urlcommand.py Sat Jun 3 13:11:04 2006 @@ -39,9 +39,6 @@ assert info.size == 165 assert info.time == 1132851300000000.0 - py.std.pprint.pprint(info.__dict__) - assert 0 - def test_svn_1_3(self): line =" 4784 hpk 2 Jun 01 2004 __init__.py" info = InfoSvnCommand(line) Modified: py/dist/py/path/svn/testing/test_wccommand.py ============================================================================== --- py/dist/py/path/svn/testing/test_wccommand.py (original) +++ py/dist/py/path/svn/testing/test_wccommand.py Sat Jun 3 13:11:04 2006 @@ -231,12 +231,13 @@ """ info = InfoSvnWCCommand(output) - py.std.pprint.pprint(info.__dict__) assert info.last_author == 'jan' assert info.kind == 'file' assert info.mtime == 1149014726.0 assert info.url == 'http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py' assert info.time == 1149014726000000.0 + assert info.rev == 28137 + def test_svn_1_3(self): output = """ @@ -259,4 +260,6 @@ assert info.last_author == 'jan' assert info.kind == 'file' assert info.mtime == 1149014726.0 + assert info.url == 'http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py' + assert info.rev == 28124 assert info.time == 1149014726000000.0 From jan at codespeak.net Sat Jun 3 14:14:49 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Sat, 3 Jun 2006 14:14:49 +0200 (CEST) Subject: [py-svn] r28156 - py/dist/py/path/svn Message-ID: <20060603121449.C2CC910070@code0.codespeak.net> Author: jan Date: Sat Jun 3 14:14:46 2006 New Revision: 28156 Modified: py/dist/py/path/svn/wccommand.py Log: simple fix for a hard to find bug, the problem is that the svn binary return with a code of 0 but writes to stderr Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Sat Jun 3 14:14:46 2006 @@ -354,7 +354,7 @@ if e.err.find('Path is not a working copy directory') != -1: raise py.error.ENOENT(self, e.err) raise - if output.lower().find('not a versioned resource') != -1: + if output.strip() == '' or output.lower().find('not a versioned resource') != -1: raise py.error.ENOENT(self, output) info = InfoSvnWCCommand(output) @@ -499,7 +499,8 @@ try: self.url = d['url'] except KeyError: - raise ValueError, "Not a versioned resource %r" % path + raise ValueError, "Not a versioned resource" + #raise ValueError, "Not a versioned resource %r" % path self.kind = d['nodekind'] == 'directory' and 'dir' or d['nodekind'] self.rev = int(d['revision']) self.path = py.path.local(d['path']) From guido at codespeak.net Sat Jun 3 14:17:32 2006 From: guido at codespeak.net (guido at codespeak.net) Date: Sat, 3 Jun 2006 14:17:32 +0200 (CEST) Subject: [py-svn] r28157 - py/dist/py/path/svn Message-ID: <20060603121732.DF25310070@code0.codespeak.net> Author: guido Date: Sat Jun 3 14:17:32 2006 New Revision: 28157 Modified: py/dist/py/path/svn/wccommand.py Log: Added comment for somewhat nasty fix and broke line apart. ;) Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Sat Jun 3 14:17:32 2006 @@ -354,7 +354,11 @@ if e.err.find('Path is not a working copy directory') != -1: raise py.error.ENOENT(self, e.err) raise - if output.strip() == '' or output.lower().find('not a versioned resource') != -1: + # XXX SVN 1.3 has output on stderr instead of stdout (while it does + # return 0!), so a bit nasty, but we assume no output is output + # to stderr... + if (output.strip() == '' or + output.lower().find('not a versioned resource') != -1): raise py.error.ENOENT(self, output) info = InfoSvnWCCommand(output) From jan at codespeak.net Sat Jun 3 14:30:07 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Sat, 3 Jun 2006 14:30:07 +0200 (CEST) Subject: [py-svn] r28158 - py/dist/py/path/svn/testing Message-ID: <20060603123007.6267010070@code0.codespeak.net> Author: jan Date: Sat Jun 3 14:30:05 2006 New Revision: 28158 Modified: py/dist/py/path/svn/testing/test_wccommand.py Log: fixed the tests for SvnInfoWCCommand Modified: py/dist/py/path/svn/testing/test_wccommand.py ============================================================================== --- py/dist/py/path/svn/testing/test_wccommand.py (original) +++ py/dist/py/path/svn/testing/test_wccommand.py Sat Jun 3 14:30:05 2006 @@ -215,8 +215,8 @@ def test_svn_1_2(self): output = """ - Path: wccommand.py - Name: wccommand.py + Path: test_wccommand.py + Name: test_wccommand.py URL: http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py Repository UUID: fd0d7bf2-dfb6-0310-8d31-b7ecfe96aada Revision: 28137 @@ -229,8 +229,9 @@ Properties Last Updated: 2006-05-23 11:54:59 +0200 (Tue, 23 May 2006) Checksum: 357e44880e5d80157cc5fbc3ce9822e3 """ - + path = py.magic.autopath().dirpath().chdir() info = InfoSvnWCCommand(output) + path.chdir() assert info.last_author == 'jan' assert info.kind == 'file' assert info.mtime == 1149014726.0 @@ -241,8 +242,8 @@ def test_svn_1_3(self): output = """ - Path: wccommand.py - Name: wccommand.py + Path: test_wccommand.py + Name: test_wccommand.py URL: http://codespeak.net/svn/py/dist/py/path/svn/wccommand.py Repository Root: http://codespeak.net/svn Repository UUID: fd0d7bf2-dfb6-0310-8d31-b7ecfe96aada @@ -256,7 +257,9 @@ Properties Last Updated: 2006-06-02 23:45:28 +0200 (Fri, 02 Jun 2006) Checksum: 357e44880e5d80157cc5fbc3ce9822e3 """ + path = py.magic.autopath().dirpath().chdir() info = InfoSvnWCCommand(output) + path.chdir() assert info.last_author == 'jan' assert info.kind == 'file' assert info.mtime == 1149014726.0 From hpk at codespeak.net Sat Jun 3 19:44:42 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 3 Jun 2006 19:44:42 +0200 (CEST) Subject: [py-svn] r28194 - py/dist/py/test/testing Message-ID: <20060603174442.997B610060@code0.codespeak.net> Author: hpk Date: Sat Jun 3 19:44:41 2006 New Revision: 28194 Modified: py/dist/py/test/testing/test_collect.py Log: fix wrongly named test (copy-pasted but not modified) Modified: py/dist/py/test/testing/test_collect.py ============================================================================== --- py/dist/py/test/testing/test_collect.py (original) +++ py/dist/py/test/testing/test_collect.py Sat Jun 3 19:44:41 2006 @@ -78,11 +78,10 @@ assert isinstance(colitem, py.test.collect.Class) assert not colitem.run() -def test_disabled_class(): +def test_disabled_module(): col = py.test.collect.Module(datadir.join('disabled_module.py')) l = col.run() assert len(l) == 0 - class Testsomeclass: disabled = True From hpk at codespeak.net Sat Jun 3 20:11:06 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 3 Jun 2006 20:11:06 +0200 (CEST) Subject: [py-svn] r28195 - in py/dist/py/test: . testing Message-ID: <20060603181106.9972E10060@code0.codespeak.net> Author: hpk Date: Sat Jun 3 20:11:05 2006 New Revision: 28195 Modified: py/dist/py/test/collect.py py/dist/py/test/testing/test_collect.py py/dist/py/test/testing/test_session.py Log: unify behaviour of custom collections some more, now you can have custom (non-python, i.e. ReST collectors) and still specify directly a file, aka py.test py/documentation/talk/execnet-overview.txt which didn't use to work before. Modified: py/dist/py/test/collect.py ============================================================================== --- py/dist/py/test/collect.py (original) +++ py/dist/py/test/collect.py Sat Jun 3 20:11:05 2006 @@ -40,17 +40,14 @@ raise py.error.ENOENT(fspath) pkgpath = fspath.pypkgpath() if pkgpath is None: - clsname = fspath.check(file=1) and 'Module' or 'Directory' - fscol = py.test.Config.getvalue(clsname, fspath) - current = fscol(fspath) - else: - Directory = py.test.Config.getvalue('Directory', pkgpath) - current = Directory(pkgpath) - #print "pkgpath", pkgpath - names = filter(None, fspath.relto(pkgpath).split(fspath.sep)) - for name in names: - current = current.join(name) - assert current, "joining %r resulted in None!" % (names,) + pkgpath = fspath.dirpath() + Directory = py.test.Config.getvalue('Directory', pkgpath) + current = Directory(pkgpath) + #print "pkgpath", pkgpath + names = filter(None, fspath.relto(pkgpath).split(fspath.sep)) + for name in names: + current = current.join(name) + assert current, "joining %r resulted in None!" % (names,) top = current.listchain()[0] #top._config = config return current Modified: py/dist/py/test/testing/test_collect.py ============================================================================== --- py/dist/py/test/testing/test_collect.py (original) +++ py/dist/py/test/testing/test_collect.py Sat Jun 3 20:11:05 2006 @@ -148,7 +148,7 @@ assert l2[0].name == '[0]' assert l2[1].name == '[1]' -def test_custom_collection_from_conftest(): +def test_custom_python_collection_from_conftest(): o = tmpdir.ensure('customconfigtest', dir=1) o.ensure('conftest.py').write("""if 1: import py @@ -196,6 +196,60 @@ finally: old.chdir() + # test that running the file directly works + config, args = py.test.Config.parse([str(checkfile)]) + out = py.std.cStringIO.StringIO() + session = config.getsessionclass()(config, out) + session.main(args) + l = session.getitemoutcomepairs(py.test.Item.Passed) + assert len(l) == 2 + +def test_custom_NONpython_collection_from_conftest(): + o = tmpdir.ensure('customconfigtest_nonpython', dir=1) + o.ensure('conftest.py').write("""if 1: + import py + class CustomItem(py.test.Item): + def run(self): + pass + + class Directory(py.test.collect.Directory): + def filefilter(self, fspath): + return fspath.check(basestarts='check_', ext='.txt') + def join(self, name): + if not name.endswith('.txt'): + return super(Directory, self).join(name) + p = self.fspath.join(name) + if p.check(file=1): + return CustomItem(p, parent=self) + """) + checkfile = o.ensure('somedir', 'moredir', 'check_something.txt') + + from py.__.test.collect import getfscollector + for x in (o, checkfile, checkfile.dirpath()): + print "checking that %s returns custom items" % (x,) + col = getfscollector(x) + assert len(list(col.tryiter(py.test.Item))) == 1 + #assert items[1].__class__.__name__ == 'MyFunction' + + # test that running a session works from the directories + old = o.chdir() + try: + config, args = py.test.Config.parse([]) + out = py.std.cStringIO.StringIO() + session = config.getsessionclass()(config, out) + session.main(args) + l = session.getitemoutcomepairs(py.test.Item.Passed) + assert len(l) == 1 + finally: + old.chdir() + + # test that running the file directly works + config, args = py.test.Config.parse([str(checkfile)]) + out = py.std.cStringIO.StringIO() + session = config.getsessionclass()(config, out) + session.main(args) + l = session.getitemoutcomepairs(py.test.Item.Passed) + assert len(l) == 1 def test_order_of_execution_generator_same_codeline(): test_list = [] Modified: py/dist/py/test/testing/test_session.py ============================================================================== --- py/dist/py/test/testing/test_session.py (original) +++ py/dist/py/test/testing/test_session.py Sat Jun 3 20:11:05 2006 @@ -272,7 +272,7 @@ item, result = l[-1] assert item.name == 'test_4' names = item.listnames() - assert names == ['ordertest', 'test_orderofexecution.py', 'Testmygroup', '()', 'test_4'] + assert names == ['test_drive', 'ordertest', 'test_orderofexecution.py', 'Testmygroup', '()', 'test_4'] def test_nested_import_error(self): o = tmpdir.ensure('Ians_importfailure', dir=1) From hpk at codespeak.net Sat Jun 3 20:12:03 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 3 Jun 2006 20:12:03 +0200 (CEST) Subject: [py-svn] r28196 - py/dist/py/misc Message-ID: <20060603181203.B069A10060@code0.codespeak.net> Author: hpk Date: Sat Jun 3 20:12:03 2006 New Revision: 28196 Modified: py/dist/py/misc/svnlook.py Log: add a small method for getting the youngest rev Modified: py/dist/py/misc/svnlook.py ============================================================================== --- py/dist/py/misc/svnlook.py (original) +++ py/dist/py/misc/svnlook.py Sat Jun 3 20:12:03 2006 @@ -24,6 +24,7 @@ for line in out.strip().split('\n'): l.append(ChangeItem(repo, revision, line)) return l - - - + +def youngest(repo): + out = py.process.cmdexec("svnlook youngest %s" %(repo,)) + return int(out) From guido at codespeak.net Mon Jun 5 00:13:50 2006 From: guido at codespeak.net (guido at codespeak.net) Date: Mon, 5 Jun 2006 00:13:50 +0200 (CEST) Subject: [py-svn] r28294 - py/dist/py/path/svn Message-ID: <20060604221350.F02311006F@code0.codespeak.net> Author: guido Date: Mon Jun 5 00:13:41 2006 New Revision: 28294 Modified: py/dist/py/path/svn/urlcommand.py Log: Allowing more characters (e.g. ?) in the author field. Modified: py/dist/py/path/svn/urlcommand.py ============================================================================== --- py/dist/py/path/svn/urlcommand.py (original) +++ py/dist/py/path/svn/urlcommand.py Mon Jun 5 00:13:41 2006 @@ -66,6 +66,7 @@ return out def _encodedurl(self): + return self.strpath scheme, rest = self.strpath.split(':', 1) rest = py.std.urllib.quote(rest) return "%s:%s" %(scheme, rest) @@ -227,7 +228,7 @@ # the '0?' part in the middle is an indication of whether the resource is # locked, see 'svn help ls' lspattern = re.compile( - r'^ *(?P\d+) +(?P\w+) +(0? *(?P\d+))? ' + r'^ *(?P\d+) +(?P\S+) +(0? *(?P\d+))? ' '*(?P\w+ +\d{2} +[\d:]+) +(?P.*)$') def __init__(self, line): # this is a typical line from 'svn ls http://...' From hpk at codespeak.net Mon Jun 5 08:08:59 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 5 Jun 2006 08:08:59 +0200 (CEST) Subject: [py-svn] r28295 - py/dist/py/path/svn Message-ID: <20060605060859.1FD5810063@code0.codespeak.net> Author: hpk Date: Mon Jun 5 08:08:55 2006 New Revision: 28295 Modified: py/dist/py/path/svn/urlcommand.py Log: remove wrong escaping code and add XXX for doing it properly Modified: py/dist/py/path/svn/urlcommand.py ============================================================================== --- py/dist/py/path/svn/urlcommand.py (original) +++ py/dist/py/path/svn/urlcommand.py Mon Jun 5 08:08:55 2006 @@ -66,11 +66,8 @@ return out def _encodedurl(self): + # XXX do proper escaping of special characters return self.strpath - scheme, rest = self.strpath.split(':', 1) - rest = py.std.urllib.quote(rest) - return "%s:%s" %(scheme, rest) - def open(self, mode='r'): assert 'w' not in mode and 'a' not in mode, "XXX not implemented for svn cmdline" From hpk at codespeak.net Mon Jun 5 11:09:38 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 5 Jun 2006 11:09:38 +0200 (CEST) Subject: [py-svn] r28304 - py/dist/py/test/terminal Message-ID: <20060605090938.BABFF10053@code0.codespeak.net> Author: hpk Date: Mon Jun 5 11:09:36 2006 New Revision: 28304 Modified: py/dist/py/test/terminal/terminal.py Log: bail out Armin's controversial rev 23481, it really hurts in too many cases. If neccessary we make it configurable (by conftest so that pypy translation, e.g., could use the reverse, but i actually think it would be better to look for other solutions, like reducing the output or not showing all logging output by default etc.) Modified: py/dist/py/test/terminal/terminal.py ============================================================================== --- py/dist/py/test/terminal/terminal.py (original) +++ py/dist/py/test/terminal/terminal.py Mon Jun 5 11:09:36 2006 @@ -252,6 +252,7 @@ return # skip the detailed failure reports altogether l = self.getitemoutcomepairs(Item.Failed) if l: + self.out.sep('_') for colitem, outcome in l: self.repr_failure(colitem, outcome) @@ -267,11 +268,6 @@ if ntraceback == traceback: ntraceback = ntraceback.cut(path=path) traceback = ntraceback.filter() - - # show the stdout/stderr log before the traceback - self.out.sep('_') - self.repr_out_err(item) - if not traceback: self.out.line("empty traceback from item %r" % (item,)) return @@ -302,7 +298,13 @@ self.out.line("[%s:%d]" %(entry.frame.code.path, entry.lineno+1)) self.repr_locals(entry) - if entry is not last: + # trailing info + if entry == last: + #if item: + # self.repr_failure_info(item, entry) + self.repr_out_err(item) + self.out.sep("_") + else: self.out.sep("_ ") if index == recursionindex: self.out.line("Recursion detected (same locals & position)") @@ -336,8 +338,13 @@ self.repr_source(source, ' ') self.repr_locals(entry) - if entry is not last: - self.out.sep("_ ") + # trailing info + if entry == last: + #if item: + # self.repr_failure_info(item, entry) + self.repr_out_err(item) + self.out.sep("_") + else: if index == recursionindex: self.out.line("Recursion detected (same locals & position)") self.out.sep("!") @@ -423,8 +430,6 @@ for name, obj in zip(['out', 'err'], parent.getouterr()): if obj: self.out.sep("- ", "%s: recorded std%s" % (parent.name, name)) - if obj.endswith('\n'): - obj = obj[:-1] # avoids an empty line in the common case self.out.line(obj) def repr_locals(self, entry): From guido at codespeak.net Tue Jun 6 00:16:29 2006 From: guido at codespeak.net (guido at codespeak.net) Date: Tue, 6 Jun 2006 00:16:29 +0200 (CEST) Subject: [py-svn] r28339 - py/dist/py/path/svn Message-ID: <20060605221629.A46091006F@code0.codespeak.net> Author: guido Date: Tue Jun 6 00:16:09 2006 New Revision: 28339 Modified: py/dist/py/path/svn/svncommon.py Log: Fixed bug where locale would be set wrongly, making chars get mangled. Now we only set the locale for dates/times. Modified: py/dist/py/path/svn/svncommon.py ============================================================================== --- py/dist/py/path/svn/svncommon.py (original) +++ py/dist/py/path/svn/svncommon.py Tue Jun 6 00:16:09 2006 @@ -264,5 +264,5 @@ def fixlocale(): if sys.platform != 'win32': - return 'LC_ALL=C ' + return 'LC_TIME=en_US ' return '' From arigo at codespeak.net Sun Jun 11 13:36:13 2006 From: arigo at codespeak.net (arigo at codespeak.net) Date: Sun, 11 Jun 2006 13:36:13 +0200 (CEST) Subject: [py-svn] r28665 - py/dist/py/test/terminal Message-ID: <20060611113613.52ED310063@code0.codespeak.net> Author: arigo Date: Sun Jun 11 13:36:12 2006 New Revision: 28665 Modified: py/dist/py/test/terminal/terminal.py Log: For module outcomes, use a helper repr_*() method similar to the repr_*() methods for single test outcomes. This allows hooking from custom conftests. Modified: py/dist/py/test/terminal/terminal.py ============================================================================== --- py/dist/py/test/terminal/terminal.py (original) +++ py/dist/py/test/terminal/terminal.py Sun Jun 11 13:36:12 2006 @@ -102,12 +102,9 @@ self.out.rewrite('\n%s\n' % (outcome.excinfo.exconly(),)) pdb.post_mortem(outcome.excinfo._excinfo[2]) if isinstance(colitem, py.test.collect.Module): - if isinstance(outcome, py.test.Item.Failed): - self.out.line(" - FAILED TO LOAD MODULE") - elif isinstance(outcome, py.test.Item.Skipped): - self.out.line(" - skipped") - elif not isinstance(outcome, (list, py.test.Item.Passed)): - self.out.line(" - ?") + resultstring = self.repr_progress_module_result(colitem, outcome) + if resultstring: + self.out.line(" - " + resultstring) if isinstance(colitem, py.test.Item): if self.config.option.verbose >= 1: resultstring = self.repr_progress_long_result(colitem, outcome) @@ -200,6 +197,14 @@ #raise TypeError, "not an Outcome instance: %r" % (outcome,) return 'UNKNOWN' + def repr_progress_module_result(self, item, outcome): + if isinstance(outcome, py.test.Item.Failed): + return "FAILED TO LOAD MODULE" + elif isinstance(outcome, py.test.Item.Skipped): + return "skipped" + elif not isinstance(outcome, (list, py.test.Item.Passed)): + return "?" + # -------------------- # summary information # -------------------- From ac at codespeak.net Mon Jun 12 17:08:57 2006 From: ac at codespeak.net (ac at codespeak.net) Date: Mon, 12 Jun 2006 17:08:57 +0200 (CEST) Subject: [py-svn] r28711 - in py/dist/py/code: . testing Message-ID: <20060612150857.B051210064@code0.codespeak.net> Author: ac Date: Mon Jun 12 17:08:56 2006 New Revision: 28711 Modified: py/dist/py/code/source.py py/dist/py/code/testing/test_source.py Log: (pedronis, arre) Fix deindent so that it correctly handles multiline strings. Modified: py/dist/py/code/source.py ============================================================================== --- py/dist/py/code/source.py (original) +++ py/dist/py/code/source.py Mon Jun 12 17:08:56 2006 @@ -1,6 +1,6 @@ from __future__ import generators import sys -import inspect +import inspect, tokenize import py cpy_compile = compile @@ -238,11 +238,11 @@ end = fullsource.getblockend(lineno) return fullsource[lineno:end+1] + def deindent(lines, offset=None): - # XXX maybe use the tokenizer to properly handle multiline - # strings etc.pp? if offset is None: for line in lines: + line = line.expandtabs() s = line.lstrip() if s: offset = len(line)-len(s) @@ -250,11 +250,30 @@ else: offset = 0 newlines = [] - for line in lines: - line = line.expandtabs() - s = line.lstrip() - if s and line[:offset].isspace(): - line = line[offset:] - newlines.append(line) - return newlines + def readline_generator(lines): + for line in lines: + yield line + '\n' + while True: + yield '' + + readline = readline_generator(lines).next + try: + for _, _, (sline, _), (eline, _), _ in tokenize.generate_tokens(readline): + if sline > len(lines): + break # End of input reached + if sline > len(newlines): + line = lines[sline - 1].expandtabs() + if line.lstrip() and line[:offset].isspace(): + line = line[offset:] # Deindent + newlines.append(line) + + for i in range(sline, eline): + # Don't deindent continuing lines of + # multiline tokens (i.e. multiline strings) + newlines.append(lines[i]) + except (IndentationError, tokenize.TokenError): + pass + # Add any lines we didn't see. E.g. if an exception was raised. + newlines.extend(lines[len(newlines):]) + return newlines Modified: py/dist/py/code/testing/test_source.py ============================================================================== --- py/dist/py/code/testing/test_source.py (original) +++ py/dist/py/code/testing/test_source.py Mon Jun 12 17:08:56 2006 @@ -228,3 +228,31 @@ assert str(py.code.Source(f)).strip() == 'def f():\n raise ValueError' assert str(py.code.Source(g)).strip() == 'def g(): pass' + +def test_getfuncsource_with_multine_string(): + def f(): + c = '''while True: + pass +''' + assert str(py.code.Source(f)).strip() == "def f():\n c = '''while True:\n pass\n'''" + + +def test_deindent(): + from py.__.code.source import deindent as deindent + assert deindent(['\tfoo', '\tbar', ]) == ['foo', 'bar'] + + def f(): + c = '''while True: + pass +''' + import inspect + lines = deindent(inspect.getsource(f).splitlines()) + assert lines == ["def f():", " c = '''while True:", " pass", "'''"] + + source = """ + def f(): + def g(): + pass + """ + lines = deindent(source.splitlines()) + assert lines == ['', 'def f():', ' def g():', ' pass', ' '] From hpk at codespeak.net Thu Jun 15 06:28:09 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 15 Jun 2006 06:28:09 +0200 (CEST) Subject: [py-svn] r28795 - py/dist/py/documentation Message-ID: <20060615042809.14CB91007A@code0.codespeak.net> Author: hpk Date: Thu Jun 15 06:28:07 2006 New Revision: 28795 Modified: py/dist/py/documentation/test.txt Log: fixing typo pointed out by Bruce Modified: py/dist/py/documentation/test.txt ============================================================================== --- py/dist/py/documentation/test.txt (original) +++ py/dist/py/documentation/test.txt Thu Jun 15 06:28:07 2006 @@ -66,7 +66,7 @@ *behind-the-scenes-magic* you may turn off the magic by providing the ``--nomagic`` option. -how to write assertions about execptions +how to write assertions about exceptions ---------------------------------------- In order to write assertions about exceptions, you use From arigo at codespeak.net Thu Jun 15 13:40:00 2006 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 15 Jun 2006 13:40:00 +0200 (CEST) Subject: [py-svn] r28807 - py/dist/py/misc Message-ID: <20060615114000.7393310077@code0.codespeak.net> Author: arigo Date: Thu Jun 15 13:39:59 2006 New Revision: 28807 Modified: py/dist/py/misc/error.py Log: An import order fix. So far I only saw it crash when playing with a CPython with explicitly modified dict orders, but I'm sure it would bite sooner or later. Modified: py/dist/py/misc/error.py ============================================================================== --- py/dist/py/misc/error.py (original) +++ py/dist/py/misc/error.py Thu Jun 15 13:39:59 2006 @@ -1,5 +1,6 @@ import py +import errno class Error(EnvironmentError): __module__ = 'py.error' @@ -18,10 +19,13 @@ ) _winerrnomap = { - 3: py.std.errno.ENOENT, - 267: py.std.errno.ENOTDIR, - 5: py.std.errno.EACCES, # anything better? + 3: errno.ENOENT, + 267: errno.ENOTDIR, + 5: errno.EACCES, # anything better? } +# note: 'py.std' may not be imported yet at all, because +# the 'error' module in this file is imported very early. +# This is dependent on dict order. ModuleType = type(py) From hpk at codespeak.net Thu Jun 15 18:17:51 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 15 Jun 2006 18:17:51 +0200 (CEST) Subject: [py-svn] r28838 - py/dist/py/documentation Message-ID: <20060615161751.A905D10034@code0.codespeak.net> Author: hpk Date: Thu Jun 15 18:17:50 2006 New Revision: 28838 Modified: py/dist/py/documentation/test.txt Log: fix anchor Modified: py/dist/py/documentation/test.txt ============================================================================== --- py/dist/py/documentation/test.txt (original) +++ py/dist/py/documentation/test.txt Thu Jun 15 18:17:50 2006 @@ -114,6 +114,8 @@ to get run, notably ``check(42)``, ``check(17)`` and ``check(49)`` of which the middle one will obviously fail. +.. _`selection by keyword`: + selecting tests by keyword -------------------------- @@ -147,8 +149,6 @@ and does not need to complete before your first test items are executed. -.. _`selection by keyword`: - no interference with cmdline utilities -------------------------------------- From arigo at codespeak.net Mon Jun 19 20:14:32 2006 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 19 Jun 2006 20:14:32 +0200 (CEST) Subject: [py-svn] r28962 - py/dist/py/test Message-ID: <20060619181432.DBE6C10063@code0.codespeak.net> Author: arigo Date: Mon Jun 19 20:14:32 2006 New Revision: 28962 Modified: py/dist/py/test/collect.py Log: Avoid using getattr() on self.obj. This avoids strange interaction with lazily-computed attributes (in our case, 'space' from PyPy's conftest). Modified: py/dist/py/test/collect.py ============================================================================== --- py/dist/py/test/collect.py (original) +++ py/dist/py/test/collect.py Mon Jun 19 20:14:32 2006 @@ -259,16 +259,24 @@ return name.startswith('Test') def buildname2items(self): - d = {} - for name in dir(self.obj): - obj = getattr(self.obj, name) - if self.classnamefilter(name) and isclass(obj): - d[name] = self.Class(name, parent=self) - elif self.funcnamefilter(name) and callable(obj): - if obj.func_code.co_flags & 32: # generator function - d[name] = self.Generator(name, parent=self) - else: - d[name] = self.Function(name, parent=self) + # NB. we avoid random getattrs and peek in the __dict__ instead + d = {} + dicts = [getattr(self.obj, '__dict__', {})] + for basecls in py.std.inspect.getmro(self.obj.__class__): + dicts.append(basecls.__dict__) + seen = {} + for dic in dicts: + for name, obj in dic.items(): + if name in seen: + continue + seen[name] = True + if self.classnamefilter(name) and isclass(obj): + d[name] = self.Class(name, parent=self) + elif self.funcnamefilter(name) and callable(obj): + if obj.func_code.co_flags & 32: # generator function + d[name] = self.Generator(name, parent=self) + else: + d[name] = self.Function(name, parent=self) return d class Module(PyCollectorMixin, FSCollector): From hpk at codespeak.net Thu Jun 22 15:22:01 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 22 Jun 2006 15:22:01 +0200 (CEST) Subject: [py-svn] r29140 - py/dist/py/code Message-ID: <20060622132201.C0B4410064@code0.codespeak.net> Author: hpk Date: Thu Jun 22 15:22:00 2006 New Revision: 29140 Modified: py/dist/py/code/source.py Log: shortcut for not tokenizing a whole file when there is no deindent needed. Modified: py/dist/py/code/source.py ============================================================================== --- py/dist/py/code/source.py (original) +++ py/dist/py/code/source.py Thu Jun 22 15:22:00 2006 @@ -249,6 +249,8 @@ break else: offset = 0 + if offset == 0: + return list(lines) newlines = [] def readline_generator(lines): for line in lines: From arigo at codespeak.net Thu Jun 29 10:48:12 2006 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 29 Jun 2006 10:48:12 +0200 (CEST) Subject: [py-svn] r29478 - in py/dist/py/code: . testing Message-ID: <20060629084812.4267710076@code0.codespeak.net> Author: arigo Date: Thu Jun 29 10:48:10 2006 New Revision: 29478 Modified: py/dist/py/code/source.py py/dist/py/code/testing/test_source.py Log: Trying to improve the heuristics of Source.getstatementrange(). This version seems to work in more cases (see tests that now give a reasonable answer instead of IndexError). It was prompted by a buggy behavior in one case (see new test). It is quite faster than the previous heuristics too (veeery slow tracebacks in PyPy should be solved). Modified: py/dist/py/code/source.py ============================================================================== --- py/dist/py/code/source.py (original) +++ py/dist/py/code/source.py Thu Jun 29 10:48:10 2006 @@ -100,34 +100,32 @@ statement region which containing the given lineno. """ # XXX there must be a better than these heuristic ways ... - # XXX there may even be better heuristics :-) - for end in range(lineno, len(self)): - trysource = self[lineno:end+1] - if trysource.isparseable(): - start = lineno - break - else: - end = lineno - for start in range(lineno, -1, -1): - trysource = self[start:end+1] - if trysource.isparseable(): - break + # XXX there may even be better heuristics :-) + if not (0 <= lineno < len(self)): + raise IndexError("lineno out of range") + + # 1. find the start of the statement + from codeop import compile_command + 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:') + trysource = '\n '.join(trylines) + # ^ space here + try: + compile_command(trysource) + except (SyntaxError, OverflowError, ValueError): + pass else: - # find the end - for end in range(lineno, len(self)): - trysource = self[:end+1] - if trysource.isparseable(): - break - else: - return None - # find the start - for start in range(end, -1, -1): - trysource = self[start:end+1] - if trysource.isparseable(): - break - if start <= lineno <= end: - return start, end + 1 - raise IndexError("could not find lineno statement at %d" % lineno) + break # got a valid or incomplete statement + + # 2. find the end of the statement + for end in range(lineno+1, len(self)+1): + trysource = self[start:end] + if trysource.isparseable(): + break + + return start, end def getblockend(self, lineno): # XXX Modified: py/dist/py/code/testing/test_source.py ============================================================================== --- py/dist/py/code/testing/test_source.py (original) +++ py/dist/py/code/testing/test_source.py Thu Jun 29 10:48:10 2006 @@ -156,13 +156,22 @@ assert source.getstatementrange(0) == (0, 7) assert source.getstatementrange(1) == (1, 5) assert source.getstatementrange(2) == (2, 3) - assert py.test.raises(IndexError, - "source.getstatementrange(3)") + assert source.getstatementrange(3) == (1, 5) assert source.getstatementrange(4) == (4, 5) - assert py.test.raises(IndexError, - "source.getstatementrange(5)") + assert source.getstatementrange(5) == (0, 7) assert source.getstatementrange(6) == (6, 7) - + + def test_getstatementrange_bug(self): + source = Source("""\ + try: + x = ( + y + + z) + except: + pass + """) + assert len(source) == 6 + assert source.getstatementrange(2) == (1, 4) def test_compile_and_getsource(self): co = self.source.compile()