From cfbolz at codespeak.net Wed Feb 1 20:31:29 2006 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Wed, 1 Feb 2006 20:31:29 +0100 (CET) Subject: [py-svn] r22930 - py/dist/py/bin Message-ID: <20060201193129.9121A1007F@code0.codespeak.net> Author: cfbolz Date: Wed Feb 1 20:31:28 2006 New Revision: 22930 Modified: py/dist/py/bin/py.lookup Log: added -i option to lookup, added proper optparser option parsing Modified: py/dist/py/bin/py.lookup ============================================================================== --- py/dist/py/bin/py.lookup (original) +++ py/dist/py/bin/py.lookup Wed Feb 1 20:31:28 2006 @@ -3,15 +3,29 @@ from _findpy import py import re -string = py.std.sys.argv[1] curdir = py.path.local() def rec(p): return p.check(dotfile=0) -for x in curdir.visit('*.py', rec): - s = x.read() - if s.find(string) != -1: - lines = x.readlines() - for i, line in enumerate(lines): - if line.find(string) != -1: - print "%s:%d: %s" %(x.relto(curdir), i+1, line.rstrip()) +optparse = py.compat.optparse + +parser = optparse.OptionParser() +parser.add_option("-i", "--ignore-case", action="store_true", dest="ignorecase", + help="ignore case distinctions") + +if __name__ == '__main__': + (options, args) = parser.parse_args() + string = args[0] + if options.ignorecase: + string = string.lower() + for x in curdir.visit('*.py', rec): + s = x.read() + if s.find(string) != -1: + lines = s.splitlines() + if options.ignorecase: + searchlines = s.lower().splitlines() + else: + searchlines = lines + for i, (line, searchline) in enumerate(zip(lines, searchlines)): + if searchline.find(string) != -1: + print "%s:%d: %s" %(x.relto(curdir), i+1, line.rstrip()) From cfbolz at codespeak.net Wed Feb 1 21:25:52 2006 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Wed, 1 Feb 2006 21:25:52 +0100 (CET) Subject: [py-svn] r22933 - py/dist/py/bin Message-ID: <20060201202552.AC04610081@code0.codespeak.net> Author: cfbolz Date: Wed Feb 1 21:25:51 2006 New Revision: 22933 Modified: py/dist/py/bin/py.lookup Log: umpf. where are the tests for this thing? Modified: py/dist/py/bin/py.lookup ============================================================================== --- py/dist/py/bin/py.lookup (original) +++ py/dist/py/bin/py.lookup Wed Feb 1 21:25:51 2006 @@ -20,6 +20,9 @@ string = string.lower() for x in curdir.visit('*.py', rec): s = x.read() + searchs = s + if options.ignorecase: + searchs = s.lower() if s.find(string) != -1: lines = s.splitlines() if options.ignorecase: From jan at codespeak.net Thu Feb 9 15:11:54 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Thu, 9 Feb 2006 15:11:54 +0100 (CET) Subject: [py-svn] r23178 - py/dist/py/documentation Message-ID: <20060209141154.CAE43100EA@code0.codespeak.net> Author: jan Date: Thu Feb 9 15:11:51 2006 New Revision: 23178 Added: py/dist/py/documentation/links.txt Log: collection of links to pylib related articles Added: py/dist/py/documentation/links.txt ============================================================================== --- (empty file) +++ py/dist/py/documentation/links.txt Thu Feb 9 15:11:51 2006 @@ -0,0 +1,33 @@ + +===== +Links +===== + +Some links to ongoing discussions and comments about pylib and technics/concepts pylib uses. + +* `Discussion `_ + about site-packages. That's why pylib autopath and py.__.misc.dynpkg are a good idea ;-) + + +* `Pyinotify `_ uses code from pypy autopath functions. + +* `Testing (WSGI) Applications with Paste `_ and py.test. "This has been written with py.test in mind." Paste uses py.test. + + +* `Agile Testing `_ by Grig Gheorghiu + + * `Slides from 'py library overview' presentation at SoCal Piggies meeting + `_ + + * `Python unit testing part 3: the py.test tool and library + `_ + + * `greenlets and py.xml + `_ + + * `Keyword-based logging with the py library + `_ + + + + From jan at codespeak.net Thu Feb 9 19:18:30 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Thu, 9 Feb 2006 19:18:30 +0100 (CET) Subject: [py-svn] r23181 - py/branch/setup/py/rest/testing Message-ID: <20060209181830.EFE6D100CD@code0.codespeak.net> Author: jan Date: Thu Feb 9 19:18:29 2006 New Revision: 23181 Modified: py/branch/setup/py/rest/testing/test_directive.py Log: py/misc/rest.process expects no svnwcs anymore Modified: py/branch/setup/py/rest/testing/test_directive.py ============================================================================== --- py/branch/setup/py/rest/testing/test_directive.py (original) +++ py/branch/setup/py/rest/testing/test_directive.py Thu Feb 9 19:18:29 2006 @@ -7,8 +7,7 @@ def test_graphviz_html(): directive.BackendStore("html") - #for reasons that elude me rest.process expects svnwcs??? - txt = py.path.svnwc(datadir.join("graphviz.txt")) + txt = datadir.join("graphviz.txt") html = txt.new(ext="html") png = datadir.join("example1.png") rest.process(txt) From jan at codespeak.net Thu Feb 9 20:26:51 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Thu, 9 Feb 2006 20:26:51 +0100 (CET) Subject: [py-svn] r23182 - py/branch/setup/py/misc/testing Message-ID: <20060209192651.822F6100CD@code0.codespeak.net> Author: jan Date: Thu Feb 9 20:26:48 2006 New Revision: 23182 Modified: py/branch/setup/py/misc/testing/test_initpkg.py Log: (svn) 'unkonwn' == (svnversion) 'exported' Modified: py/branch/setup/py/misc/testing/test_initpkg.py ============================================================================== --- py/branch/setup/py/misc/testing/test_initpkg.py (original) +++ py/branch/setup/py/misc/testing/test_initpkg.py Thu Feb 9 20:26:48 2006 @@ -80,6 +80,9 @@ except py.error.ENOENT: py.test.skip("cannot test svnversion, 'svnversion' binary not found") v = svnversion.sysexec(py.path.local(py.__file__).dirpath()) + # svnversion returns "exported" if the version is 'unknown' + if v.startswith('exported'): + v='unknown' assert v.startswith(str(d)) # the following test should abasically work in the future From jan at codespeak.net Thu Feb 9 21:35:56 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Thu, 9 Feb 2006 21:35:56 +0100 (CET) Subject: [py-svn] r23185 - py/branch/setup Message-ID: <20060209203556.0B7CF100CD@code0.codespeak.net> Author: jan Date: Thu Feb 9 21:35:55 2006 New Revision: 23185 Modified: py/branch/setup/finddata.py Log: force addition of all test files and directories Modified: py/branch/setup/finddata.py ============================================================================== --- py/branch/setup/finddata.py (original) +++ py/branch/setup/finddata.py Thu Feb 9 21:35:55 2006 @@ -9,7 +9,7 @@ # Provided as an attribute, so you can append to these instead # of replicating them: -standard_exclude = ('*.py', '*.pyc', '*~', '.*', '*.bak') +standard_exclude = ('*.pyc', '*~', '.*', '*.bak') standard_exclude_directories = ('.*', 'CVS', '_darcs', './build', './dist', 'EGG-INFO', '*.egg-info') From jan at codespeak.net Sat Feb 11 09:20:33 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Sat, 11 Feb 2006 09:20:33 +0100 (CET) Subject: [py-svn] r23227 - py/dist/py/misc Message-ID: <20060211082033.7ED60100B0@code0.codespeak.net> Author: jan Date: Sat Feb 11 09:20:30 2006 New Revision: 23227 Modified: py/dist/py/misc/dynpkg.py Log: exclude temp directories Modified: py/dist/py/misc/dynpkg.py ============================================================================== --- py/dist/py/misc/dynpkg.py (original) +++ py/dist/py/misc/dynpkg.py Sat Feb 11 09:20:30 2006 @@ -10,6 +10,8 @@ debug=py.log.STDOUT, command=None) # py.log.STDOUT) +from distutils import util + class DistPython: def __init__(self, location=None, python=None): if python is None: @@ -18,6 +20,7 @@ if location is None: location = py.path.local() self.location = location + self.plat_specifier = '.%s-%s' % (util.get_platform(), sys.version[0:3]) def clean(self): out = self._exec("clean -a") @@ -38,7 +41,7 @@ old.chdir() return out - def get_package_path(self, pkgname): + def get_package_path(self, pkgname): pkg = self._get_package_path(pkgname) if pkg is None: #self.clean() @@ -52,14 +55,15 @@ #assert major >=2 and minor in (3,4,5) suffix = "%s.%s" %(major, minor) location = self.location - base = location.join('build') - if base.check(dir=1): - # XXX check if we need to rebuild - for pkg in base.visit(lambda x: x.check(dir=1)): - if pkg.basename == pkgname: - if pkg.dirpath().basename.endswith(suffix) or \ - pkg.dirpath().basename == 'lib': - return pkg + for base in [location.join('build', 'lib'), + location.join('build', 'lib'+ self.plat_specifier)]: + if base.check(dir=1): + for pkg in base.visit(lambda x: x.check(dir=1)): + if pkg.basename == pkgname: + # + if pkg.dirpath().basename == 'lib'+ self.plat_specifier or \ + pkg.dirpath().basename == 'lib': + return pkg def setpkg(finalpkgname, distdir): assert distdir.check(dir=1) From jan at codespeak.net Sat Feb 11 17:34:13 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Sat, 11 Feb 2006 17:34:13 +0100 (CET) Subject: [py-svn] r23231 - py/dist/py/misc Message-ID: <20060211163413.448A1100B4@code0.codespeak.net> Author: jan Date: Sat Feb 11 17:34:11 2006 New Revision: 23231 Modified: py/dist/py/misc/dynpkg.py Log: use docutils to get the right build/lib... directory Modified: py/dist/py/misc/dynpkg.py ============================================================================== --- py/dist/py/misc/dynpkg.py (original) +++ py/dist/py/misc/dynpkg.py Sat Feb 11 17:34:11 2006 @@ -10,7 +10,7 @@ debug=py.log.STDOUT, command=None) # py.log.STDOUT) -from distutils import util +import distutils.core class DistPython: def __init__(self, location=None, python=None): @@ -20,7 +20,6 @@ if location is None: location = py.path.local() self.location = location - self.plat_specifier = '.%s-%s' % (util.get_platform(), sys.version[0:3]) def clean(self): out = self._exec("clean -a") @@ -42,28 +41,24 @@ return out def get_package_path(self, pkgname): - pkg = self._get_package_path(pkgname) - if pkg is None: + path = self._get_package_path(pkgname) + if not path.check(exists=True): #self.clean() self.build() - pkg = self._get_package_path(pkgname) - assert pkg is not None - return pkg + path = self._get_package_path(pkgname) + print path + assert path.check(exists=1) + return path def _get_package_path(self, pkgname): - major, minor = py.std.sys.version_info[:2] - #assert major >=2 and minor in (3,4,5) - suffix = "%s.%s" %(major, minor) - location = self.location - for base in [location.join('build', 'lib'), - location.join('build', 'lib'+ self.plat_specifier)]: - if base.check(dir=1): - for pkg in base.visit(lambda x: x.check(dir=1)): - if pkg.basename == pkgname: - # - if pkg.dirpath().basename == 'lib'+ self.plat_specifier or \ - pkg.dirpath().basename == 'lib': - return pkg + # process all config files and commandline args + dist = distutils.core.run_setup(self.location.join('setup.py').strpath, + script_args=['-q', 'build'], + stop_after='commandline') + create_if_necessary = True + build_command = dist.get_command_obj('build', create_if_necessary) + build_command.ensure_finalized() + return self.location.join(build_command.build_lib, pkgname) def setpkg(finalpkgname, distdir): assert distdir.check(dir=1) From hpk at codespeak.net Sat Feb 11 21:25:25 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 11 Feb 2006 21:25:25 +0100 (CET) Subject: [py-svn] r23238 - py/dist/py/misc Message-ID: <20060211202525.5C997100C8@code0.codespeak.net> Author: hpk Date: Sat Feb 11 21:25:21 2006 New Revision: 23238 Added: py/dist/py/misc/svnlook.py Log: start a small implementation level helper for svnlook'ing into a repo Added: py/dist/py/misc/svnlook.py ============================================================================== --- (empty file) +++ py/dist/py/misc/svnlook.py Sat Feb 11 21:25:21 2006 @@ -0,0 +1,14 @@ + +import py + +def changed(repo, revision): + out = py.process.cmdexec("svnlook changed -r %s %s" %(revision, repo)) + l = [] + for line in out.strip().split('\n'): + action = line[:4] + path = line[4:].strip() + l.append((action, path)) + return l + + + From hpk at codespeak.net Sun Feb 12 11:38:39 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sun, 12 Feb 2006 11:38:39 +0100 (CET) Subject: [py-svn] r23251 - in py/dist/py/path/svn: . testing Message-ID: <20060212103839.DB1F0100EA@code0.codespeak.net> Author: hpk Date: Sun Feb 12 11:38:37 2006 New Revision: 23251 Modified: py/dist/py/path/svn/testing/test_test_repo.py py/dist/py/path/svn/wccommand.py Log: let WC.commit() calls return the revision number of the commit Modified: py/dist/py/path/svn/testing/test_test_repo.py ============================================================================== --- py/dist/py/path/svn/testing/test_test_repo.py (original) +++ py/dist/py/path/svn/testing/test_test_repo.py Sun Feb 12 11:38:37 2006 @@ -14,5 +14,6 @@ p = self.wc.join("a_file") p.write("test file") p.add() - self.wc.commit("some test") + rev = self.wc.commit("some test") assert p.info().rev == 1 + assert rev == 1 Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Sun Feb 12 11:38:37 2006 @@ -162,6 +162,8 @@ def rename(self, target): py.process.cmdexec("svn move --force %s %s" %(str(self), str(target))) + rex_status = re.compile(r'\s+(\d+|-)\s+(\S+)\s+(\S+)\s+(.*)') + def status(self, updates=0, rec=0, externals=0): """ return (collective) Status object for this file. """ # http://svnbook.red-bean.com/book.html#svn-ch-3-sect-4.3.1 @@ -190,7 +192,6 @@ out = self._svn('status -v %s %s %s' % (updates, rec, externals)) rootstatus = WCStatus(self) - rex = re.compile(r'\s+(\d+|-)\s+(\S+)\s+(\S+)\s+(.*)') for line in out.split('\n'): if not line.strip(): continue @@ -218,7 +219,7 @@ #elif c0 in '~!' or c4 == 'S': # raise NotImplementedError("received flag %r" % c0) - m = rex.match(rest) + m = self.rex_status.match(rest) if not m: if c7 == '*': fn = rest.strip() @@ -275,16 +276,18 @@ out = self._svn('diff -r %d' % rev) return out + rex_commit = re.compile(r'.*Committed revision (\d+)\.$', re.DOTALL) def commit(self, message=None): if message: - self._svn('commit -m %r' % message) + out = self._svn('commit -m %r' % message) else: - os.system(svncommon.fixlocale()+ - 'svn commit %r' % (self.strpath)) + out = self._svn('commit') try: del cache.info[self] except KeyError: pass + m = self.rex_commit.match(out) + return int(m.group(1)) def propset(self, propname, value, *args): d = py.path.local.mkdtemp() From hpk at codespeak.net Sun Feb 12 19:45:41 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sun, 12 Feb 2006 19:45:41 +0100 (CET) Subject: [py-svn] r23259 - py/dist/py/path/svn Message-ID: <20060212184541.7B6D71009B@code0.codespeak.net> Author: hpk Date: Sun Feb 12 19:45:40 2006 New Revision: 23259 Modified: py/dist/py/path/svn/wccommand.py Log: always do a non-interactive commit Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Sun Feb 12 19:45:40 2006 @@ -277,11 +277,8 @@ return out rex_commit = re.compile(r'.*Committed revision (\d+)\.$', re.DOTALL) - def commit(self, message=None): - if message: - out = self._svn('commit -m %r' % message) - else: - out = self._svn('commit') + def commit(self, message=""): + out = self._svn('commit -m %r' % message) try: del cache.info[self] except KeyError: From hpk at codespeak.net Sun Feb 12 23:21:54 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sun, 12 Feb 2006 23:21:54 +0100 (CET) Subject: [py-svn] r23262 - in py/dist/py/path/svn: . testing Message-ID: <20060212222154.26B8B1009F@code0.codespeak.net> Author: hpk Date: Sun Feb 12 23:21:51 2006 New Revision: 23262 Modified: py/dist/py/path/svn/testing/test_test_repo.py py/dist/py/path/svn/wccommand.py Log: commit() returns None if there was nothing to commit and the revision number of the commit otherwise. Modified: py/dist/py/path/svn/testing/test_test_repo.py ============================================================================== --- py/dist/py/path/svn/testing/test_test_repo.py (original) +++ py/dist/py/path/svn/testing/test_test_repo.py Sun Feb 12 23:21:51 2006 @@ -10,10 +10,13 @@ self.wc.checkout(self.repo) assert len(self.wc.listdir()) == 0 - def test_checkin(self): + def test_commit(self): p = self.wc.join("a_file") p.write("test file") p.add() rev = self.wc.commit("some test") assert p.info().rev == 1 assert rev == 1 + rev = self.wc.commit() + assert rev is None + Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Sun Feb 12 23:21:51 2006 @@ -278,13 +278,17 @@ rex_commit = re.compile(r'.*Committed revision (\d+)\.$', re.DOTALL) def commit(self, message=""): + """commit() returns None if there was nothing to commit + and the revision number of the commit otherwise. + """ out = self._svn('commit -m %r' % message) try: del cache.info[self] except KeyError: pass - m = self.rex_commit.match(out) - return int(m.group(1)) + if out: + m = self.rex_commit.match(out) + return int(m.group(1)) def propset(self, propname, value, *args): d = py.path.local.mkdtemp() From arigo at codespeak.net Mon Feb 13 00:59:13 2006 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 13 Feb 2006 00:59:13 +0100 (CET) Subject: [py-svn] r23264 - py/dist/py/test/terminal Message-ID: <20060212235913.DC9941009F@code0.codespeak.net> Author: arigo Date: Mon Feb 13 00:59:11 2006 New Revision: 23264 Modified: py/dist/py/test/terminal/terminal.py Log: Report skipped and other special outcomes of Modules (if any). This is meant for the case where the module calls py.test.skip() when it is imported. Now we get e.g.: pypy/objspace/std/test/test_complexobject - skipped Modified: py/dist/py/test/terminal/terminal.py ============================================================================== --- py/dist/py/test/terminal/terminal.py (original) +++ py/dist/py/test/terminal/terminal.py Mon Feb 13 00:59:11 2006 @@ -100,9 +100,13 @@ import pdb self.out.rewrite('\n%s\n' % (outcome.excinfo.exconly(),)) pdb.post_mortem(outcome.excinfo._excinfo[2]) - if (isinstance(outcome, py.test.Item.Failed) and - isinstance(colitem, py.test.collect.Module)): - self.out.line(" FAILED TO LOAD MODULE") + 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(" - ?") if isinstance(colitem, py.test.Item): if self.config.option.verbose >= 1: resultstring = self.repr_progress_long_result(colitem, outcome) From hpk at codespeak.net Mon Feb 13 16:01:56 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 13 Feb 2006 16:01:56 +0100 (CET) Subject: [py-svn] r23283 - py/dist/py/path/svn Message-ID: <20060213150156.CA8A01009F@code0.codespeak.net> Author: hpk Date: Mon Feb 13 16:01:55 2006 New Revision: 23283 Modified: py/dist/py/path/svn/wccommand.py Log: i have no clue when this comment was inserted but i hope it's correct :) Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Mon Feb 13 16:01:55 2006 @@ -173,6 +173,7 @@ raise ValueError("XXX cannot perform status() " "on external items yet") else: + #1.2 supports: externals = '--ignore-externals' externals = '' if rec: rec= '' From hpk at codespeak.net Mon Feb 13 19:58:24 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 13 Feb 2006 19:58:24 +0100 (CET) Subject: [py-svn] r23294 - in py/dist/py/misc/testing: . data Message-ID: <20060213185824.1FB261009A@code0.codespeak.net> Author: hpk Date: Mon Feb 13 19:58:22 2006 New Revision: 23294 Added: py/dist/py/misc/testing/data/ py/dist/py/misc/testing/data/svnlookrepo.dump py/dist/py/misc/testing/test_svnlook.py Log: svnlook now returns ChangeItems offering some more fine grained info on changes. Added: py/dist/py/misc/testing/data/svnlookrepo.dump ============================================================================== --- (empty file) +++ py/dist/py/misc/testing/data/svnlookrepo.dump Mon Feb 13 19:58:22 2006 @@ -0,0 +1,160 @@ +SVN-fs-dump-format-version: 2 + +UUID: 9cb23565-b10c-0410-b2e2-dde77f08022e + +Revision-number: 0 +Prop-content-length: 56 +Content-length: 56 + +K 8 +svn:date +V 27 +2006-02-13T18:39:13.605561Z +PROPS-END + +Revision-number: 1 +Prop-content-length: 111 +Content-length: 111 + +K 7 +svn:log +V 13 +A testdir + +K 10 +svn:author +V 3 +hpk +K 8 +svn:date +V 27 +2006-02-13T18:39:27.723346Z +PROPS-END + +Node-path: testdir +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Revision-number: 2 +Prop-content-length: 111 +Content-length: 111 + +K 7 +svn:log +V 13 +_M testdir + +K 10 +svn:author +V 3 +hpk +K 8 +svn:date +V 27 +2006-02-13T18:39:48.595729Z +PROPS-END + +Node-path: testdir +Node-kind: dir +Node-action: change +Prop-content-length: 28 +Content-length: 28 + +K 4 +key1 +V 4 +val2 +PROPS-END + + +Revision-number: 3 +Prop-content-length: 113 +Content-length: 113 + +K 7 +svn:log +V 15 +AM testdir2 + + +K 10 +svn:author +V 3 +hpk +K 8 +svn:date +V 27 +2006-02-13T18:40:53.307540Z +PROPS-END + +Node-path: testdir2 +Node-kind: dir +Node-action: add +Prop-content-length: 28 +Content-length: 28 + +K 4 +key2 +V 4 +val2 +PROPS-END + + +Revision-number: 4 +Prop-content-length: 113 +Content-length: 113 + +K 7 +svn:log +V 15 +D testdir2 + + +K 10 +svn:author +V 3 +hpk +K 8 +svn:date +V 27 +2006-02-13T18:41:07.188024Z +PROPS-END + +Node-path: testdir2 +Node-action: delete + + +Revision-number: 5 +Prop-content-length: 112 +Content-length: 112 + +K 7 +svn:log +V 14 +_M testdir + + +K 10 +svn:author +V 3 +hpk +K 8 +svn:date +V 27 +2006-02-13T18:42:03.179177Z +PROPS-END + +Node-path: testdir +Node-kind: dir +Node-action: change +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + Added: py/dist/py/misc/testing/test_svnlook.py ============================================================================== --- (empty file) +++ py/dist/py/misc/testing/test_svnlook.py Mon Feb 13 19:58:22 2006 @@ -0,0 +1,46 @@ + +import py +from py.__.misc import svnlook +data = py.magic.autopath().dirpath('data') + +def test_svnlook(): + tempdir = py.test.ensuretemp("svnlook") + repo = tempdir.join("repo") + py.process.cmdexec("svnadmin create --fs-type fsfs %s" % repo) + py.process.cmdexec("svnadmin load %s <%s" %(repo, + data.join("svnlookrepo.dump"))) + + for item in svnlook.changed(repo, 1): + assert item.added + assert not item.modified + assert not item.propchanged + assert not item.deleted + assert item.path == "testdir/" + + for item in svnlook.changed(repo, 2): + assert not item.added + assert not item.modified + assert item.propchanged + assert not item.deleted + assert item.path == "testdir/" + + for item in svnlook.changed(repo, 3): + assert item.added + assert not item.modified + assert not item.propchanged + assert not item.deleted + assert item.path == "testdir2/" + + for item in svnlook.changed(repo, 4): + assert not item.added + assert not item.modified + assert not item.propchanged + assert item.deleted + assert item.path == "testdir2/" + + for item in svnlook.changed(repo, 5): + assert not item.added + assert not item.modified + assert item.propchanged + assert not item.deleted + assert item.path == "testdir/" From hpk at codespeak.net Mon Feb 13 19:58:34 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 13 Feb 2006 19:58:34 +0100 (CET) Subject: [py-svn] r23295 - py/dist/py/misc Message-ID: <20060213185834.1D5E71009B@code0.codespeak.net> Author: hpk Date: Mon Feb 13 19:58:33 2006 New Revision: 23295 Modified: py/dist/py/misc/svnlook.py Log: actually commit the impl :) Modified: py/dist/py/misc/svnlook.py ============================================================================== --- py/dist/py/misc/svnlook.py (original) +++ py/dist/py/misc/svnlook.py Mon Feb 13 19:58:33 2006 @@ -1,13 +1,23 @@ import py +class ChangeItem: + def __init__(self, line): + self.action = action = line[:4] + self.path = line[4:].strip() + self.added = action[0] == "A" + self.modified = action[0] == "M" + self.propchanged = action[1] == "U" + self.deleted = action[0] == "D" + + def __repr__(self): + return "" %(self.action + self.path) + def changed(repo, revision): out = py.process.cmdexec("svnlook changed -r %s %s" %(revision, repo)) l = [] for line in out.strip().split('\n'): - action = line[:4] - path = line[4:].strip() - l.append((action, path)) + l.append(ChangeItem(line)) return l From hpk at codespeak.net Mon Feb 13 22:26:39 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 13 Feb 2006 22:26:39 +0100 (CET) Subject: [py-svn] r23297 - in py/dist/py/misc: . testing Message-ID: <20060213212639.360C910097@code0.codespeak.net> Author: hpk Date: Mon Feb 13 22:26:36 2006 New Revision: 23297 Modified: py/dist/py/misc/svnlook.py py/dist/py/misc/testing/test_svnlook.py Log: items now carry a repo, revisions and svnurl() method Modified: py/dist/py/misc/svnlook.py ============================================================================== --- py/dist/py/misc/svnlook.py (original) +++ py/dist/py/misc/svnlook.py Mon Feb 13 22:26:36 2006 @@ -2,7 +2,9 @@ import py class ChangeItem: - def __init__(self, line): + def __init__(self, repo, revision, line): + self.repo = repo + self.revision = revision self.action = action = line[:4] self.path = line[4:].strip() self.added = action[0] == "A" @@ -10,6 +12,9 @@ self.propchanged = action[1] == "U" self.deleted = action[0] == "D" + def svnurl(self): + return py.path.svnurl("file://%s/%s" %(self.repo, self.path), self.revision) + def __repr__(self): return "" %(self.action + self.path) @@ -17,7 +22,7 @@ out = py.process.cmdexec("svnlook changed -r %s %s" %(revision, repo)) l = [] for line in out.strip().split('\n'): - l.append(ChangeItem(line)) + l.append(ChangeItem(repo, revision, line)) return l Modified: py/dist/py/misc/testing/test_svnlook.py ============================================================================== --- py/dist/py/misc/testing/test_svnlook.py (original) +++ py/dist/py/misc/testing/test_svnlook.py Mon Feb 13 22:26:36 2006 @@ -11,6 +11,9 @@ data.join("svnlookrepo.dump"))) for item in svnlook.changed(repo, 1): + svnurl = item.svnurl() + assert item.revision == 1 + assert (svnurl.strpath + "/") == "file://%s/%s" %(repo, item.path) assert item.added assert not item.modified assert not item.propchanged @@ -18,6 +21,7 @@ assert item.path == "testdir/" for item in svnlook.changed(repo, 2): + assert item.revision == 2 assert not item.added assert not item.modified assert item.propchanged @@ -25,6 +29,7 @@ assert item.path == "testdir/" for item in svnlook.changed(repo, 3): + assert item.revision == 3 assert item.added assert not item.modified assert not item.propchanged @@ -32,6 +37,7 @@ assert item.path == "testdir2/" for item in svnlook.changed(repo, 4): + assert item.revision == 4 assert not item.added assert not item.modified assert not item.propchanged @@ -39,6 +45,7 @@ assert item.path == "testdir2/" for item in svnlook.changed(repo, 5): + assert item.revision == 5 assert not item.added assert not item.modified assert item.propchanged From hpk at codespeak.net Tue Feb 14 00:55:16 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Tue, 14 Feb 2006 00:55:16 +0100 (CET) Subject: [py-svn] r23304 - py/dist/py/misc Message-ID: <20060213235516.1763110097@code0.codespeak.net> Author: hpk Date: Tue Feb 14 00:55:15 2006 New Revision: 23304 Modified: py/dist/py/misc/dynpkg.py Log: bailing out Jan's patch of using distutils.* to determine the library path - it is not reliable (we had failures while starting mailwitness daemons) this is a clean bail out of revision 23231 let's worry about this later. Modified: py/dist/py/misc/dynpkg.py ============================================================================== --- py/dist/py/misc/dynpkg.py (original) +++ py/dist/py/misc/dynpkg.py Tue Feb 14 00:55:15 2006 @@ -10,7 +10,7 @@ debug=py.log.STDOUT, command=None) # py.log.STDOUT) -import distutils.core +from distutils import util class DistPython: def __init__(self, location=None, python=None): @@ -20,6 +20,7 @@ if location is None: location = py.path.local() self.location = location + self.plat_specifier = '.%s-%s' % (util.get_platform(), sys.version[0:3]) def clean(self): out = self._exec("clean -a") @@ -41,24 +42,28 @@ return out def get_package_path(self, pkgname): - path = self._get_package_path(pkgname) - if not path.check(exists=True): + pkg = self._get_package_path(pkgname) + if pkg is None: #self.clean() self.build() - path = self._get_package_path(pkgname) - print path - assert path.check(exists=1) - return path + pkg = self._get_package_path(pkgname) + assert pkg is not None + return pkg def _get_package_path(self, pkgname): - # process all config files and commandline args - dist = distutils.core.run_setup(self.location.join('setup.py').strpath, - script_args=['-q', 'build'], - stop_after='commandline') - create_if_necessary = True - build_command = dist.get_command_obj('build', create_if_necessary) - build_command.ensure_finalized() - return self.location.join(build_command.build_lib, pkgname) + major, minor = py.std.sys.version_info[:2] + #assert major >=2 and minor in (3,4,5) + suffix = "%s.%s" %(major, minor) + location = self.location + for base in [location.join('build', 'lib'), + location.join('build', 'lib'+ self.plat_specifier)]: + if base.check(dir=1): + for pkg in base.visit(lambda x: x.check(dir=1)): + if pkg.basename == pkgname: + # + if pkg.dirpath().basename == 'lib'+ self.plat_specifier or \ + pkg.dirpath().basename == 'lib': + return pkg def setpkg(finalpkgname, distdir): assert distdir.check(dir=1) From hpk at codespeak.net Tue Feb 14 02:07:12 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Tue, 14 Feb 2006 02:07:12 +0100 (CET) Subject: [py-svn] r23308 - py/dist/py/path/svn Message-ID: <20060214010712.96E9210097@code0.codespeak.net> Author: hpk Date: Tue Feb 14 02:07:11 2006 New Revision: 23308 Modified: py/dist/py/path/svn/wccommand.py Log: fixing checkouts from urls containing a "@" (too tired to do this on a grand scale ...) Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Tue Feb 14 02:07:11 2006 @@ -89,14 +89,15 @@ """ switch to given URL. """ self._svn('switch', url) - def checkout(self, url=None, rev = None): + def checkout(self, url=None, rev=None): """ checkout from url to local wcpath. """ if url is None: url = self.url if rev is None or rev == -1: - self._svn('co', url) + url += "@HEAD" else: - self._svn('co -r %s' % rev, url) + url += "@%d" % self.rev + self._svn('co', url) def update(self, rev = 'HEAD'): """ update working copy item to given revision. (None -> HEAD). """ From hpk at codespeak.net Tue Feb 14 13:07:09 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Tue, 14 Feb 2006 13:07:09 +0100 (CET) Subject: [py-svn] r23317 - py/dist/py/misc Message-ID: <20060214120709.49764100A2@code0.codespeak.net> Author: hpk Date: Tue Feb 14 13:07:09 2006 New Revision: 23317 Modified: py/dist/py/misc/svnlook.py Log: make sure we get an int as a revision Modified: py/dist/py/misc/svnlook.py ============================================================================== --- py/dist/py/misc/svnlook.py (original) +++ py/dist/py/misc/svnlook.py Tue Feb 14 13:07:09 2006 @@ -4,7 +4,7 @@ class ChangeItem: def __init__(self, repo, revision, line): self.repo = repo - self.revision = revision + self.revision = int(revision) self.action = action = line[:4] self.path = line[4:].strip() self.added = action[0] == "A" From hpk at codespeak.net Wed Feb 15 10:35:32 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 15 Feb 2006 10:35:32 +0100 (CET) Subject: [py-svn] r23355 - py/dist/py/misc Message-ID: <20060215093532.8E8B7100BD@code0.codespeak.net> Author: hpk Date: Wed Feb 15 10:35:31 2006 New Revision: 23355 Modified: py/dist/py/misc/svnlook.py Log: make the repo attribute a path object Modified: py/dist/py/misc/svnlook.py ============================================================================== --- py/dist/py/misc/svnlook.py (original) +++ py/dist/py/misc/svnlook.py Wed Feb 15 10:35:31 2006 @@ -3,7 +3,7 @@ class ChangeItem: def __init__(self, repo, revision, line): - self.repo = repo + self.repo = py.path.local(repo) self.revision = int(revision) self.action = action = line[:4] self.path = line[4:].strip() From hpk at codespeak.net Wed Feb 15 20:25:26 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 15 Feb 2006 20:25:26 +0100 (CET) Subject: [py-svn] r23377 - py/dist/py/execnet/testing Message-ID: <20060215192526.8544A100BE@code0.codespeak.net> Author: hpk Date: Wed Feb 15 20:25:25 2006 New Revision: 23377 Modified: py/dist/py/execnet/testing/test_gateway.py Log: test that Popen()ed gateway inherit the working directory and stay with it although it's slightly implicit in the popen-notion already. Modified: py/dist/py/execnet/testing/test_gateway.py ============================================================================== --- py/dist/py/execnet/testing/test_gateway.py (original) +++ py/dist/py/execnet/testing/test_gateway.py Wed Feb 15 20:25:25 2006 @@ -308,8 +308,18 @@ # x = reply.get(timeout=1.0) # assert x == 17 -class TestBasicPopenGateway(PopenGatewayTestSetup, BasicRemoteExecution): +class TestPopenGateway(PopenGatewayTestSetup, BasicRemoteExecution): #disabled = True + def test_chdir_separation(self): + old = py.test.ensuretemp('chdirtest').chdir() + try: + gw = py.execnet.PopenGateway() + finally: + waschangedir = old.chdir() + c = gw.remote_exec("import os ; channel.send(os.getcwd())") + x = c.receive() + assert x == str(waschangedir) + def test_many_popen(self): num = 4 l = [] From jan at codespeak.net Thu Feb 16 19:25:46 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Thu, 16 Feb 2006 19:25:46 +0100 (CET) Subject: [py-svn] r23423 - in py/dist/py: code code/testing test/terminal test/testing test/testing/data Message-ID: <20060216182546.5C64B10095@code0.codespeak.net> Author: jan Date: Thu Feb 16 19:25:42 2006 New Revision: 23423 Added: py/dist/py/code/safe_repr.py py/dist/py/code/testing/test_safe_repr.py py/dist/py/test/testing/data/brokenrepr.py Modified: py/dist/py/code/frame.py py/dist/py/test/terminal/terminal.py py/dist/py/test/testing/test_session.py Log: integrated a patch from Tom Harris Now py.test uses py.__.code.safe_repr and catches any exception from a call to __repr__ of a local object and generates a default representation. py.__.code.safe_repr produces object representations with limits on the size of the resulting strings, the failure explanation may now be shorter. safe_repr uses the module repr (python stdlib). Modified: py/dist/py/code/frame.py ============================================================================== --- py/dist/py/code/frame.py (original) +++ py/dist/py/code/frame.py Thu Feb 16 19:25:42 2006 @@ -1,5 +1,5 @@ import py - +import py.__.code.safe_repr class Frame(object): """Wrapper around a Python frame holding f_locals and f_globals @@ -27,7 +27,7 @@ exec code in self.f_globals, f_locals def repr(self, object): - return repr(object) + return py.__.code.safe_repr._repr(object) def is_true(self, object): return object Added: py/dist/py/code/safe_repr.py ============================================================================== --- (empty file) +++ py/dist/py/code/safe_repr.py Thu Feb 16 19:25:42 2006 @@ -0,0 +1,63 @@ +"""Defines a safe repr function. This will always return a string of "reasonable" length +no matter what the object does in it's own repr function. Let's examine what can go wrong +in an arbitrary repr function. +The default repr will return something like (on Win32 anyway): +. Well behaved user-defined repr() methods will do similar. +The usual expectation is that repr will return a single line string. + +1. However, the repr method can raise an exception of an arbitrary type. + +Also, the return value may not be as expected: + 2. The return value may not be a string! + 3. The return value may not be a single line string, it may contain line breaks. + 4. The method may enter a loop and never return. + 5. The return value may be enormous, eg range(100000) + + The standard library has a nice implementation in the repr module that will do the job, + but the exception + handling is silent, so the the output contains no clue that repr() call raised an + exception. I would like to be told if repr raises an exception, it's a serious error, so + a sublass of repr overrides the method that does repr for class instances.""" + + +import repr +import __builtin__ + + +class SafeRepr(repr.Repr): + def __init__(self, *args, **kwargs): + repr.Repr.__init__(self, *args, **kwargs) + # Do we need a commandline switch for this? + self.maxstring = 240 # 3 * 80 chars + self.maxother = 160 # 2 * 80 chars + def repr_instance(self, x, level): + try: + # Try the vanilla repr and make sure that the result is a string + s = str(__builtin__.repr(x)) + except (KeyboardInterrupt, MemoryError, SystemExit): + raise + except Exception ,e: + try: + exc_name = e.__class__.__name__ + except: + exc_name = 'unknown' + try: + exc_info = str(e) + except: + exc_info = 'unknown' + return '<[%s("%s") raised in repr()] %s object at 0x%x>' % \ + (exc_name, exc_info, x.__class__.__name__, id(x)) + except: + try: + name = x.__class__.__name__ + except: + name = 'unknown' + return '<[unknown exception raised in repr()] %s object at 0x%x>' % \ + (name, id(x)) + if len(s) > self.maxstring: + i = max(0, (self.maxstring-3)//2) + j = max(0, self.maxstring-3-i) + s = s[:i] + '...' + s[len(s)-j:] + return s + +_repr = SafeRepr().repr Added: py/dist/py/code/testing/test_safe_repr.py ============================================================================== --- (empty file) +++ py/dist/py/code/testing/test_safe_repr.py Thu Feb 16 19:25:42 2006 @@ -0,0 +1,34 @@ + +import py +from py.__.code import safe_repr + +def test_simple_repr(): + assert safe_repr._repr(1) == '1' + assert safe_repr._repr(None) == 'None' + +class BrokenRepr: + def __init__(self, ex): + self.ex = ex + foo = 0 + def __repr__(self): + raise self.ex + +def test_exception(): + assert 'Exception' in safe_repr._repr(BrokenRepr(Exception("broken"))) + +class BrokenReprException(Exception): + __str__ = None + __repr__ = None + +def test_broken_exception(): + assert 'Exception' in safe_repr._repr(BrokenRepr(BrokenReprException("really broken"))) + +def test_string_exception(): + assert 'unknown' in safe_repr._repr(BrokenRepr("string")) + +def test_big_repr(): + assert len(safe_repr._repr(range(1000))) <= \ + len('[' + safe_repr.SafeRepr().maxlist * "1000" + ']') + + + Modified: py/dist/py/test/terminal/terminal.py ============================================================================== --- py/dist/py/test/terminal/terminal.py (original) +++ py/dist/py/test/terminal/terminal.py Thu Feb 16 19:25:42 2006 @@ -3,6 +3,7 @@ from time import time as now Item = py.test.Item from py.__.test.terminal.out import getout +import py.__.code.safe_repr def getrelpath(source, dest): base = source.common(dest) @@ -434,12 +435,16 @@ for name, value in entry.frame.f_locals.items(): if name == '__builtins__': self.out.line("__builtins__ = ") - elif len(repr(value)) < 70 or not isinstance(value, - (list, tuple, dict)): - self.out.line("%-10s = %r" %(name, value)) else: - self.out.line("%-10s =\\" % (name,)) - py.std.pprint.pprint(value, stream=self.out) + # This formatting could all be handled by the _repr() function, which is + # only repr.Repr in disguise, so is very configurable. + str_repr = py.__.code.safe_repr._repr(value) + if len(str_repr) < 70 or not isinstance(value, + (list, tuple, dict)): + self.out.line("%-10s = %s" %(name, str_repr)) + else: + self.out.line("%-10s =\\" % (name,)) + py.std.pprint.pprint(value, stream=self.out) def repr_pythonversion(): v = py.std.sys.version_info Added: py/dist/py/test/testing/data/brokenrepr.py ============================================================================== --- (empty file) +++ py/dist/py/test/testing/data/brokenrepr.py Thu Feb 16 19:25:42 2006 @@ -0,0 +1,31 @@ +import py + +class BrokenRepr1: + """A broken class with lots of broken methods. Let's try to make the test framework + immune to these.""" + foo=0 + def __repr__(self): + raise Exception("Ha Ha fooled you, I'm a broken repr().") + +class BrokenRepr2: + """A broken class with lots of broken methods. Let's try to make the test framework + immune to these.""" + foo=0 + def __repr__(self): + raise "Ha Ha fooled you, I'm a broken repr()." + + +class TestBrokenClass: + + def test_explicit_bad_repr(self): + t = BrokenRepr1() + py.test.raises(Exception, 'repr(t)') + + def test_implicit_bad_repr1(self): + t = BrokenRepr1() + assert t.foo == 1 + + def test_implicit_bad_repr2(self): + t = BrokenRepr2() + assert t.foo == 1 + 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 Thu Feb 16 19:25:42 2006 @@ -293,6 +293,19 @@ item, outcome = l[0] assert str(outcome.excinfo).find('does_not_work') != -1 + def test_safe_repr(self): + session = self.session + session.main([str(datadir / 'brokenrepr.py')]) + out = self.file.getvalue() + print 'Output of simulated "py.test brokenrepr.py":' + print out + + l = session.getitemoutcomepairs(py.test.Item.Failed) + assert len(l) == 2 + assert out.find("""[Exception("Ha Ha fooled you, I'm a broken repr().") raised in repr()]""") != -1 #' + assert out.find("[unknown exception raised in repr()]") != -1 + + from py.__.test.terminal.remote import getrootdir class TestRemote: def test_rootdir_is_package(self): From hpk at codespeak.net Thu Feb 16 19:56:19 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 16 Feb 2006 19:56:19 +0100 (CET) Subject: [py-svn] r23424 - in py/dist/py: code code/testing test/terminal test/testing test/testing/data Message-ID: <20060216185619.860C6100C4@code0.codespeak.net> Author: hpk Date: Thu Feb 16 19:56:15 2006 New Revision: 23424 Removed: py/dist/py/code/safe_repr.py py/dist/py/code/testing/test_safe_repr.py py/dist/py/test/testing/data/brokenrepr.py Modified: py/dist/py/code/frame.py py/dist/py/test/terminal/terminal.py py/dist/py/test/testing/test_session.py Log: bail out last patch from Jan/Tom - this breaks PyPy testing which provides different frame classes so we need to check more carefully. Jan, can you checkout codespeak.net/svn/pypy/dist and run py.test -l pypy/tool/pytest/pypy_test_failure_demo.py which will result in py.test bailing out (without the patch it doesn't). So we need to take some more care. Probably we should add some tests to the py lib that provide frame/code classes with fewer attributes (much like pypy does) so that we can check our assumtions. It's obviously very hard for a py lib committer to know about the involved problems otherwise. sorry for not having noticed this problem earlier. Modified: py/dist/py/code/frame.py ============================================================================== --- py/dist/py/code/frame.py (original) +++ py/dist/py/code/frame.py Thu Feb 16 19:56:15 2006 @@ -1,5 +1,5 @@ import py -import py.__.code.safe_repr + class Frame(object): """Wrapper around a Python frame holding f_locals and f_globals @@ -27,7 +27,7 @@ exec code in self.f_globals, f_locals def repr(self, object): - return py.__.code.safe_repr._repr(object) + return repr(object) def is_true(self, object): return object Deleted: /py/dist/py/code/safe_repr.py ============================================================================== --- /py/dist/py/code/safe_repr.py Thu Feb 16 19:56:15 2006 +++ (empty file) @@ -1,63 +0,0 @@ -"""Defines a safe repr function. This will always return a string of "reasonable" length -no matter what the object does in it's own repr function. Let's examine what can go wrong -in an arbitrary repr function. -The default repr will return something like (on Win32 anyway): -. Well behaved user-defined repr() methods will do similar. -The usual expectation is that repr will return a single line string. - -1. However, the repr method can raise an exception of an arbitrary type. - -Also, the return value may not be as expected: - 2. The return value may not be a string! - 3. The return value may not be a single line string, it may contain line breaks. - 4. The method may enter a loop and never return. - 5. The return value may be enormous, eg range(100000) - - The standard library has a nice implementation in the repr module that will do the job, - but the exception - handling is silent, so the the output contains no clue that repr() call raised an - exception. I would like to be told if repr raises an exception, it's a serious error, so - a sublass of repr overrides the method that does repr for class instances.""" - - -import repr -import __builtin__ - - -class SafeRepr(repr.Repr): - def __init__(self, *args, **kwargs): - repr.Repr.__init__(self, *args, **kwargs) - # Do we need a commandline switch for this? - self.maxstring = 240 # 3 * 80 chars - self.maxother = 160 # 2 * 80 chars - def repr_instance(self, x, level): - try: - # Try the vanilla repr and make sure that the result is a string - s = str(__builtin__.repr(x)) - except (KeyboardInterrupt, MemoryError, SystemExit): - raise - except Exception ,e: - try: - exc_name = e.__class__.__name__ - except: - exc_name = 'unknown' - try: - exc_info = str(e) - except: - exc_info = 'unknown' - return '<[%s("%s") raised in repr()] %s object at 0x%x>' % \ - (exc_name, exc_info, x.__class__.__name__, id(x)) - except: - try: - name = x.__class__.__name__ - except: - name = 'unknown' - return '<[unknown exception raised in repr()] %s object at 0x%x>' % \ - (name, id(x)) - if len(s) > self.maxstring: - i = max(0, (self.maxstring-3)//2) - j = max(0, self.maxstring-3-i) - s = s[:i] + '...' + s[len(s)-j:] - return s - -_repr = SafeRepr().repr Deleted: /py/dist/py/code/testing/test_safe_repr.py ============================================================================== --- /py/dist/py/code/testing/test_safe_repr.py Thu Feb 16 19:56:15 2006 +++ (empty file) @@ -1,34 +0,0 @@ - -import py -from py.__.code import safe_repr - -def test_simple_repr(): - assert safe_repr._repr(1) == '1' - assert safe_repr._repr(None) == 'None' - -class BrokenRepr: - def __init__(self, ex): - self.ex = ex - foo = 0 - def __repr__(self): - raise self.ex - -def test_exception(): - assert 'Exception' in safe_repr._repr(BrokenRepr(Exception("broken"))) - -class BrokenReprException(Exception): - __str__ = None - __repr__ = None - -def test_broken_exception(): - assert 'Exception' in safe_repr._repr(BrokenRepr(BrokenReprException("really broken"))) - -def test_string_exception(): - assert 'unknown' in safe_repr._repr(BrokenRepr("string")) - -def test_big_repr(): - assert len(safe_repr._repr(range(1000))) <= \ - len('[' + safe_repr.SafeRepr().maxlist * "1000" + ']') - - - Modified: py/dist/py/test/terminal/terminal.py ============================================================================== --- py/dist/py/test/terminal/terminal.py (original) +++ py/dist/py/test/terminal/terminal.py Thu Feb 16 19:56:15 2006 @@ -3,7 +3,6 @@ from time import time as now Item = py.test.Item from py.__.test.terminal.out import getout -import py.__.code.safe_repr def getrelpath(source, dest): base = source.common(dest) @@ -435,16 +434,12 @@ for name, value in entry.frame.f_locals.items(): if name == '__builtins__': self.out.line("__builtins__ = ") - else: - # This formatting could all be handled by the _repr() function, which is - # only repr.Repr in disguise, so is very configurable. - str_repr = py.__.code.safe_repr._repr(value) - if len(str_repr) < 70 or not isinstance(value, + elif len(repr(value)) < 70 or not isinstance(value, (list, tuple, dict)): - self.out.line("%-10s = %s" %(name, str_repr)) - else: - self.out.line("%-10s =\\" % (name,)) - py.std.pprint.pprint(value, stream=self.out) + self.out.line("%-10s = %r" %(name, value)) + else: + self.out.line("%-10s =\\" % (name,)) + py.std.pprint.pprint(value, stream=self.out) def repr_pythonversion(): v = py.std.sys.version_info Deleted: /py/dist/py/test/testing/data/brokenrepr.py ============================================================================== --- /py/dist/py/test/testing/data/brokenrepr.py Thu Feb 16 19:56:15 2006 +++ (empty file) @@ -1,31 +0,0 @@ -import py - -class BrokenRepr1: - """A broken class with lots of broken methods. Let's try to make the test framework - immune to these.""" - foo=0 - def __repr__(self): - raise Exception("Ha Ha fooled you, I'm a broken repr().") - -class BrokenRepr2: - """A broken class with lots of broken methods. Let's try to make the test framework - immune to these.""" - foo=0 - def __repr__(self): - raise "Ha Ha fooled you, I'm a broken repr()." - - -class TestBrokenClass: - - def test_explicit_bad_repr(self): - t = BrokenRepr1() - py.test.raises(Exception, 'repr(t)') - - def test_implicit_bad_repr1(self): - t = BrokenRepr1() - assert t.foo == 1 - - def test_implicit_bad_repr2(self): - t = BrokenRepr2() - assert t.foo == 1 - 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 Thu Feb 16 19:56:15 2006 @@ -293,19 +293,6 @@ item, outcome = l[0] assert str(outcome.excinfo).find('does_not_work') != -1 - def test_safe_repr(self): - session = self.session - session.main([str(datadir / 'brokenrepr.py')]) - out = self.file.getvalue() - print 'Output of simulated "py.test brokenrepr.py":' - print out - - l = session.getitemoutcomepairs(py.test.Item.Failed) - assert len(l) == 2 - assert out.find("""[Exception("Ha Ha fooled you, I'm a broken repr().") raised in repr()]""") != -1 #' - assert out.find("[unknown exception raised in repr()]") != -1 - - from py.__.test.terminal.remote import getrootdir class TestRemote: def test_rootdir_is_package(self): From hpk at codespeak.net Thu Feb 16 20:03:10 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 16 Feb 2006 20:03:10 +0100 (CET) Subject: [py-svn] r23425 - in py/dist/py: code code/testing test/terminal test/testing test/testing/data Message-ID: <20060216190310.41EC1100C6@code0.codespeak.net> Author: hpk Date: Thu Feb 16 20:03:08 2006 New Revision: 23425 Added: py/dist/py/code/safe_repr.py - copied unchanged from r23423, py/dist/py/code/safe_repr.py py/dist/py/code/testing/test_safe_repr.py - copied unchanged from r23423, py/dist/py/code/testing/test_safe_repr.py py/dist/py/test/testing/data/brokenrepr.py - copied unchanged from r23423, py/dist/py/test/testing/data/brokenrepr.py Modified: py/dist/py/code/frame.py py/dist/py/test/terminal/terminal.py py/dist/py/test/testing/test_session.py Log: hum, re-applying Jan/Tom's patch for now (watch out for the next checking, i might reconsider :) it turns out the problem with pypy is there either way. However, my comment regarding the need to check a bit for pypy related use cases in py test itself still holds true. Modified: py/dist/py/code/frame.py ============================================================================== --- py/dist/py/code/frame.py (original) +++ py/dist/py/code/frame.py Thu Feb 16 20:03:08 2006 @@ -1,5 +1,5 @@ import py - +import py.__.code.safe_repr class Frame(object): """Wrapper around a Python frame holding f_locals and f_globals @@ -27,7 +27,7 @@ exec code in self.f_globals, f_locals def repr(self, object): - return repr(object) + return py.__.code.safe_repr._repr(object) def is_true(self, object): return object Modified: py/dist/py/test/terminal/terminal.py ============================================================================== --- py/dist/py/test/terminal/terminal.py (original) +++ py/dist/py/test/terminal/terminal.py Thu Feb 16 20:03:08 2006 @@ -3,6 +3,7 @@ from time import time as now Item = py.test.Item from py.__.test.terminal.out import getout +import py.__.code.safe_repr def getrelpath(source, dest): base = source.common(dest) @@ -434,12 +435,16 @@ for name, value in entry.frame.f_locals.items(): if name == '__builtins__': self.out.line("__builtins__ = ") - elif len(repr(value)) < 70 or not isinstance(value, - (list, tuple, dict)): - self.out.line("%-10s = %r" %(name, value)) else: - self.out.line("%-10s =\\" % (name,)) - py.std.pprint.pprint(value, stream=self.out) + # This formatting could all be handled by the _repr() function, which is + # only repr.Repr in disguise, so is very configurable. + str_repr = py.__.code.safe_repr._repr(value) + if len(str_repr) < 70 or not isinstance(value, + (list, tuple, dict)): + self.out.line("%-10s = %s" %(name, str_repr)) + else: + self.out.line("%-10s =\\" % (name,)) + py.std.pprint.pprint(value, stream=self.out) def repr_pythonversion(): v = py.std.sys.version_info 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 Thu Feb 16 20:03:08 2006 @@ -293,6 +293,19 @@ item, outcome = l[0] assert str(outcome.excinfo).find('does_not_work') != -1 + def test_safe_repr(self): + session = self.session + session.main([str(datadir / 'brokenrepr.py')]) + out = self.file.getvalue() + print 'Output of simulated "py.test brokenrepr.py":' + print out + + l = session.getitemoutcomepairs(py.test.Item.Failed) + assert len(l) == 2 + assert out.find("""[Exception("Ha Ha fooled you, I'm a broken repr().") raised in repr()]""") != -1 #' + assert out.find("[unknown exception raised in repr()]") != -1 + + from py.__.test.terminal.remote import getrootdir class TestRemote: def test_rootdir_is_package(self): From hpk at codespeak.net Thu Feb 16 20:05:38 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 16 Feb 2006 20:05:38 +0100 (CET) Subject: [py-svn] r23426 - py/dist/py/rest/testing/data Message-ID: <20060216190538.8ED80100C6@code0.codespeak.net> Author: hpk Date: Thu Feb 16 20:05:37 2006 New Revision: 23426 Modified: py/dist/py/rest/testing/data/ (props changed) Log: ignore files generated by tests From cfbolz at codespeak.net Fri Feb 17 03:00:19 2006 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Fri, 17 Feb 2006 03:00:19 +0100 (CET) Subject: [py-svn] r23434 - py/dist/py/path/svn Message-ID: <20060217020019.7289610092@code0.codespeak.net> Author: cfbolz Date: Fri Feb 17 03:00:18 2006 New Revision: 23434 Modified: py/dist/py/path/svn/wccommand.py Log: almost certainly a typo Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Fri Feb 17 03:00:18 2006 @@ -96,7 +96,7 @@ if rev is None or rev == -1: url += "@HEAD" else: - url += "@%d" % self.rev + url += "@%d" % rev self._svn('co', url) def update(self, rev = 'HEAD'): From arigo at codespeak.net Sun Feb 19 16:18:39 2006 From: arigo at codespeak.net (arigo at codespeak.net) Date: Sun, 19 Feb 2006 16:18:39 +0100 (CET) Subject: [py-svn] r23478 - py/dist/py/test/terminal Message-ID: <20060219151839.B66C01006C@code0.codespeak.net> Author: arigo Date: Sun Feb 19 16:18:38 2006 New Revision: 23478 Modified: py/dist/py/test/terminal/terminal.py Log: Fix a crash with the (unlikely) combination of flags --pdb --tb=no. Modified: py/dist/py/test/terminal/terminal.py ============================================================================== --- py/dist/py/test/terminal/terminal.py (original) +++ py/dist/py/test/terminal/terminal.py Sun Feb 19 16:18:38 2006 @@ -350,6 +350,9 @@ self.out.sep("!") break + # the following is only used by the combination '--pdb --tb=no' + repr_failure_tbno = repr_failure_tbshort + def repr_failure_info(self, item, entry): root = item.fspath modpath = item.getmodpath() From arigo at codespeak.net Sun Feb 19 16:40:11 2006 From: arigo at codespeak.net (arigo at codespeak.net) Date: Sun, 19 Feb 2006 16:40:11 +0100 (CET) Subject: [py-svn] r23480 - py/dist/py/test/terminal Message-ID: <20060219154011.3035810072@code0.codespeak.net> Author: arigo Date: Sun Feb 19 16:40:10 2006 New Revision: 23480 Modified: py/dist/py/test/terminal/out.py Log: Revised the out.sep() logic, which used to produce a line one character too long in specific situations (odd-sized terminal widths with sep=="_ "). Modified: py/dist/py/test/terminal/out.py ============================================================================== --- py/dist/py/test/terminal/out.py (original) +++ py/dist/py/test/terminal/out.py Sun Feb 19 16:40:10 2006 @@ -13,19 +13,25 @@ def sep(self, sepchar, title=None): fullwidth = self.fullwidth - #spacing = " " * ((79 - compwidth)/2) + # the goal is to have the line be as long as possible + # under the condition that len(line) <= fullwidth if title is not None: - size = len(title) + 2 - half = (fullwidth-size) / 2.0 - #line = "%s%s %s %s%s" %(spacing, - # sepchar * half, title, sepchar * half, spacing) - fill = sepchar * int(half / len(sepchar)) + # we want 2 + 2*len(fill) + len(title) <= fullwidth + # i.e. 2 + 2*len(sepchar)*N + len(title) <= fullwidth + # 2*len(sepchar)*N <= fullwidth - len(title) - 2 + # N <= (fullwidth - len(title) - 2) // (2*len(sepchar)) + N = (fullwidth - len(title) - 2) // (2*len(sepchar)) + fill = sepchar * N line = "%s %s %s" % (fill, title, fill) - line += sepchar * int(fullwidth-(half*2+size)) else: - line = sepchar * int(fullwidth/len(sepchar)) - if len(line) != fullwidth: - line += sepchar + # we want len(sepchar)*N <= fullwidth + # i.e. N <= fullwidth // len(sepchar) + line = sepchar * (fullwidth // len(sepchar)) + # in some situations there is room for an extra sepchar at the right, + # in particular if we consider that with a sepchar like "_ " the + # trailing space is not important at the end of the line + if len(line) + len(sepchar.rstrip()) <= fullwidth: + line += sepchar.rstrip() self.line(line) class TerminalOut(Out): From arigo at codespeak.net Sun Feb 19 16:41:18 2006 From: arigo at codespeak.net (arigo at codespeak.net) Date: Sun, 19 Feb 2006 16:41:18 +0100 (CET) Subject: [py-svn] r23481 - py/dist/py/test/terminal Message-ID: <20060219154118.E864610072@code0.codespeak.net> Author: arigo Date: Sun Feb 19 16:41:17 2006 New Revision: 23481 Modified: py/dist/py/test/terminal/terminal.py Log: Possibly controvertial change: put the recorded stdout/stderr before the tracebacks. This seems to be essential for PyPy debugging, which can produce very long captured stdout logs and thus completely drown the actual traceback. Modified: py/dist/py/test/terminal/terminal.py ============================================================================== --- py/dist/py/test/terminal/terminal.py (original) +++ py/dist/py/test/terminal/terminal.py Sun Feb 19 16:41:17 2006 @@ -252,7 +252,6 @@ 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) @@ -268,6 +267,11 @@ 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 @@ -298,13 +302,7 @@ self.out.line("[%s:%d]" %(entry.frame.code.path, entry.lineno+1)) self.repr_locals(entry) - # trailing info - if entry == last: - #if item: - # self.repr_failure_info(item, entry) - self.repr_out_err(item) - self.out.sep("_") - else: + if entry is not last: self.out.sep("_ ") if index == recursionindex: self.out.line("Recursion detected (same locals & position)") @@ -338,13 +336,8 @@ self.repr_source(source, ' ') self.repr_locals(entry) - # trailing info - if entry == last: - #if item: - # self.repr_failure_info(item, entry) - self.repr_out_err(item) - self.out.sep("_") - else: + if entry is not last: + self.out.sep("_ ") if index == recursionindex: self.out.line("Recursion detected (same locals & position)") self.out.sep("!") @@ -430,6 +423,8 @@ 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 briandorsey at codespeak.net Mon Feb 27 16:41:49 2006 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Mon, 27 Feb 2006 16:41:49 +0100 (CET) Subject: [py-svn] r23695 - py/dist/py/rest/testing Message-ID: <20060227154149.DF53010092@code0.codespeak.net> Author: briandorsey Date: Mon Feb 27 16:41:38 2006 New Revision: 23695 Added: py/dist/py/rest/testing/shared_helpers.py Modified: py/dist/py/rest/testing/test_convert.py py/dist/py/rest/testing/test_directive.py py/dist/py/rest/testing/test_htmlrest.py py/dist/py/rest/testing/test_rst2pdf.py Log: Modified ReST tests to skip most tests if latex, gs or dot are not available. Added: py/dist/py/rest/testing/shared_helpers.py ============================================================================== --- (empty file) +++ py/dist/py/rest/testing/shared_helpers.py Mon Feb 27 16:41:38 2006 @@ -0,0 +1,11 @@ +import py + +def is_on_path(name): + try: + py.path.local.sysfind(name) + except py.error.ENOENT: + return False + else: + return True + + Modified: py/dist/py/rest/testing/test_convert.py ============================================================================== --- py/dist/py/rest/testing/test_convert.py (original) +++ py/dist/py/rest/testing/test_convert.py Mon Feb 27 16:41:38 2006 @@ -1,13 +1,6 @@ import py from py.__.rest.convert import convert_dot, latexformula2png - -def is_on_path(name): - try: - py.path.local.sysfind(name) - except py.error.ENOENT: - return False - else: - return True +from shared_helpers import is_on_path datadir = py.magic.autopath().dirpath().join("data") Modified: py/dist/py/rest/testing/test_directive.py ============================================================================== --- py/dist/py/rest/testing/test_directive.py (original) +++ py/dist/py/rest/testing/test_directive.py Mon Feb 27 16:41:38 2006 @@ -2,10 +2,13 @@ from py.__.rest import directive from py.__.misc import rest from py.__.rest.latex import process_rest_file +from shared_helpers import is_on_path datadir = py.magic.autopath().dirpath().join("data") def test_graphviz_html(): + if not is_on_path("dot"): + py.test.skip("graphviz needed") directive.BackendStore("html") #for reasons that elude me rest.process expects svnwcs??? txt = py.path.svnwc(datadir.join("graphviz.txt")) @@ -20,6 +23,9 @@ png.remove() def test_graphviz_pdf(): + if is_on_path("dot") or not is_on_path("latex"): + py.test.skip("graphviz and latex needed") + directive.BackendStore("latex") txt = py.path.local(datadir.join("graphviz.txt")) pdf = txt.new(ext="pdf") Modified: py/dist/py/rest/testing/test_htmlrest.py ============================================================================== --- py/dist/py/rest/testing/test_htmlrest.py (original) +++ py/dist/py/rest/testing/test_htmlrest.py Mon Feb 27 16:41:38 2006 @@ -1,11 +1,17 @@ import py from py.__.misc import rest +from shared_helpers import is_on_path + +def setup_module(mod): + if not is_on_path("gs") or not is_on_path("dot") or not is_on_path("latex"): + py.test.skip("ghostscript, graphviz and latex needed") data = py.magic.autopath().dirpath().join("data") -def test_process_all(): +def test_process_simple(): # fallback test: only checks that no exception is raised def rec(p): return p.check(dotfile=0) for x in data.visit("*.txt", rec=rec): yield rest.process, x + Modified: py/dist/py/rest/testing/test_rst2pdf.py ============================================================================== --- py/dist/py/rest/testing/test_rst2pdf.py (original) +++ py/dist/py/rest/testing/test_rst2pdf.py Mon Feb 27 16:41:38 2006 @@ -1,5 +1,10 @@ import py from py.__.rest.latex import process_configfile, process_rest_file +from shared_helpers import is_on_path + +def setup_module(mod): + if not is_on_path("gs") or not is_on_path("dot") or not is_on_path("latex"): + py.test.skip("ghostscript, graphviz and latex needed") data = py.magic.autopath().dirpath().join("data") From briandorsey at codespeak.net Mon Feb 27 21:37:55 2006 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Mon, 27 Feb 2006 21:37:55 +0100 (CET) Subject: [py-svn] r23705 - in py/dist/py/path/local: . testing Message-ID: <20060227203755.14A791008F@code0.codespeak.net> Author: briandorsey Date: Mon Feb 27 21:37:55 2006 New Revision: 23705 Added: py/dist/py/path/local/testing/test_win.py Modified: py/dist/py/path/local/win.py Log: Added chmod to all py.path.local objects on windows. Added: py/dist/py/path/local/testing/test_win.py ============================================================================== --- (empty file) +++ py/dist/py/path/local/testing/test_win.py Mon Feb 27 21:37:55 2006 @@ -0,0 +1,26 @@ +import py + +class TestWINLocalPath: + #root = local(TestLocalPath.root) + disabled = py.std.sys.platform != 'win32' + + def setup_class(cls): + cls.root = py.test.ensuretemp(cls.__name__) + + def setup_method(self, method): + name = method.im_func.func_name + self.tmpdir = self.root.ensure(name, dir=1) + + def test_chmod_simple_int(self): + print "self.root is", self.root + mode = self.root.stat().st_mode + # Ensure that we actually change the mode to something different. + self.root.chmod(mode == 0 and 1 or 0) + try: + print self.root.stat().st_mode + print mode + assert self.root.stat().st_mode != mode + finally: + self.root.chmod(mode) + assert self.root.stat().st_mode == mode + Modified: py/dist/py/path/local/win.py ============================================================================== --- py/dist/py/path/local/win.py (original) +++ py/dist/py/path/local/win.py Mon Feb 27 21:37:55 2006 @@ -1,3 +1,5 @@ +import os + """ module for win-specific local path stuff @@ -9,3 +11,19 @@ class WinMixin: def _makestat(self, statresult): return Stat(self, statresult) + + def chmod(self, mode, rec=0): + """ change permissions to the given mode. If mode is an + integer it directly encodes the os-specific modes. + if rec is True perform recursively. + + (xxx if mode is a string then it specifies access rights + in '/bin/chmod' style, e.g. a+r). + """ + if not isinstance(mode, int): + raise TypeError("mode %r must be an integer" % (mode,)) + if rec: + for x in self.visit(rec=rec): + self._callex(os.chmod, str(x), mode) + self._callex(os.chmod, str(self), mode) + From briandorsey at codespeak.net Mon Feb 27 22:01:29 2006 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Mon, 27 Feb 2006 22:01:29 +0100 (CET) Subject: [py-svn] r23707 - in py/dist/py/path/local: . testing Message-ID: <20060227210129.14E5410076@code0.codespeak.net> Author: briandorsey Date: Mon Feb 27 22:01:18 2006 New Revision: 23707 Modified: py/dist/py/path/local/local.py py/dist/py/path/local/testing/test_local.py Log: Make py.path.local.remove() more agressive - it now runs chmod(0700) when deleting recursively. Modified: py/dist/py/path/local/local.py ============================================================================== --- py/dist/py/path/local/local.py (original) +++ py/dist/py/path/local/local.py Mon Feb 27 22:01:18 2006 @@ -209,6 +209,7 @@ """ remove a file or directory (or a directory tree if rec=1). """ if self.check(dir=1, link=0): if rec: + self.chmod(0700, rec=True) self._callex(py.std.shutil.rmtree, self.strpath) else: self._callex(os.rmdir, self.strpath) Modified: py/dist/py/path/local/testing/test_local.py ============================================================================== --- py/dist/py/path/local/testing/test_local.py (original) +++ py/dist/py/path/local/testing/test_local.py Mon Feb 27 22:01:18 2006 @@ -129,6 +129,20 @@ assert t == newfile assert newfile.check(dir=1) + def test_remove_readonly(self): + tmpdir = self.tmpdir / 'subdir' + tmpdir.mkdir() + tmpfile = tmpdir / 'a_file' + f = open(str(tmpfile), 'w') + f.close() + tmpfile.chmod(0) + + local = py.path.local(tmpdir) + local.remove(rec = True) + + + + class TestExecutionOnWindows(LocalSetup): disabled = py.std.sys.platform != 'win32' From briandorsey at codespeak.net Tue Feb 28 18:19:52 2006 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Tue, 28 Feb 2006 18:19:52 +0100 (CET) Subject: [py-svn] r23763 - in py/dist/py/path/local: . testing Message-ID: <20060228171952.910D01008D@code0.codespeak.net> Author: briandorsey Date: Tue Feb 28 18:19:51 2006 New Revision: 23763 Modified: py/dist/py/path/local/local.py py/dist/py/path/local/testing/test_win.py Log: Allow unix style paths (forward slashes) even on windows. Modified: py/dist/py/path/local/local.py ============================================================================== --- py/dist/py/path/local/local.py (original) +++ py/dist/py/path/local/local.py Tue Feb 28 18:19:51 2006 @@ -165,6 +165,10 @@ break for arg in strargs: arg = arg.strip(sep) + if py.std.sys.platform == 'win32': + # allow unix style paths even on windows. + arg = arg.strip('/') + arg = arg.replace('/', sep) if arg: if not strpath.endswith(sep): strpath += sep Modified: py/dist/py/path/local/testing/test_win.py ============================================================================== --- py/dist/py/path/local/testing/test_win.py (original) +++ py/dist/py/path/local/testing/test_win.py Tue Feb 28 18:19:51 2006 @@ -24,3 +24,11 @@ self.root.chmod(mode) assert self.root.stat().st_mode == mode + def test_allow_unix_style_paths(self): + t1 = self.root.join('a_path') + assert t1 == str(self.root) + '\\a_path' + t1 = self.root.join('a_path/') + assert t1 == str(self.root) + '\\a_path' + t1 = self.root.join('dir/a_path') + assert t1 == str(self.root) + '\\dir\\a_path' + From briandorsey at codespeak.net Tue Feb 28 21:56:10 2006 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Tue, 28 Feb 2006 21:56:10 +0100 (CET) Subject: [py-svn] r23783 - py/dist/py/path/testing Message-ID: <20060228205610.242AC10080@code0.codespeak.net> Author: briandorsey Date: Tue Feb 28 21:56:09 2006 New Revision: 23783 Modified: py/dist/py/path/testing/common.py Log: Open the test file in universal readlines mode so the comparison to the string literal works even on windows. Modified: py/dist/py/path/testing/common.py ============================================================================== --- py/dist/py/path/testing/common.py (original) +++ py/dist/py/path/testing/common.py Tue Feb 28 21:56:09 2006 @@ -218,6 +218,6 @@ assert name in doc def test_simple_read(self): - x = self.root.join('samplefile').read() + x = self.root.join('samplefile').read('ru') assert x == 'samplefile\n' From briandorsey at codespeak.net Tue Feb 28 22:14:53 2006 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Tue, 28 Feb 2006 22:14:53 +0100 (CET) Subject: [py-svn] r23786 - py/dist/py/documentation Message-ID: <20060228211453.11A3210084@code0.codespeak.net> Author: briandorsey Date: Tue Feb 28 22:14:52 2006 New Revision: 23786 Modified: py/dist/py/documentation/why_py.txt Log: Python itself is now hosted in SVN, so removing the CVS comment. Modified: py/dist/py/documentation/why_py.txt ============================================================================== --- py/dist/py/documentation/why_py.txt (original) +++ py/dist/py/documentation/why_py.txt Tue Feb 28 22:14:52 2006 @@ -29,8 +29,7 @@ - the python "batteries included" standard modules are tied to the python release process. You can't easily benefit from new python module in older python versions which you might - have to use for whatever reason. Oh and battery development - still happens with ``cvs`` which is so much 90ties :-) + have to use for whatever reason. - support for richer interactive interaction with command line utilities or e.g. pygame-based shells is missing. From briandorsey at codespeak.net Tue Feb 28 23:17:49 2006 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Tue, 28 Feb 2006 23:17:49 +0100 (CET) Subject: [py-svn] r23791 - in py/dist/py/path/local: . testing Message-ID: <20060228221749.331AF10075@code0.codespeak.net> Author: briandorsey Date: Tue Feb 28 23:17:48 2006 New Revision: 23791 Modified: py/dist/py/path/local/local.py py/dist/py/path/local/testing/test_local.py Log: Removing the addition of chmod to py.path.local.remove - it caused a race condition on linux where a file was found by visit, but wasn't there when chmod got to run. Modified: py/dist/py/path/local/local.py ============================================================================== --- py/dist/py/path/local/local.py (original) +++ py/dist/py/path/local/local.py Tue Feb 28 23:17:48 2006 @@ -213,7 +213,6 @@ """ remove a file or directory (or a directory tree if rec=1). """ if self.check(dir=1, link=0): if rec: - self.chmod(0700, rec=True) self._callex(py.std.shutil.rmtree, self.strpath) else: self._callex(os.rmdir, self.strpath) Modified: py/dist/py/path/local/testing/test_local.py ============================================================================== --- py/dist/py/path/local/testing/test_local.py (original) +++ py/dist/py/path/local/testing/test_local.py Tue Feb 28 23:17:48 2006 @@ -129,19 +129,6 @@ assert t == newfile assert newfile.check(dir=1) - def test_remove_readonly(self): - tmpdir = self.tmpdir / 'subdir' - tmpdir.mkdir() - tmpfile = tmpdir / 'a_file' - f = open(str(tmpfile), 'w') - f.close() - tmpfile.chmod(0) - - local = py.path.local(tmpdir) - local.remove(rec = True) - - - class TestExecutionOnWindows(LocalSetup): disabled = py.std.sys.platform != 'win32'