From cfbolz at codespeak.net Tue Aug 2 20:48:46 2005 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 2 Aug 2005 20:48:46 +0200 (CEST) Subject: [py-svn] r15523 - py/dist/py/bin Message-ID: <20050802184846.12EFF27B4B@code1.codespeak.net> Author: cfbolz Date: Tue Aug 2 20:48:42 2005 New Revision: 15523 Modified: py/dist/py/bin/py.cleanup Log: changed py.cleanup to allow to specify a path where the cleanup should start. Modified: py/dist/py/bin/py.cleanup ============================================================================== --- py/dist/py/bin/py.cleanup (original) +++ py/dist/py/bin/py.cleanup Tue Aug 2 20:48:42 2005 @@ -3,5 +3,10 @@ from _findpy import py import py -for x in py.path.local().visit('*.pyc', py.path.checker(dotfile=0)): +if len(py.std.sys.argv) > 1: + path = py.path.local(py.std.sys.argv[1]) +else: + path = py.path.local() +print "cleaning path", path +for x in path.visit('*.pyc', py.path.checker(dotfile=0)): x.remove() From arigo at codespeak.net Wed Aug 10 11:02:33 2005 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 10 Aug 2005 11:02:33 +0200 (CEST) Subject: [py-svn] r15899 - in py/dist/py: . builtin builtin/testing Message-ID: <20050810090233.31EA327B46@code1.codespeak.net> Author: arigo Date: Wed Aug 10 11:02:28 2005 New Revision: 15899 Added: py/dist/py/builtin/reversed.py (contents, props changed) py/dist/py/builtin/testing/test_reversed.py (contents, props changed) Modified: py/dist/py/__init__.py Log: Added py.builtin.reversed(), copied from PyPy and tested on top of Python 2.2 as well. This is useful for pypy/lib/test2/test_deque_extra.py. Modified: py/dist/py/__init__.py ============================================================================== --- py/dist/py/__init__.py (original) +++ py/dist/py/__init__.py Wed Aug 10 11:02:28 2005 @@ -84,6 +84,7 @@ # backports and additions of builtins 'builtin.enumerate' : ('./builtin/enumerate.py', 'enumerate'), + 'builtin.reversed' : ('./builtin/reversed.py', 'reversed'), # gateways into remote contexts 'execnet.SocketGateway' : ('./execnet/register.py', 'SocketGateway'), Added: py/dist/py/builtin/reversed.py ============================================================================== --- (empty file) +++ py/dist/py/builtin/reversed.py Wed Aug 10 11:02:28 2005 @@ -0,0 +1,37 @@ +from __future__ import generators +try: + reversed = reversed +except NameError: + + def reversed(sequence): + """reversed(sequence) -> reverse iterator over values of the sequence + + Return a reverse iterator + """ + if hasattr(sequence, '__reversed__'): + return sequence.__reversed__() + if not hasattr(sequence, '__getitem__'): + raise TypeError("argument to reversed() must be a sequence") + return reversed_iterator(sequence) + + + class reversed_iterator(object): + + def __init__(self, seq): + self.seq = seq + self.remaining = len(seq) + + def __iter__(self): + return self + + def next(self): + i = self.remaining + if i > 0: + i -= 1 + item = self.seq[i] + self.remaining = i + return item + raise StopIteration + + def __len__(self): + return self.remaining Added: py/dist/py/builtin/testing/test_reversed.py ============================================================================== --- (empty file) +++ py/dist/py/builtin/testing/test_reversed.py Wed Aug 10 11:02:28 2005 @@ -0,0 +1,18 @@ +from py.builtin import reversed +from py.test import raises + +def test_reversed(): + r = reversed("hello") + assert iter(r) is r + assert len(r) == 5 + assert r.next() == "o" + assert r.next() == "l" + assert r.next() == "l" + assert r.next() == "e" + assert len(r) == 1 + assert r.next() == "h" + assert len(r) == 0 + raises(StopIteration, r.next) + assert len(r) == 0 + assert list(reversed(list(reversed("hello")))) == ['h','e','l','l','o'] + raises(TypeError, reversed, reversed("hello")) From hpk at codespeak.net Wed Aug 10 12:50:58 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 10 Aug 2005 12:50:58 +0200 (CEST) Subject: [py-svn] r15906 - in py/dist/py/execnet: . testing Message-ID: <20050810105058.ED2E827B51@code1.codespeak.net> Author: hpk Date: Wed Aug 10 12:50:58 2005 New Revision: 15906 Modified: py/dist/py/execnet/channel.py py/dist/py/execnet/testing/test_gateway.py Log: default to no timeout for waitclose() Modified: py/dist/py/execnet/channel.py ============================================================================== --- py/dist/py/execnet/channel.py (original) +++ py/dist/py/execnet/channel.py Wed Aug 10 12:50:58 2005 @@ -85,7 +85,7 @@ put(Message.CHANNEL_CLOSE(self.id)) self._local_close() - def waitclose(self, timeout): + def waitclose(self, timeout=None): """ wait until this channel is closed. A closed channel may still hold receiveable items. waitclose() reraises exceptions from executing code on the other 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 Aug 10 12:50:58 2005 @@ -93,6 +93,10 @@ channel = self.gw.remote_exec('pass') channel.waitclose(timeout=1.0) + def test_remote_exec_waitclose_noarg(self): + channel = self.gw.remote_exec('pass') + channel.waitclose() + def test_remote_exec_error_after_close(self): channel = self.gw.remote_exec('pass') channel.waitclose(timeout=1.0) From hpk at codespeak.net Wed Aug 10 16:57:10 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 10 Aug 2005 16:57:10 +0200 (CEST) Subject: [py-svn] r15920 - py/dist/py/execnet Message-ID: <20050810145710.3DE5E27B51@code1.codespeak.net> Author: hpk Date: Wed Aug 10 16:57:09 2005 New Revision: 15920 Modified: py/dist/py/execnet/register.py Log: compress ssh traffic by default Modified: py/dist/py/execnet/register.py ============================================================================== --- py/dist/py/execnet/register.py (original) +++ py/dist/py/execnet/register.py Wed Aug 10 16:57:09 2005 @@ -144,7 +144,7 @@ # XXX Unix style quoting for i in range(len(cmdline)): cmdline[i] = "'" + cmdline[i].replace("'", "'\\''") + "'" - cmd = 'ssh' + cmd = 'ssh -C' if identity is not None: cmd += ' -i %s' % (identity,) cmdline.insert(0, cmd) From arigo at codespeak.net Wed Aug 10 23:20:47 2005 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 10 Aug 2005 23:20:47 +0200 (CEST) Subject: [py-svn] r15944 - py/branch/execnet-refactoring Message-ID: <20050810212047.B60F527B5A@code1.codespeak.net> Author: arigo Date: Wed Aug 10 23:20:47 2005 New Revision: 15944 Modified: py/branch/execnet-refactoring/gateway.py Log: Disabled debugging logs in the execnet branch, in preparation for its merge. Modified: py/branch/execnet-refactoring/gateway.py ============================================================================== --- py/branch/execnet-refactoring/gateway.py (original) +++ py/branch/execnet-refactoring/gateway.py Wed Aug 10 23:20:47 2005 @@ -26,7 +26,7 @@ NamedThreadPool = py._thread.NamedThreadPool import os -debug = open('/tmp/execnet-debug-%d' % os.getpid() , 'wa') +debug = 0 # open('/tmp/execnet-debug-%d' % os.getpid() , 'wa') sysex = (KeyboardInterrupt, SystemExit) From arigo at codespeak.net Wed Aug 10 23:25:26 2005 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 10 Aug 2005 23:25:26 +0200 (CEST) Subject: [py-svn] r15945 - in py/branch/execnet-refactoring: . testing Message-ID: <20050810212526.3791027B5A@code1.codespeak.net> Author: arigo Date: Wed Aug 10 23:25:25 2005 New Revision: 15945 Modified: py/branch/execnet-refactoring/channel.py py/branch/execnet-refactoring/register.py py/branch/execnet-refactoring/testing/test_gateway.py Log: Merged the changes from the trunk to the branch: (hpk, r15906) default to no timeout for waitclose() (hpk, r15920) compress ssh traffic by default Modified: py/branch/execnet-refactoring/channel.py ============================================================================== --- py/branch/execnet-refactoring/channel.py (original) +++ py/branch/execnet-refactoring/channel.py Wed Aug 10 23:25:25 2005 @@ -104,7 +104,7 @@ self._items.put(ENDMARKER) self.gateway.channelfactory._no_longer_opened(self.id) - def waitclose(self, timeout): + def waitclose(self, timeout=None): """ wait until this channel is closed (or the remote side otherwise signalled that no more data was being sent). The channel may still hold receiveable items, but not receive Modified: py/branch/execnet-refactoring/register.py ============================================================================== --- py/branch/execnet-refactoring/register.py (original) +++ py/branch/execnet-refactoring/register.py Wed Aug 10 23:25:25 2005 @@ -144,7 +144,7 @@ # XXX Unix style quoting for i in range(len(cmdline)): cmdline[i] = "'" + cmdline[i].replace("'", "'\\''") + "'" - cmd = 'ssh' + cmd = 'ssh -C' if identity is not None: cmd += ' -i %s' % (identity,) cmdline.insert(0, cmd) Modified: py/branch/execnet-refactoring/testing/test_gateway.py ============================================================================== --- py/branch/execnet-refactoring/testing/test_gateway.py (original) +++ py/branch/execnet-refactoring/testing/test_gateway.py Wed Aug 10 23:25:25 2005 @@ -86,6 +86,10 @@ channel = self.gw.remote_exec('def gccycle(): pass') channel.waitclose(timeout=1.0) + def test_remote_exec_waitclose_noarg(self): + channel = self.gw.remote_exec('pass') + channel.waitclose() + def test_remote_exec_error_after_close(self): channel = self.gw.remote_exec('pass') channel.waitclose(timeout=1.0) From arigo at codespeak.net Wed Aug 10 23:31:04 2005 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 10 Aug 2005 23:31:04 +0200 (CEST) Subject: [py-svn] r15946 - in py: branch/execnet-refactoring dist/py/execnet Message-ID: <20050810213104.6F64127B5A@code1.codespeak.net> Author: arigo Date: Wed Aug 10 23:31:04 2005 New Revision: 15946 Added: py/dist/py/execnet/ - copied from r15945, py/branch/execnet-refactoring/ Removed: py/branch/execnet-refactoring/ Log: Moved the execnet branch back into the 'dist' trunk. From xoraxax at codespeak.net Fri Aug 12 10:02:31 2005 From: xoraxax at codespeak.net (xoraxax at codespeak.net) Date: Fri, 12 Aug 2005 10:02:31 +0200 (CEST) Subject: [py-svn] r15998 - py/dist/py/test Message-ID: <20050812080231.C389627B64@code1.codespeak.net> Author: xoraxax Date: Fri Aug 12 10:02:30 2005 New Revision: 15998 Modified: py/dist/py/test/config.py Log: Added better usage information for py.test. Modified: py/dist/py/test/config.py ============================================================================== --- py/dist/py/test/config.py (original) +++ py/dist/py/test/config.py Fri Aug 12 10:02:30 2005 @@ -29,7 +29,7 @@ def __init__(self): self.option = optparse.Values() - self._parser = optparse.OptionParser() + self._parser = optparse.OptionParser(usage="usage: %prog [options] [query] [filenames of tests]") self._initialconfigmodules = [] # class level attributes From hpk at codespeak.net Sat Aug 13 12:58:28 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 13 Aug 2005 12:58:28 +0200 (CEST) Subject: [py-svn] r16033 - py/dist/py/test/tkinter/testing Message-ID: <20050813105828.134D027B64@code1.codespeak.net> Author: hpk Date: Sat Aug 13 12:58:27 2005 New Revision: 16033 Modified: py/dist/py/test/tkinter/testing/test_backend.py Log: skip a tkinter test that currently fails after Armin's execnet merge. Jan, could you maybe look into it? Modified: py/dist/py/test/tkinter/testing/test_backend.py ============================================================================== --- py/dist/py/test/tkinter/testing/test_backend.py (original) +++ py/dist/py/test/tkinter/testing/test_backend.py Sat Aug 13 12:58:27 2005 @@ -178,6 +178,7 @@ assert l[0] is None def test_start_tests(self): + py.test.skip("XXX this test does not work after execnet merge") config, args = py.test.Config.parse([]) self.backend.start_tests(config = config, args = [str(datadir / 'filetest.py')], From hpk at codespeak.net Sat Aug 13 13:16:14 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 13 Aug 2005 13:16:14 +0200 (CEST) Subject: [py-svn] r16034 - in py/dist/py/test: . tkinter/testing Message-ID: <20050813111614.BBF0327B64@code1.codespeak.net> Author: hpk Date: Sat Aug 13 13:16:13 2005 New Revision: 16034 Modified: py/dist/py/test/collect.py py/dist/py/test/item.py py/dist/py/test/tkinter/testing/test_capture_out_err.py Log: issue15 chatting temporarily make --looponfailing and --tkinter work after the execnet merge and the stdout/stderr capturing changes in py.test. This needs to be looked at more closely soon. Modified: py/dist/py/test/collect.py ============================================================================== --- py/dist/py/test/collect.py (original) +++ py/dist/py/test/collect.py Sat Aug 13 13:16:13 2005 @@ -278,7 +278,11 @@ def startcapture(self): if not self.option.nocapture and not self.option.usepdb: assert not hasattr(self, '_capture') - self._capture = py.io.OutErrCapture() + #self._capture = py.io.OutErrCapture() + # XXX integrate this into py.io / refactor + # execnet/py.test capturing mechanisms + from py.__.misc.simplecapture import SimpleOutErrCapture + self._capture = SimpleOutErrCapture() def finishcapture(self): if hasattr(self, '_capture'): Modified: py/dist/py/test/item.py ============================================================================== --- py/dist/py/test/item.py (original) +++ py/dist/py/test/item.py Sat Aug 13 13:16:13 2005 @@ -32,7 +32,11 @@ class Item(py.test.collect.Collector): def startcapture(self): if not self.option.nocapture and not self.option.usepdb: - self._capture = py.io.OutErrCapture() + # XXX refactor integrate capturing + #self._capture = py.io.OutErrCapture() + from py.__.misc.simplecapture import SimpleOutErrCapture + self._capture = SimpleOutErrCapture() + def finishcapture(self): if hasattr(self, '_capture'): capture = self._capture Modified: py/dist/py/test/tkinter/testing/test_capture_out_err.py ============================================================================== --- py/dist/py/test/tkinter/testing/test_capture_out_err.py (original) +++ py/dist/py/test/tkinter/testing/test_capture_out_err.py Sat Aug 13 13:16:13 2005 @@ -5,6 +5,7 @@ datadir = py.magic.autopath().dirpath('data') def test_capture_out_err(): + py.test.skip("XXX needs fixing after execnet merge") config, args = py.test.Config.parse([]) backend = ReportBackend() backend.start_tests(config = config, From hpk at codespeak.net Sat Aug 13 15:23:07 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 13 Aug 2005 15:23:07 +0200 (CEST) Subject: [py-svn] r16043 - in py/dist/py/path/local: . testing Message-ID: <20050813132307.09D2F27B6D@code1.codespeak.net> Author: hpk Date: Sat Aug 13 15:23:06 2005 New Revision: 16043 Modified: py/dist/py/path/local/posix.py py/dist/py/path/local/testing/test_posix.py Log: don't try chown on a link when recursing Modified: py/dist/py/path/local/posix.py ============================================================================== --- py/dist/py/path/local/posix.py (original) +++ py/dist/py/path/local/posix.py Sat Aug 13 15:23:06 2005 @@ -52,7 +52,8 @@ gid = getgroupid(group) if rec: for x in self.visit(rec=py.path.checker(link=0)): - self._callex(os.chown, str(x), uid, gid) + if x.check(link=0): + self._callex(os.chown, str(x), uid, gid) self._callex(os.chown, str(self), uid, gid) def readlink(self): Modified: py/dist/py/path/local/testing/test_posix.py ============================================================================== --- py/dist/py/path/local/testing/test_posix.py (original) +++ py/dist/py/path/local/testing/test_posix.py Sat Aug 13 15:23:06 2005 @@ -155,6 +155,16 @@ group = self.root.group() self.root.chown(owner, group) + def test_chown_dangling_link(self): + owner = self.root.owner() + group = self.root.group() + x = self.root.join('hello') + x.mksymlinkto('qlwkejqwlek') + try: + self.root.chown(owner, group, rec=1) + finally: + x.remove(rec=0) + def test_chown_identity_rec_mayfail(self): owner = self.root.owner() group = self.root.group() From jan at codespeak.net Wed Aug 17 22:33:32 2005 From: jan at codespeak.net (jan at codespeak.net) Date: Wed, 17 Aug 2005 22:33:32 +0200 (CEST) Subject: [py-svn] r16118 - in py/dist/py/test/tkinter: . testing Message-ID: <20050817203332.6D37C27B7C@code1.codespeak.net> Author: jan Date: Wed Aug 17 22:33:30 2005 New Revision: 16118 Modified: py/dist/py/test/tkinter/backend.py py/dist/py/test/tkinter/testing/test_backend.py py/dist/py/test/tkinter/testing/test_capture_out_err.py Log: - close channel on the remote side - enable tests again Modified: py/dist/py/test/tkinter/backend.py ============================================================================== --- py/dist/py/test/tkinter/backend.py (original) +++ py/dist/py/test/tkinter/backend.py Wed Aug 17 22:33:30 2005 @@ -198,6 +198,8 @@ args, tests = channel.receive() remote(channel, tests = tests, args = args) + # why? + channel.close() ''') self.channel.send((args, tests)) self.waitfinish_thread = threading.Thread(target = waitfinish, args = (self.channel,)) Modified: py/dist/py/test/tkinter/testing/test_backend.py ============================================================================== --- py/dist/py/test/tkinter/testing/test_backend.py (original) +++ py/dist/py/test/tkinter/testing/test_backend.py Wed Aug 17 22:33:30 2005 @@ -178,13 +178,13 @@ assert l[0] is None def test_start_tests(self): - py.test.skip("XXX this test does not work after execnet merge") config, args = py.test.Config.parse([]) self.backend.start_tests(config = config, args = [str(datadir / 'filetest.py')], tests = []) while self.backend.running: self.backend.update() + self.backend.update() store = self.backend.get_store() assert store._repository.find(['py', 'test', Modified: py/dist/py/test/tkinter/testing/test_capture_out_err.py ============================================================================== --- py/dist/py/test/tkinter/testing/test_capture_out_err.py (original) +++ py/dist/py/test/tkinter/testing/test_capture_out_err.py Wed Aug 17 22:33:30 2005 @@ -5,7 +5,6 @@ datadir = py.magic.autopath().dirpath('data') def test_capture_out_err(): - py.test.skip("XXX needs fixing after execnet merge") config, args = py.test.Config.parse([]) backend = ReportBackend() backend.start_tests(config = config, @@ -13,6 +12,7 @@ tests = []) while backend.running: backend.update() + backend.update() store = backend.get_store() assert len(store.get(failed = True)) == 1 failed = store.get(failed = True)[0] From jan at codespeak.net Thu Aug 18 00:10:27 2005 From: jan at codespeak.net (jan at codespeak.net) Date: Thu, 18 Aug 2005 00:10:27 +0200 (CEST) Subject: [py-svn] r16121 - in py/dist/py/test: . testing Message-ID: <20050817221027.7C30427B80@code1.codespeak.net> Author: jan Date: Thu Aug 18 00:10:25 2005 New Revision: 16121 Modified: py/dist/py/test/collect.py py/dist/py/test/item.py py/dist/py/test/testing/test_collect.py Log: issue16 ensure right order of generative tests Modified: py/dist/py/test/collect.py ============================================================================== --- py/dist/py/test/collect.py (original) +++ py/dist/py/test/collect.py Thu Aug 18 00:10:25 2005 @@ -361,7 +361,7 @@ if not callable(call): raise TypeError("yielded test %r not callable" %(call,)) name = "[%d]" % i - d[name] = self.Function(name, self, args, obj=call) + d[name] = self.Function(name, self, args, obj=call, sort_value = i) return d def getcallargs(self, obj): Modified: py/dist/py/test/item.py ============================================================================== --- py/dist/py/test/item.py (original) +++ py/dist/py/test/item.py Thu Aug 18 00:10:25 2005 @@ -40,20 +40,22 @@ def finishcapture(self): if hasattr(self, '_capture'): capture = self._capture - del self._capture + del self._capture self.captured_out, self.captured_err = capture.reset() + class Function(Item): """ a Function Item is responsible for setting up and executing a Python callable test object. """ state = SetupState() - def __init__(self, name, parent, args=(), obj=_dummy): + def __init__(self, name, parent, args=(), obj=_dummy, sort_value = None): super(Function, self).__init__(name, parent) self.args = args if obj is not _dummy: self._obj = obj - + self.sort_value = sort_value + def __repr__(self): return "<%s %r>" %(self.__class__.__name__, self.name) @@ -62,7 +64,9 @@ return code.path, code.firstlineno def getsortvalue(self): - return self.getpathlineno() + if self.sort_value is None: + return self.getpathlineno() + return self.sort_value def run(self): self.state.prepare(self) 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 Thu Aug 18 00:10:25 2005 @@ -187,3 +187,46 @@ assert len(l) == 2 finally: old.chdir() + + +def test_order_of_execution_generator_same_codeline(): + test_list = [] + expected_list = range(6) + + def list_append(item): + test_list.append(item) + + def assert_order_of_execution(): + print 'expected order', expected_list + print 'but got ', test_list + assert test_list == expected_list + + for i in expected_list: + yield list_append, i + yield assert_order_of_execution + + + +def test_order_of_execution_generator_different_codeline(): + test_list = [] + expected_list = range(3) + + def list_append_2(): + test_list.append(2) + + def list_append_1(): + test_list.append(1) + + def list_append_0(): + test_list.append(0) + + def assert_order_of_execution(): + print 'expected order', expected_list + print 'but got ', test_list + assert test_list == expected_list + + yield list_append_0 + yield list_append_1 + yield list_append_2 + yield assert_order_of_execution + From hpk at codespeak.net Mon Aug 22 18:32:00 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 22 Aug 2005 18:32:00 +0200 (CEST) Subject: [py-svn] r16220 - py/dist/py/documentation Message-ID: <20050822163200.F394627B41@code1.codespeak.net> Author: hpk Date: Mon Aug 22 18:32:00 2005 New Revision: 16220 Modified: py/dist/py/documentation/conftest.py Log: try harder to verify references even for non-html files Modified: py/dist/py/documentation/conftest.py ============================================================================== --- py/dist/py/documentation/conftest.py (original) +++ py/dist/py/documentation/conftest.py Mon Aug 22 18:32:00 2005 @@ -140,8 +140,9 @@ anchor = '' fn = path.dirpath(tryfn) ishtml = fn.ext == '.html' - fn = fn.new(ext='.txt') - if not ishtml or not fn.check(file=1): + fn = ishtml and fn.new(ext='.txt') or fn + print "filename is", fn + if not fn.check(): # not ishtml or not fn.check(): py.test.fail("reference error %r in %s:%d" %( tryfn, path.basename, lineno+1)) if anchor: From hpk at codespeak.net Mon Aug 22 20:17:00 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 22 Aug 2005 20:17:00 +0200 (CEST) Subject: [py-svn] r16230 - py/dist/py/path/svn Message-ID: <20050822181700.EC3F127B41@code1.codespeak.net> Author: hpk Date: Mon Aug 22 20:17:00 2005 New Revision: 16230 Modified: py/dist/py/path/svn/wccommand.py Log: ignore externals by default when performing wcpath.status() and raise an error if one requests it for now. Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Mon Aug 22 20:17:00 2005 @@ -149,15 +149,22 @@ def rename(self, target): py.process.cmdexec("svn move --force %s %s" %(str(self), str(target))) - def status(self, updates=0, rec=0): + 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 # 2201 2192 jum test + # XXX + if externals: + raise ValueError("XXX cannot perform status() " + "on external items yet") if rec: rec= '' else: rec = '--non-recursive' + if not externals: + externals = '--ignore-externals' + if updates: updates = '-u' else: @@ -165,7 +172,7 @@ update_rev = None - out = self._svn('status -v %s %s' % (updates, rec)) + 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'): From hpk at codespeak.net Mon Aug 22 22:15:49 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 22 Aug 2005 22:15:49 +0200 (CEST) Subject: [py-svn] r16238 - py/dist/py/documentation Message-ID: <20050822201549.8C40627B41@code1.codespeak.net> Author: hpk Date: Mon Aug 22 22:15:48 2005 New Revision: 16238 Modified: py/dist/py/documentation/conftest.py Log: skip rest-processing by default for .txt where we have a newer html file. With "--forcegen" html-generation can be forced though. Modified: py/dist/py/documentation/conftest.py ============================================================================== --- py/dist/py/documentation/conftest.py (original) +++ py/dist/py/documentation/conftest.py Mon Aug 22 22:15:48 2005 @@ -7,6 +7,10 @@ Option('-R', '--checkremote', action="store_true", dest="checkremote", default=False, help="check remote links in ReST files" + ), + Option('', '--forcegen', + action="store_true", dest="forcegen", default=False, + help="force generation of html files even if they appear up-to-date" ) ) @@ -17,6 +21,7 @@ py.test.skip("docutils not importable") def restcheck(path): + _checkskip(path.localpath) checkdocutils() import docutils.utils @@ -34,9 +39,18 @@ # we assume docutils printed info on stdout py.test.fail("docutils processing failed, see captured stderr") +def _checkskip(lpath): + if not option.forcegen: + if lpath.ext == '.txt': + htmlpath = lpath.new(ext='.html') + if htmlpath.check(file=1) and htmlpath.mtime() >= lpath.mtime(): + py.test.skip("html file is up to date, use --forcegen to regenerate") + #return [] # no need to rebuild + class ReSTSyntaxTest(py.test.Item): - def run(self): + def run(self): mypath = self.fspath + _checkskip(mypath) restcheck(py.path.svnwc(mypath)) class DoctestText(py.test.Item): @@ -165,10 +179,7 @@ # ___________________________________________________________ # -# hooking into py.test collector's chain ... -# because we generate subtests for all link checks -# it is a bit more convoluted than is strictly neccessary -# to perform the tests +# hooking into py.test Directory collector's chain ... class DocDirectory(py.test.collect.Directory): ReSTChecker = ReSTChecker From hpk at codespeak.net Tue Aug 23 10:12:25 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Tue, 23 Aug 2005 10:12:25 +0200 (CEST) Subject: [py-svn] r16241 - in py/dist/py: . bin documentation misc/testing path path/extpy path/extpy/testing path/local path/local/testing path/svn path/testing test test/terminal test/testing test/tkinter Message-ID: <20050823081225.CCC2427B3F@code1.codespeak.net> Author: hpk Date: Tue Aug 23 10:12:13 2005 New Revision: 16241 Added: py/dist/py/test/deprecate.py (contents, props changed) py/dist/py/test/testing/test_deprecated.py (contents, props changed) Removed: py/dist/py/test/testing/test_api.py Modified: py/dist/py/__init__.py py/dist/py/bin/py.cleanup py/dist/py/bin/py.countloc py/dist/py/bin/py.lookup py/dist/py/bin/py.rest py/dist/py/documentation/test.txt py/dist/py/misc/testing/test_initpkg.py py/dist/py/path/common.py py/dist/py/path/extpy/extpy.py py/dist/py/path/extpy/testing/test_extpy.py py/dist/py/path/local/local.py py/dist/py/path/local/posix.py py/dist/py/path/local/testing/test_posix.py py/dist/py/path/svn/svncommon.py py/dist/py/path/svn/wccommand.py py/dist/py/path/testing/common.py py/dist/py/path/testing/fscommon.py py/dist/py/path/testing/test_api.py py/dist/py/test/item.py py/dist/py/test/terminal/remote.py py/dist/py/test/testing/test_collect.py py/dist/py/test/tkinter/util.py Log: - add a new py.test.deprecated_call method to test if a given callable with args/kwargs produces a deprecation warning. - deprecate py.path.checker(...) use functions or lambda x: x.check(...) instead - deprecate py.path.X().get(commaseparatestring) in favour of using the 'basename', 'purebasename' etc.pp. attributes directly. Modified: py/dist/py/__init__.py ============================================================================== --- py/dist/py/__init__.py (original) +++ py/dist/py/__init__.py Tue Aug 23 10:12:13 2005 @@ -23,10 +23,10 @@ # helpers for use from test functions or collectors 'test.raises' : ('./test/raises.py', 'raises'), + 'test.deprecated_call' : ('./test/deprecate.py', 'deprecated_call'), 'test.skip' : ('./test/item.py', 'skip'), 'test.fail' : ('./test/item.py', 'fail'), 'test.exit' : ('./test/session.py', 'exit'), - 'test.skip_on_error' : ('./test/item.py', 'skip_on_error'), 'test.compat.TestCase' : ('./test/compat.py', 'TestCase'), # configuration/initialization related test api @@ -62,9 +62,9 @@ 'path.svnurl' : ('./path/svn/urlcommand.py', 'SvnCommandPath'), 'path.local' : ('./path/local/local.py', 'LocalPath'), 'path.extpy' : ('./path/extpy/extpy.py', 'Extpy'), - 'path.checker' : ('./path/common.py', 'checker'), + 'path.checker' : ('./path/common.py', 'checker'), # deprecated - # some nice more or less magic APIs + # some nice slightly magic APIs 'magic.greenlet' : ('./magic/greenlet.py', 'greenlet'), 'magic.invoke' : ('./magic/invoke.py', 'invoke'), 'magic.revoke' : ('./magic/invoke.py', 'revoke'), @@ -74,7 +74,7 @@ 'magic.View' : ('./magic/viewtype.py', 'View'), 'magic.AssertionError' : ('./magic/assertion.py', 'AssertionError'), - # generalized inspection API + # python inspection/code-generation API 'code.compile' : ('./code/source.py', 'compile_'), 'code.Source' : ('./code/source.py', 'Source'), 'code.Code' : ('./code/code.py', 'Code'), @@ -116,6 +116,7 @@ 'log.STDOUT' : ('./log/consumer.py', 'STDOUT'), 'log.STDERR' : ('./log/consumer.py', 'STDERR'), + # compatibility modules (taken from 2.4.1) 'compat.doctest' : ('./compat/doctest.py', '*'), 'compat.optparse' : ('./compat/optparse.py', '*'), 'compat.textwrap' : ('./compat/textwrap.py', '*'), Modified: py/dist/py/bin/py.cleanup ============================================================================== --- py/dist/py/bin/py.cleanup (original) +++ py/dist/py/bin/py.cleanup Tue Aug 23 10:12:13 2005 @@ -8,5 +8,5 @@ else: path = py.path.local() print "cleaning path", path -for x in path.visit('*.pyc', py.path.checker(dotfile=0)): +for x in path.visit('*.pyc', lambda x: x.check(dotfile=0)): x.remove() Modified: py/dist/py/bin/py.countloc ============================================================================== --- py/dist/py/bin/py.countloc (original) +++ py/dist/py/bin/py.countloc Tue Aug 23 10:12:13 2005 @@ -29,8 +29,11 @@ args = ['.'] locations = [py.path.local(x) for x in args] + def nodot(p): + return p.check(dotfile=0) + for loc in locations: - for x in loc.visit('*.py', py.path.checker(dotfile=0)): + for x in loc.visit('*.py', nodot): bn = x.basename if bn.startswith('test_') or bn.endswith('_test.py'): testcounter.count(x) Modified: py/dist/py/bin/py.lookup ============================================================================== --- py/dist/py/bin/py.lookup (original) +++ py/dist/py/bin/py.lookup Tue Aug 23 10:12:13 2005 @@ -5,7 +5,10 @@ string = py.std.sys.argv[1] curdir = py.path.local() -for x in curdir.visit('*.py', py.path.checker(dotfile=0)): +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() Modified: py/dist/py/bin/py.rest ============================================================================== --- py/dist/py/bin/py.rest (original) +++ py/dist/py/bin/py.rest Tue Aug 23 10:12:13 2005 @@ -27,9 +27,12 @@ if not p.check(): log("path %s not found, ignoring" % p) continue + def fil(p): + return p.check(fnmatch='*.txt', versioned=True) + def rec(p): + return p.check(dotfile=0) if p.check(dir=1): - for x in p.visit(fil=py.path.checker(fnmatch='*.txt', versioned=True), - rec=py.path.checker(dotfile=0)): + for x in p.visit(fil, rec): rest.process(x) elif p.check(file=1): rest.process(p) Modified: py/dist/py/documentation/test.txt ============================================================================== --- py/dist/py/documentation/test.txt (original) +++ py/dist/py/documentation/test.txt Tue Aug 23 10:12:13 2005 @@ -224,6 +224,13 @@ def test_xxx(self): ... +testing for deprecated APIs +------------------------------ + +In your tests you can use ``py.test.deprecated_call(func, *args, **kwargs)`` +to test that a particular function call triggers a DeprecationWarning. +This is useful for testing phasing out of old APIs in your projects. + Managing test state across test modules, classes and methods ------------------------------------------------------------ Modified: py/dist/py/misc/testing/test_initpkg.py ============================================================================== --- py/dist/py/misc/testing/test_initpkg.py (original) +++ py/dist/py/misc/testing/test_initpkg.py Tue Aug 23 10:12:13 2005 @@ -51,7 +51,7 @@ base.join('execnet', 'script'), base.join('compat'), ) - for p in base.visit('*.py', py.path.checker(dotfile=0)): + for p in base.visit('*.py', lambda x: x.check(dotfile=0)): relpath = p.new(ext='').relto(base) if base.sep in relpath: # not py/*.py itself for x in nodirs: Modified: py/dist/py/path/common.py ============================================================================== --- py/dist/py/path/common.py (original) +++ py/dist/py/path/common.py Tue Aug 23 10:12:13 2005 @@ -17,7 +17,13 @@ return True class checker: + """ deprecated: return checker callable checking for the given + kwargs-specified specification. + """ def __init__(self, **kwargs): + py.std.warnings.warn("py.path.checker is deprecated, construct " + "calls to pathobj.check() instead", + DeprecationWarning) self.kwargs = kwargs def __call__(self, p): return p.check(**self.kwargs) @@ -109,7 +115,7 @@ return p.check() def basename(self): - return self.get('basename')[0] + return self._getbyspec('basename')[0] basename = property(basename, None, None, 'basename part of path') def relto(self, relpath): @@ -165,6 +171,12 @@ def __repr__(self): return repr(str(self)) + def get(self, spec): + """ deprecated, use _getbyspec if you really need it. """ + py.std.warnings.warn("path.get() is deprecated", + DeprecationWarning) + return self._getbyspec(spec) + def visit(self, fil=None, rec=None, ignore=_dummyclass): if isinstance(fil, str): fil = fnmatch(fil) @@ -273,11 +285,11 @@ return self.new(basename='').join(*args, **kwargs) def ext(self): - return self.get('ext')[0] + return self._getbyspec('ext')[0] ext = property(ext, None, None, 'extension part of path') def purebasename(self): - return self.get('purebasename')[0] + return self._getbyspec('purebasename')[0] purebasename = property(purebasename, None, None, 'basename without extension') def read(self, mode='rb'): Modified: py/dist/py/path/extpy/extpy.py ============================================================================== --- py/dist/py/path/extpy/extpy.py (original) +++ py/dist/py/path/extpy/extpy.py Tue Aug 23 10:12:13 2005 @@ -72,7 +72,7 @@ return cls(self.root, kw['basename']) return cls(self.root, self.modpath) - def get(self, spec): + def _getbyspec(self, spec): l = [] modparts = self.modpath.split(self.sep) for name in spec.split(','): @@ -108,7 +108,7 @@ def listdir(self, fil=None, sort=True, **kw): if kw: if fil is None: - fil = py.path.checker(**kw) + fil = lambda x: x.check(**kw) else: raise TypeError, "cannot take filter and keyword arguments" elif isinstance(fil, str): Modified: py/dist/py/path/extpy/testing/test_extpy.py ============================================================================== --- py/dist/py/path/extpy/testing/test_extpy.py (original) +++ py/dist/py/path/extpy/testing/test_extpy.py Tue Aug 23 10:12:13 2005 @@ -48,7 +48,7 @@ assert l[0] == path def test_visit(self): - l = list(self.root.visit(py.path.checker(basename='borgfunc'))) + l = list(self.root.visit(lambda x: x.basename == 'borgfunc')) assert len(l) == 1 obj = l[0] assert str(obj).endswith('Nested.Class.borgfunc') Modified: py/dist/py/path/local/local.py ============================================================================== --- py/dist/py/path/local/local.py (original) +++ py/dist/py/path/local/local.py Tue Aug 23 10:12:13 2005 @@ -85,7 +85,7 @@ |--| ext """ obj = object.__new__(self.__class__) - drive, dirname, basename, purebasename,ext = self.get( + drive, dirname, basename, purebasename,ext = self._getbyspec( "drive,dirname,basename,purebasename,ext") if 'basename' in kw: if 'purebasename' in kw or 'ext' in kw: @@ -108,7 +108,7 @@ "%(drive)s%(dirname)s%(sep)s%(basename)s" % kw) return obj - def get(self, spec): + def _getbyspec(self, spec): """ return a sequence of specified path parts. 'spec' is a comma separated string containing path part names. according to the following convention: Modified: py/dist/py/path/local/posix.py ============================================================================== --- py/dist/py/path/local/posix.py (original) +++ py/dist/py/path/local/posix.py Tue Aug 23 10:12:13 2005 @@ -51,7 +51,7 @@ uid = getuserid(user) gid = getgroupid(group) if rec: - for x in self.visit(rec=py.path.checker(link=0)): + for x in self.visit(rec=lambda x: x.check(link=0)): if x.check(link=0): self._callex(os.chown, str(x), uid, gid) self._callex(os.chown, str(self), uid, gid) Modified: py/dist/py/path/local/testing/test_posix.py ============================================================================== --- py/dist/py/path/local/testing/test_posix.py (original) +++ py/dist/py/path/local/testing/test_posix.py Tue Aug 23 10:12:13 2005 @@ -54,7 +54,7 @@ tmpdir = self.tmpdir linkpath = tmpdir.join('test') linkpath.mksymlinkto(tmpdir) - visitor = tmpdir.visit(None, py.path.checker(link=0)) + visitor = tmpdir.visit(None, lambda x: x.check(link=0)) assert list(visitor) == [linkpath] def test_symlink_isdir(self): @@ -138,7 +138,7 @@ def test_chmod_rec_int(self): # XXX fragile test print "self.root is", self.root - recfilter = py.path.checker(dotfile=0, link=0) + recfilter = lambda x: x.check(dotfile=0, link=0) oldmodes = {} for x in self.root.visit(rec=recfilter): oldmodes[x] = x.mode() Modified: py/dist/py/path/svn/svncommon.py ============================================================================== --- py/dist/py/path/svn/svncommon.py (original) +++ py/dist/py/path/svn/svncommon.py Tue Aug 23 10:12:13 2005 @@ -5,6 +5,18 @@ import py from py.__.path import common + +# XXX this helper not used yet (but should be for testing +# if the underlying svn binary supports certain features) +def _getsvnversion(ver=[]): + try: + return ver[0] + except: + v = py.process.cmdexec("svn -q --version") + v.strip() + ver.append(v) + return v + #_______________________________________________________________ class SvnPathBase(common.FSPathBase): @@ -35,7 +47,7 @@ """ obj = object.__new__(self.__class__) obj.rev = kw.get('rev', self.rev) - dirname, basename, purebasename, ext = self.get( + dirname, basename, purebasename, ext = self._getbyspec( "dirname,basename,purebasename,ext") if 'basename' in kw: if 'purebasename' in kw or 'ext' in kw: @@ -55,7 +67,7 @@ obj.strpath = "%(dirname)s" % kw return obj - def get(self, spec): + def _getbyspec(self, spec): """ get specified parts of the path. 'arg' is a string with comma separated path parts. The parts are returned in exactly the order of the specification. Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Tue Aug 23 10:12:13 2005 @@ -157,13 +157,16 @@ if externals: raise ValueError("XXX cannot perform status() " "on external items yet") + else: + externals = '' if rec: rec= '' else: rec = '--non-recursive' - if not externals: - externals = '--ignore-externals' + # XXX does not work on all subversion versions + #if not externals: + # externals = '--ignore-externals' if updates: updates = '-u' @@ -368,8 +371,8 @@ def open(self, mode='r'): return open(self.strpath, mode) - def get(self, spec): - return self.localpath.get(spec) + def _getbyspec(self, spec): + return self.localpath._getbyspec(spec) class Checkers(py.path.local.Checkers): def __init__(self, path): Modified: py/dist/py/path/testing/common.py ============================================================================== --- py/dist/py/path/testing/common.py (original) +++ py/dist/py/path/testing/common.py Tue Aug 23 10:12:13 2005 @@ -4,6 +4,9 @@ class CommonPathTests: root = None # subclasses have to setup a 'root' attribute + def test_get_deprecation(self): + py.test.deprecated_call(self.root.get, "basename") + def test_constructor_equality(self): p = self.root.__class__(self.root) assert p == self.root Modified: py/dist/py/path/testing/fscommon.py ============================================================================== --- py/dist/py/path/testing/fscommon.py (original) +++ py/dist/py/path/testing/fscommon.py Tue Aug 23 10:12:13 2005 @@ -1,8 +1,6 @@ import py from py.__.path.testing import common -checker = py.path.checker - def setuptestfs(path): if path.join('samplefile').check(): return @@ -60,7 +58,7 @@ def test_multiple_parts(self): newpath = self.root.join('samplefile.py') - dirname, purebasename, basename, ext = newpath.get( + dirname, purebasename, basename, ext = newpath._getbyspec( 'dirname,purebasename,basename,ext') assert str(self.root).endswith(dirname) # be careful with win32 'drive' assert purebasename == 'samplefile' @@ -123,7 +121,7 @@ def test_visit_filesonly(self): l = [] - for i in self.root.visit(checker(file=1)): + for i in self.root.visit(lambda x: x.check(file=1)): l.append(i.relto(self.root)) assert not "sampledir" in l assert self.root.sep.join(["sampledir", "otherfile"]) in l @@ -136,14 +134,15 @@ def test_visit_nodotfiles(self): l = [] - for i in self.root.visit(checker(dotfile=0)): + for i in self.root.visit(lambda x: x.check(dotfile=0)): l.append(i.relto(self.root)) assert "sampledir" in l assert self.root.sep.join(["sampledir", "otherfile"]) in l assert not ".dotfile" in l def test_endswith(self): - chk = checker(endswith='pickle') + def chk(p): + return p.check(endswith="pickle") assert not chk(self.root) assert not chk(self.root.join('samplefile')) assert chk(self.root.join('somepickle')) Modified: py/dist/py/path/testing/test_api.py ============================================================================== --- py/dist/py/path/testing/test_api.py (original) +++ py/dist/py/path/testing/test_api.py Tue Aug 23 10:12:13 2005 @@ -13,6 +13,9 @@ y = eval(r) assert y == p + def test_deprecated_checker(self): + py.test.deprecated_call(py.path.checker) + def test_defaultlocal(self): p = path.local() assert hasattr(p, 'atime') Added: py/dist/py/test/deprecate.py ============================================================================== --- (empty file) +++ py/dist/py/test/deprecate.py Tue Aug 23 10:12:13 2005 @@ -0,0 +1,36 @@ +import py + +def deprecated_call(func, *args, **kwargs): + """ assert that calling func(*args, **kwargs) + triggers a DeprecationWarning. + """ + oldfilters = py.std.warnings.filters[:] + onceregistry = py.std.warnings.onceregistry.copy() + try: + py.std.warnings.onceregistry.clear() + py.std.warnings.filterwarnings("error", category=DeprecationWarning) + try: + _ = func(*args, **kwargs) + except DeprecationWarning: + pass + else: + print __warningregistry__ + raise AssertionError("%s not deprecated" % (func,)) + finally: + py.std.warnings.filters[:] = oldfilters + py.std.warnings.onceregistry.clear() + py.std.warnings.onceregistry.update(onceregistry) + +def deprecated_call(func, *args, **kwargs): + l = [] + oldwarn = py.std.warnings.warn_explicit + def warn_explicit(*args, **kwargs): + l.append(args) + oldwarn(*args, **kwargs) + + py.magic.patch(py.std.warnings, 'warn_explicit', warn_explicit) + try: + _ = func(*args, **kwargs) + finally: + py.magic.revert(py.std.warnings, 'warn_explicit') + assert l Modified: py/dist/py/test/item.py ============================================================================== --- py/dist/py/test/item.py (original) +++ py/dist/py/test/item.py Tue Aug 23 10:12:13 2005 @@ -106,16 +106,6 @@ __tracebackhide__ = True raise py.test.Item.Skipped(msg=msg) -def skip_on_error(func, *args, **kwargs): - """ skip test if the given call fails. """ - __tracebackhide__ = True - try: - return func(*args, **kwargs) - except Exception, e: - s = py.code.ExceptionInfo().exconly() - name = getattr(func, '__name__', func) - py.test.skip("%s(...) -> %s" %(name, s.rstrip(), )) - def fail(msg="unknown failure"): """ fail with the given Message. """ __tracebackhide__ = True Modified: py/dist/py/test/terminal/remote.py ============================================================================== --- py/dist/py/test/terminal/remote.py (original) +++ py/dist/py/test/terminal/remote.py Tue Aug 23 10:12:13 2005 @@ -7,8 +7,9 @@ """ wait until project files are changed. """ def fil(p): return p.ext in ('.py', '.c', '.h') - #fil = py.path.checker(fnmatch='*.py') - rec = py.path.checker(dotfile=0) + #fil = lambda x: x.check(fnmatch='*.py') + def rec(p): + return p.check(dotfile=0) changed = False for path in rootdir.visit(fil, rec): oldstat = statcache.get(path, None) Deleted: /py/dist/py/test/testing/test_api.py ============================================================================== --- /py/dist/py/test/testing/test_api.py Tue Aug 23 10:12:13 2005 +++ (empty file) @@ -1,16 +0,0 @@ - -import py - -def test_skipfailure(): - def f(): - raise ValueError() - excinfo = py.test.raises( - py.test.Item.Skipped, - "py.test.skip_on_error(f)") - print excinfo - assert str(excinfo).find("ValueError") != -1 - -def test_skip_on_error_with_no_failure(): - def f(): - return 42 - assert py.test.skip_on_error(f) == 42 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 Tue Aug 23 10:12:13 2005 @@ -49,7 +49,8 @@ def test_failing_import_directory(): class MyDirectory(py.test.collect.Directory): - filefilter = py.path.checker(fnmatch='testspecial*.py') + def filefilter(self, p): + return p.check(fnmatch='testspecial*.py') mydir = MyDirectory(datadir) l = mydir.run() assert len(l) == 1 Added: py/dist/py/test/testing/test_deprecated.py ============================================================================== --- (empty file) +++ py/dist/py/test/testing/test_deprecated.py Tue Aug 23 10:12:13 2005 @@ -0,0 +1,35 @@ +import py + +def dep(i): + if i == 0: + py.std.warnings.warn("is deprecated", DeprecationWarning) + +reg = {} +def dep_explicit(i): + if i == 0: + py.std.warnings.warn_explicit("dep_explicit", category=DeprecationWarning, + filename="hello", lineno=3) + +def test_deprecated_call_raises(): + py.test.raises(AssertionError, + "py.test.deprecated_call(dep, 3)") + +def test_deprecated_call(): + py.test.deprecated_call(dep, 0) + +def test_deprecated_call_preserves(): + r = py.std.warnings.onceregistry.copy() + f = py.std.warnings.filters[:] + test_deprecated_call_raises() + test_deprecated_call() + assert r == py.std.warnings.onceregistry + assert f == py.std.warnings.filters + +def test_deprecated_explicit_call_raises(): + py.test.raises(AssertionError, + "py.test.deprecated_call(dep_explicit, 3)") + +def test_deprecated_explicit_call(): + py.test.deprecated_call(dep_explicit, 0) + py.test.deprecated_call(dep_explicit, 0) + Modified: py/dist/py/test/tkinter/util.py ============================================================================== --- py/dist/py/test/tkinter/util.py (original) +++ py/dist/py/test/tkinter/util.py Tue Aug 23 10:12:13 2005 @@ -263,9 +263,10 @@ def check_files(self): '''returns (changed files, deleted files)''' - fil = py.path.checker(fnmatch='[!.]*.py') - rec = py.path.checker(dotfile=0) - + def fil(p): + return p.check(fnmatch='[!.]*.py') + def rec(p): + return p.check(dotfile=0) files = [] for path in self.paths: if path.check(file=1): From hpk at codespeak.net Tue Aug 23 16:03:56 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Tue, 23 Aug 2005 16:03:56 +0200 (CEST) Subject: [py-svn] r16269 - py/dist/py/documentation Message-ID: <20050823140356.5B9AB27B41@code1.codespeak.net> Author: hpk Date: Tue Aug 23 16:03:55 2005 New Revision: 16269 Modified: py/dist/py/documentation/confrest.py py/dist/py/documentation/conftest.py Log: - look for confrest.py files in parent directories - allow stylesheets to be absolute URLs Modified: py/dist/py/documentation/confrest.py ============================================================================== --- py/dist/py/documentation/confrest.py (original) +++ py/dist/py/documentation/confrest.py Tue Aug 23 16:03:55 2005 @@ -94,7 +94,8 @@ encoding = self.encoding content = unicode(txtpath.read(), encoding) stylesheet = self.stylesheet - if not txtpath.dirpath(stylesheet).check(): + if not stylesheet.startswith('http') and \ + not txtpath.dirpath(stylesheet).check(): stylesheet = None content = convert_rest_html(content, txtpath, stylesheet=stylesheet, encoding=encoding) Modified: py/dist/py/documentation/conftest.py ============================================================================== --- py/dist/py/documentation/conftest.py (original) +++ py/dist/py/documentation/conftest.py Tue Aug 23 16:03:55 2005 @@ -26,10 +26,13 @@ import docutils.utils try: - confrest = path.localpath.dirpath('confrest.py') - if confrest.check(file=1): - confrest = confrest.pyimport() - confrest.Project().process(path) + cur = path.localpath + for x in cur.parts(reverse=True): + confrest = x.dirpath('confrest.py') + if confrest.check(file=1): + confrest = confrest.pyimport() + confrest.Project().process(path) + break else: # defer to default processor rest.process(path) From hpk at codespeak.net Thu Aug 25 18:14:19 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 25 Aug 2005 18:14:19 +0200 (CEST) Subject: [py-svn] r16514 - py/dist/py/path Message-ID: <20050825161419.E9C8F27B51@code1.codespeak.net> Author: hpk Date: Thu Aug 25 18:14:19 2005 New Revision: 16514 Modified: py/dist/py/path/common.py Log: show a more useful location for warning about deprecation Modified: py/dist/py/path/common.py ============================================================================== --- py/dist/py/path/common.py (original) +++ py/dist/py/path/common.py Thu Aug 25 18:14:19 2005 @@ -23,7 +23,7 @@ def __init__(self, **kwargs): py.std.warnings.warn("py.path.checker is deprecated, construct " "calls to pathobj.check() instead", - DeprecationWarning) + DeprecationWarning, stacklevel=2) self.kwargs = kwargs def __call__(self, p): return p.check(**self.kwargs) @@ -174,7 +174,7 @@ def get(self, spec): """ deprecated, use _getbyspec if you really need it. """ py.std.warnings.warn("path.get() is deprecated", - DeprecationWarning) + DeprecationWarning, stacklevel=2) return self._getbyspec(spec) def visit(self, fil=None, rec=None, ignore=_dummyclass): From hpk at codespeak.net Thu Aug 25 18:52:39 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 25 Aug 2005 18:52:39 +0200 (CEST) Subject: [py-svn] r16524 - py/dist/py/test Message-ID: <20050825165239.2A6E927B49@code1.codespeak.net> Author: hpk Date: Thu Aug 25 18:52:37 2005 New Revision: 16524 Modified: py/dist/py/test/cmdline.py Log: basically added Ian's suggestions of better error/warnings to the user. Modified: py/dist/py/test/cmdline.py ============================================================================== --- py/dist/py/test/cmdline.py (original) +++ py/dist/py/test/cmdline.py Thu Aug 25 18:52:37 2005 @@ -5,6 +5,7 @@ # def main(): + warn_about_missing_assertion() config, args = py.test.Config.parse(py.std.sys.argv[1:]) sessionclass = config.getsessionclass() session = sessionclass(config) @@ -15,7 +16,16 @@ except KeyboardInterrupt: if not config.option.verbose: print - print "KeyboardInterrupt" + print "KeyboardInterrupt (-v to see trackeback)" raise SystemExit, 2 else: raise + +def warn_about_missing_assertion(): + try: + assert False + except AssertionError: + pass + else: + py.std.warnings.warn("Assertions are turned off!" + " (are you using python -O?)") From lac at codespeak.net Thu Aug 25 19:05:06 2005 From: lac at codespeak.net (lac at codespeak.net) Date: Thu, 25 Aug 2005 19:05:06 +0200 (CEST) Subject: [py-svn] r16525 - py/dist/py/test Message-ID: <20050825170506.729DE27B4B@code1.codespeak.net> Author: lac Date: Thu Aug 25 19:05:05 2005 New Revision: 16525 Modified: py/dist/py/test/cmdline.py Log: typo Modified: py/dist/py/test/cmdline.py ============================================================================== --- py/dist/py/test/cmdline.py (original) +++ py/dist/py/test/cmdline.py Thu Aug 25 19:05:05 2005 @@ -16,7 +16,7 @@ except KeyboardInterrupt: if not config.option.verbose: print - print "KeyboardInterrupt (-v to see trackeback)" + print "KeyboardInterrupt (-v to see traceback)" raise SystemExit, 2 else: raise From hpk at codespeak.net Fri Aug 26 10:09:11 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 26 Aug 2005 10:09:11 +0200 (CEST) Subject: [py-svn] r16563 - in py/dist/py: bin misc/cmdline Message-ID: <20050826080911.0AB6C27B45@code1.codespeak.net> Author: hpk Date: Fri Aug 26 10:09:10 2005 New Revision: 16563 Added: py/dist/py/misc/cmdline/ py/dist/py/misc/cmdline/__init__.py (contents, props changed) py/dist/py/misc/cmdline/countloc.py - copied, changed from r16355, py/dist/py/bin/py.countloc Modified: py/dist/py/bin/py.countloc Log: refactor py.countloc to have more shareable code Modified: py/dist/py/bin/py.countloc ============================================================================== --- py/dist/py/bin/py.countloc (original) +++ py/dist/py/bin/py.countloc Fri Aug 26 10:09:10 2005 @@ -3,56 +3,6 @@ # hands on script to compute the non-empty Lines of Code # for tests and non-test code -import py -curdir = py.path.local() - - -class Filecounter: - def __init__(self): - self.counts = {} - - def count(self, fn, empty=False): - if empty: - s = len(p.readlines()) - else: - s = 0 - for i in fn.readlines(): - if i.strip(): - s += 1 - self.counts[fn] = s - -if __name__ == '__main__': - testcounter = Filecounter() - counter = Filecounter() - args = py.std.sys.argv[1:] - if not args: - args = ['.'] - locations = [py.path.local(x) for x in args] - - def nodot(p): - return p.check(dotfile=0) - - for loc in locations: - for x in loc.visit('*.py', nodot): - bn = x.basename - if bn.startswith('test_') or bn.endswith('_test.py'): - testcounter.count(x) - else: - counter.count(x) - numfiles = len(counter.counts) - numtestfiles = len(testcounter.counts) - numlines = sum(counter.counts.values()) - numtestlines = sum(testcounter.counts.values()) - - #for x,y in counter.counts.items(): - # print "%3d %30s" % (y,x) - - items = counter.counts.items() - items.sort(lambda x,y: cmp(x[1], y[1])) - for x, y in items: - print "%3d %30s" % (y,x) - - print "%30s %3d" %("number of testfiles", numtestfiles) - print "%30s %3d" %("number of testlines", numtestlines) - print "%30s %3d" %("number of files", numfiles) - print "%30s %3d" %("number of lines", numlines) +from _findpy import py +from py.__.misc.cmdline.countloc import countloc +countloc() Added: py/dist/py/misc/cmdline/__init__.py ============================================================================== --- (empty file) +++ py/dist/py/misc/cmdline/__init__.py Fri Aug 26 10:09:10 2005 @@ -0,0 +1 @@ +# Copied: py/dist/py/misc/cmdline/countloc.py (from r16355, py/dist/py/bin/py.countloc) ============================================================================== --- py/dist/py/bin/py.countloc (original) +++ py/dist/py/misc/cmdline/countloc.py Fri Aug 26 10:09:10 2005 @@ -4,55 +4,78 @@ # for tests and non-test code import py + + curdir = py.path.local() -class Filecounter: +def nodot(p): + return p.check(dotfile=0) + +class FileCounter(object): def __init__(self): - self.counts = {} + self.file2numlines = {} + self.numlines = 0 + self.numfiles = 0 + + def addrecursive(self, directory, fil="*.py", rec=nodot): + for x in directory.visit(fil, rec): + self.addfile(x) - def count(self, fn, empty=False): - if empty: + def addfile(self, fn, emptylines=False): + if emptylines: s = len(p.readlines()) else: s = 0 for i in fn.readlines(): if i.strip(): s += 1 - self.counts[fn] = s + self.file2numlines[fn] = s + self.numfiles += 1 + self.numlines += s + + def getnumlines(self, fil): + numlines = 0 + for path, value in self.file2numlines.items(): + if fil(path): + numlines += value + return numlines + + def getnumfiles(self, fil): + numfiles = 0 + for path in self.file2numlines: + if fil(path): + numfiles += 1 + return numfiles -if __name__ == '__main__': - testcounter = Filecounter() - counter = Filecounter() +def countloc(): + counter = FileCounter() args = py.std.sys.argv[1:] if not args: args = ['.'] locations = [py.path.local(x) for x in args] - def nodot(p): - return p.check(dotfile=0) - for loc in locations: - for x in loc.visit('*.py', nodot): - bn = x.basename - if bn.startswith('test_') or bn.endswith('_test.py'): - testcounter.count(x) - else: - counter.count(x) - numfiles = len(counter.counts) - numtestfiles = len(testcounter.counts) - numlines = sum(counter.counts.values()) - numtestlines = sum(testcounter.counts.values()) + counter.addrecursive(loc, '*.py', rec=nodot) + + def istestfile(p): + return p.check(fnmatch='test_*.py') + isnottestfile = lambda x: not istestfile(x) + + numfiles = counter.getnumfiles(isnottestfile) + numlines = counter.getnumlines(isnottestfile) + numtestfiles = counter.getnumfiles(istestfile) + numtestlines = counter.getnumlines(istestfile) #for x,y in counter.counts.items(): # print "%3d %30s" % (y,x) - items = counter.counts.items() + items = counter.file2numlines.items() items.sort(lambda x,y: cmp(x[1], y[1])) for x, y in items: print "%3d %30s" % (y,x) print "%30s %3d" %("number of testfiles", numtestfiles) - print "%30s %3d" %("number of testlines", numtestlines) + print "%30s %3d" %("number of non-empty testlines", numtestlines) print "%30s %3d" %("number of files", numfiles) - print "%30s %3d" %("number of lines", numlines) + print "%30s %3d" %("number of non-empty lines", numlines) From hpk at codespeak.net Fri Aug 26 17:38:40 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 26 Aug 2005 17:38:40 +0200 (CEST) Subject: [py-svn] r16644 - py/dist/py Message-ID: <20050826153840.29B7C27B69@code1.codespeak.net> Author: hpk Date: Fri Aug 26 17:38:39 2005 New Revision: 16644 Added: py/dist/py/LICENSE Log: a rough LICENSE file describing - suprise - licensing and copyright holders for the py lib. It's not very exact but a start. Added: py/dist/py/LICENSE ============================================================================== --- (empty file) +++ py/dist/py/LICENSE Fri Aug 26 17:38:39 2005 @@ -0,0 +1,18 @@ +py lib Copyright holders, 2003-2005 +======================================= + +Except when otherwise stated (look for LICENSE files or information at +the beginning of each file) the files in the 'py' directory are +copyrighted by one or more of the following people and organizations: + + Holger Krekel + merlinux GmbH, Germany + Armin Rigo + Jan Balster + +Contributors include:: + + Ian Bicking + Grig Gheorghiu + Bob Ippolito + From hpk at codespeak.net Sat Aug 27 12:50:27 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 27 Aug 2005 12:50:27 +0200 (CEST) Subject: [py-svn] r16733 - py/dist/py/path/svn Message-ID: <20050827105027.0688127B56@code1.codespeak.net> Author: hpk Date: Sat Aug 27 12:50:26 2005 New Revision: 16733 Modified: py/dist/py/path/svn/wccommand.py Log: add switch command (XXX more specific tests need to be done for svnwc's) Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Sat Aug 27 12:50:26 2005 @@ -76,6 +76,10 @@ raise return out + def switch(self, url): + """ checkout from url to local wcpath. """ + self._svn('switch', url) + def checkout(self, url=None, rev = None): """ checkout from url to local wcpath. """ if url is None: From hpk at codespeak.net Sat Aug 27 13:05:39 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sat, 27 Aug 2005 13:05:39 +0200 (CEST) Subject: [py-svn] r16738 - py/dist/py/path/svn Message-ID: <20050827110539.542A227B56@code1.codespeak.net> Author: hpk Date: Sat Aug 27 13:05:39 2005 New Revision: 16738 Modified: py/dist/py/path/svn/wccommand.py Log: fix docstring Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Sat Aug 27 13:05:39 2005 @@ -77,7 +77,7 @@ return out def switch(self, url): - """ checkout from url to local wcpath. """ + """ switch to given URL. """ self._svn('switch', url) def checkout(self, url=None, rev = None): From hpk at codespeak.net Sun Aug 28 12:25:51 2005 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sun, 28 Aug 2005 12:25:51 +0200 (CEST) Subject: [py-svn] r16976 - py/dist/py/documentation Message-ID: <20050828102551.4ACD127B46@code1.codespeak.net> Author: hpk Date: Sun Aug 28 12:25:50 2005 New Revision: 16976 Modified: py/dist/py/documentation/confrest.py Log: set "modified" info to no stirng not having a svn/working copy Modified: py/dist/py/documentation/confrest.py ============================================================================== --- py/dist/py/documentation/confrest.py (original) +++ py/dist/py/documentation/confrest.py Sun Aug 28 12:25:50 2005 @@ -103,9 +103,14 @@ page = self.Page(self, "[%s] " % txtpath.purebasename, stylesheeturl=stylesheet) - svninfo = txtpath.info() - modified = " modified %s by %s" % (worded_diff_time(svninfo.mtime), - getrealname(svninfo.last_author)) + try: + svninfo = txtpath.info() + modified = " modified %s by %s" % (worded_diff_time(svninfo.mtime), + getrealname(svninfo.last_author)) + except (KeyboardInterrupt, SystemExit): + raise + except: + modified = " " page.contentspace.append( html.div(html.div(modified, style="float: right; font-style: italic;"), From tismer at codespeak.net Sun Aug 28 13:44:07 2005 From: tismer at codespeak.net (tismer at codespeak.net) Date: Sun, 28 Aug 2005 13:44:07 +0200 (CEST) Subject: [py-svn] r17000 - py/dist/py/path/svn Message-ID: <20050828114407.8ECF427B47@code1.codespeak.net> Author: tismer Date: Sun Aug 28 13:44:06 2005 New Revision: 17000 Modified: py/dist/py/path/svn/wccommand.py Log: small patch to set LC_MESSAGES before doing svn commands Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Sun Aug 28 13:44:06 2005 @@ -66,7 +66,16 @@ if DEBUG: print "execing", string try: - out = py.process.cmdexec(string) + try: + key = 'LC_MESSAGES' + hold = os.environ.get(key) + os.environ[key] = 'C' + out = py.process.cmdexec(string) + finally: + if hold: + os.environ[key] = hold + else: + del os.environ[key] except py.process.cmdexec.Error, e: strerr = e.err.lower() if strerr.find('file not found') != -1: From ericvrp at codespeak.net Mon Aug 29 09:58:22 2005 From: ericvrp at codespeak.net (ericvrp at codespeak.net) Date: Mon, 29 Aug 2005 09:58:22 +0200 (CEST) Subject: [py-svn] r17029 - in py/dist/py/misc: . cmdline Message-ID: <20050829075822.124CF27B4D@code1.codespeak.net> Author: ericvrp Date: Mon Aug 29 09:58:21 2005 New Revision: 17029 Modified: py/dist/py/misc/capture.py (props changed) py/dist/py/misc/cmdline/ (props changed) py/dist/py/misc/cmdline/countloc.py (props changed) Log: fixeol