[py-svn] r8048 - in py/dist/py: documentation documentation/example/test documentation/example/testing documentation/testing execnet execnet/test execnet/testing execnet/testing/test magic magic/testing misc misc/testing path/extpy path/extpy/test_data path/extpy/testing path/extpy/testing/test_data path/local path/local/popen5 path/local/popen5/testing path/local/testing path/svn path/svn/testing path/test process process/testing test test/report test/report/testing test/test test/testing test/testing/test test/tool test/tool/testing
hpk at codespeak.net
hpk at codespeak.net
Mon Jan 3 13:14:28 CET 2005
Author: hpk
Date: Mon Jan 3 13:14:26 2005
New Revision: 8048
Added:
py/dist/py/documentation/example/testing/
- copied from r8046, py/dist/py/documentation/example/test/
py/dist/py/documentation/testing/
py/dist/py/documentation/testing/__init__.py
py/dist/py/documentation/testing/rest_test.py
- copied unchanged from r8046, py/dist/py/documentation/rest_test.py
py/dist/py/execnet/testing/
py/dist/py/execnet/testing/__init__.py
py/dist/py/execnet/testing/sshtesting.py
- copied unchanged from r8046, py/dist/py/execnet/sshtesting.py
py/dist/py/execnet/testing/test/
- copied from r8046, py/dist/py/execnet/test/
py/dist/py/execnet/testing/test_gateway.py
- copied, changed from r8046, py/dist/py/execnet/test_gateway.py
py/dist/py/magic/testing/
py/dist/py/magic/testing/__init__.py
py/dist/py/magic/testing/test_assertion.py
- copied unchanged from r8046, py/dist/py/magic/test_assertion.py
py/dist/py/magic/testing/test_autopath.py
- copied unchanged from r8046, py/dist/py/magic/test_autopath.py
py/dist/py/magic/testing/test_exprinfo.py
- copied unchanged from r8046, py/dist/py/magic/test_exprinfo.py
py/dist/py/magic/testing/test_invoke.py
- copied unchanged from r8046, py/dist/py/magic/test_invoke.py
py/dist/py/magic/testing/test_patch.py
- copied unchanged from r8046, py/dist/py/magic/test_patch.py
py/dist/py/magic/testing/test_viewtype.py
- copied unchanged from r8046, py/dist/py/magic/test_viewtype.py
py/dist/py/misc/testing/
py/dist/py/misc/testing/__init__.py
py/dist/py/misc/testing/test_api.py
- copied unchanged from r8046, py/dist/py/misc/test_api.py
py/dist/py/misc/testing/test_cache.py
- copied, changed from r8046, py/dist/py/misc/test_cache.py
py/dist/py/misc/testing/test_error.py
- copied unchanged from r8046, py/dist/py/misc/test_error.py
py/dist/py/misc/testing/test_initpkg.py
- copied, changed from r8046, py/dist/py/misc/test_initpkg.py
py/dist/py/misc/testing/test_std.py
- copied unchanged from r8046, py/dist/py/misc/test_std.py
py/dist/py/path/extpy/testing/
py/dist/py/path/extpy/testing/__init__.py
py/dist/py/path/extpy/testing/inc_pseudofs.py
- copied unchanged from r8046, py/dist/py/path/extpy/inc_pseudofs.py
py/dist/py/path/extpy/testing/inc_test_extpy.py
- copied unchanged from r8046, py/dist/py/path/extpy/inc_test_extpy.py
py/dist/py/path/extpy/testing/test_data/
- copied from r8046, py/dist/py/path/extpy/test_data/
py/dist/py/path/extpy/testing/test_extpy.py
- copied unchanged from r8046, py/dist/py/path/extpy/test_extpy.py
py/dist/py/path/local/popen5/testing/
py/dist/py/path/local/popen5/testing/__init__.py
py/dist/py/path/local/popen5/testing/test_subprocess.py
- copied unchanged from r8046, py/dist/py/path/local/popen5/test_subprocess.py
py/dist/py/path/local/testing/
py/dist/py/path/local/testing/__init__.py
py/dist/py/path/local/testing/test_local.py
- copied unchanged from r8046, py/dist/py/path/local/test_local.py
py/dist/py/path/local/testing/test_posix.py
- copied unchanged from r8046, py/dist/py/path/local/test_posix.py
py/dist/py/path/svn/testing/
py/dist/py/path/svn/testing/__init__.py
py/dist/py/path/svn/testing/svntestbase.py
- copied unchanged from r8046, py/dist/py/path/svn/svntestbase.py
py/dist/py/path/svn/testing/test_urlcommand.py
- copied unchanged from r8047, py/dist/py/path/svn/test_urlcommand.py
py/dist/py/path/svn/testing/test_wccommand.py
- copied unchanged from r8047, py/dist/py/path/svn/test_wccommand.py
py/dist/py/process/testing/
py/dist/py/process/testing/__init__.py
py/dist/py/process/testing/test_cmdexec.py
- copied unchanged from r8046, py/dist/py/process/test_cmdexec.py
py/dist/py/test/report/testing/
py/dist/py/test/report/testing/__init__.py
py/dist/py/test/report/testing/test_memo.py
- copied unchanged from r8046, py/dist/py/test/report/test_memo.py
py/dist/py/test/testing/
py/dist/py/test/testing/__init__.py
py/dist/py/test/testing/test/
- copied from r8046, py/dist/py/test/test/
py/dist/py/test/testing/test_collect.py
- copied unchanged from r8046, py/dist/py/test/test_collect.py
py/dist/py/test/testing/test_compat.py
- copied unchanged from r8046, py/dist/py/test/test_compat.py
py/dist/py/test/testing/test_config.py
- copied unchanged from r8046, py/dist/py/test/test_config.py
py/dist/py/test/testing/test_raises.py
- copied unchanged from r8046, py/dist/py/test/test_raises.py
py/dist/py/test/tool/testing/
py/dist/py/test/tool/testing/__init__.py
py/dist/py/test/tool/testing/test_outerrcapture.py
- copied unchanged from r8046, py/dist/py/test/tool/test_outerrcapture.py
Removed:
py/dist/py/documentation/example/test/
py/dist/py/documentation/rest_test.py
py/dist/py/execnet/sshtesting.py
py/dist/py/execnet/test/
py/dist/py/execnet/test_gateway.py
py/dist/py/magic/test_assertion.py
py/dist/py/magic/test_autopath.py
py/dist/py/magic/test_exprinfo.py
py/dist/py/magic/test_invoke.py
py/dist/py/magic/test_patch.py
py/dist/py/magic/test_viewtype.py
py/dist/py/misc/test_api.py
py/dist/py/misc/test_cache.py
py/dist/py/misc/test_error.py
py/dist/py/misc/test_initpkg.py
py/dist/py/misc/test_std.py
py/dist/py/path/extpy/inc_pseudofs.py
py/dist/py/path/extpy/inc_test_extpy.py
py/dist/py/path/extpy/test_data/
py/dist/py/path/extpy/test_extpy.py
py/dist/py/path/local/popen5/test_subprocess.py
py/dist/py/path/local/test_local.py
py/dist/py/path/local/test_posix.py
py/dist/py/path/svn/svntestbase.py
py/dist/py/path/svn/test_urlcommand.py
py/dist/py/path/svn/test_wccommand.py
py/dist/py/process/test_cmdexec.py
py/dist/py/test/report/test_memo.py
py/dist/py/test/test/
py/dist/py/test/test_collect.py
py/dist/py/test/test_compat.py
py/dist/py/test/test_config.py
py/dist/py/test/test_raises.py
py/dist/py/test/tool/test_outerrcapture.py
Modified:
py/dist/py/path/test/test_api.py
Log:
separated test files out into their own "testing" directory.
it keeps the implementation files cleaner.
Deleted: /py/dist/py/documentation/rest_test.py
==============================================================================
--- /py/dist/py/documentation/rest_test.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,15 +0,0 @@
-from __future__ import generators
-
-import py
-
-pydir = py.magic.autopath(vars(py)).dirpath()
-rest = pydir.join('bin', 'py.rest').getpymodule()
-docdir = py.path.svnwc(pydir.join('documentation'))
-
-def restcheck(path):
- rest.process(path)
- #assert not out
-
-def test_rest_files():
- for x in docdir.listdir('*.txt'):
- yield restcheck, x
Added: py/dist/py/documentation/testing/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/documentation/testing/__init__.py Mon Jan 3 13:14:26 2005
@@ -0,0 +1 @@
+#
\ No newline at end of file
Deleted: /py/dist/py/execnet/sshtesting.py
==============================================================================
--- /py/dist/py/execnet/sshtesting.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,16 +0,0 @@
-"""
-A test file that doesn't run by default to test SshGateway.
-"""
-
-import py
-
-#REMOTE_HOST = 'codespeak.net'
-#REMOTE_HOSTNAME = 'thoth.codespeak.net'
-REMOTE_HOST = 'localhost' # you need to have a local ssh-daemon running!
-REMOTE_HOSTNAME = py.std.socket.gethostname() # the remote's socket.gethostname()
-
-def test_sshgateway():
- gw = py.execnet.SshGateway(REMOTE_HOST)
- c = gw.remote_exec('import socket; channel.send(socket.gethostname())')
- msg = c.receive()
- assert msg == REMOTE_HOSTNAME
Deleted: /py/dist/py/execnet/test_gateway.py
==============================================================================
--- /py/dist/py/execnet/test_gateway.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,193 +0,0 @@
-import os, sys
-import py
-from py.__impl__.execnet import gateway
-mypath = py.magic.autopath()
-
-from StringIO import StringIO
-
-class TestMessage:
- def test_wire_protocol(self):
- for cls in gateway.Message._types.values():
- one = StringIO()
- cls(42, '23').writeto(one)
- two = StringIO(one.getvalue())
- msg = gateway.Message.readfrom(two)
- assert isinstance(msg, cls)
- assert msg.channelid == 42
- assert msg.data == '23'
- assert isinstance(repr(msg), str)
- # == "<Message.%s channelid=42 '23'>" %(msg.__class__.__name__, )
-
-class TestChannel:
- def setup_method(self, method):
- self.fac = gateway.ChannelFactory(None)
-
- def test_factory_create(self):
- chan1 = self.fac.new()
- assert chan1.id == 1
- chan2 = self.fac.new()
- assert chan2.id == 3
-
- def test_factory_getitem(self):
- chan1 = self.fac.new()
- assert self.fac[chan1.id] == chan1
- chan2 = self.fac.new()
- assert self.fac[chan2.id] == chan2
-
- def test_factory_delitem(self):
- chan1 = self.fac.new()
- assert self.fac[chan1.id] == chan1
- del self.fac[chan1.id]
- py.test.raises(KeyError, self.fac.__getitem__, chan1.id)
-
- def test_factory_setitem(self):
- channel = gateway.Channel(None, 12)
- self.fac[channel.id] = channel
- assert self.fac[channel.id] == channel
-
- def test_channel_timeouterror(self):
- channel = self.fac.new()
- py.test.raises(IOError, channel.waitclose, timeout=0.01)
-
-class PopenGatewayTestSetup:
- def setup_class(cls):
- cls.gw = py.execnet.PopenGateway()
-
- def teardown_class(cls):
- cls.gw.exit()
-
-class BasicRemoteExecution:
- def test_correct_setup(self):
- assert self.gw.workerthreads and self.gw.iothreads
-
- def test_remote_exec_waitclose(self):
- channel = self.gw.remote_exec('pass')
- channel.waitclose(timeout=3.0)
-
- def test_remote_exec_channel_anonymous(self):
- channel = self.gw.remote_exec('''
- obj = channel.receive()
- channel.send(obj)
- ''')
- channel.send(42)
- result = channel.receive()
- assert result == 42
-
- def test_channel_close_and_then_receive_error(self):
- channel = self.gw.remote_exec('raise ValueError')
- py.test.raises(gateway.RemoteError, channel.receive)
-
- def test_channel_close_and_then_receive_error_multiple(self):
- channel = self.gw.remote_exec('channel.send(42) ; raise ValueError')
- x = channel.receive()
- assert x == 42
- py.test.raises(gateway.RemoteError, channel.receive)
-
- def test_channel_close(self):
- channel = self.gw.channelfactory.new()
- channel._close()
- channel.waitclose(0.1)
-
- def test_channel_close_error(self):
- channel = self.gw.channelfactory.new()
- channel._close(gateway.RemoteError("error"))
- py.test.raises(gateway.RemoteError, channel.waitclose, 0.01)
-
- def test_channel_passing_over_channel(self):
- channel = self.gw.remote_exec('''
- c = channel.newchannel()
- channel.send(c)
- c.send(42)
- ''')
- c = channel.receive()
- x = c.receive()
- assert x == 42
-
- # check that the both sides previous channels are really gone
- channel.waitclose(0.3)
- assert channel.id not in self.gw.channelfactory
- #assert c.id not in self.gw.channelfactory
- newchan = self.gw.remote_exec('''
- assert %d not in channel.gateway.channelfactory
- ''' % (channel.id))
- newchan.waitclose(0.3)
-
-class TestBasicPopenGateway(PopenGatewayTestSetup, BasicRemoteExecution):
- def test_many_popen(self):
- num = 4
- l = []
- for i in range(num):
- l.append(py.execnet.PopenGateway())
- channels = []
- for gw in l:
- channel = gw.remote_exec("""channel.send(42)""")
- channels.append(channel)
- try:
- while channels:
- channel = channels.pop()
- try:
- ret = channel.receive()
- assert ret == 42
- finally:
- channel.gateway.exit()
- finally:
- for x in channels:
- x.gateway.exit()
-
-class SocketGatewaySetup:
- def setup_class(cls):
- portrange = (7770, 7800)
- cls.proxygw = py.execnet.PopenGateway()
- socketserverbootstrap = py.code.Source(
- mypath.dirpath('bin', 'startserver.py').read(),
- """
- import socket
- portrange = channel.receive()
- for i in portrange:
- try:
- sock = bind_and_listen(("localhost", i))
- except socket.error:
- print "got error"
- import traceback
- traceback.print_exc()
- continue
- else:
- channel.send(i)
- startserver(sock)
- break
- else:
- channel.send(None)
- """)
- # open a gateway to a fresh child process
- cls.proxygw = py.execnet.PopenGateway()
-
- # execute asynchronously the above socketserverbootstrap on the other
- channel = cls.proxygw.remote_exec(socketserverbootstrap)
-
- # send parameters for the for-loop
- channel.send((7770, 7800))
- #
- # the other side should start the for loop now, we
- # wait for the result
- #
- cls.listenport = channel.receive()
- if cls.listenport is None:
- raise IOError, "could not setup remote SocketServer"
- cls.gw = py.execnet.SocketGateway('localhost', cls.listenport)
- print "initialized socket gateway on port", cls.listenport
-
- def teardown_class(cls):
- print "trying to tear down remote socket gateway"
- cls.gw.exit()
- if cls.gw.port:
- print "trying to tear down remote socket loop"
- import socket
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.connect(('localhost', cls.listenport))
- sock.sendall('"raise KeyboardInterrupt"')
- sock.shutdown(2)
- print "trying to tear proxy gateway"
- cls.proxygw.exit()
-
-class TestSocketGateway(SocketGatewaySetup, BasicRemoteExecution):
- pass
Added: py/dist/py/execnet/testing/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/execnet/testing/__init__.py Mon Jan 3 13:14:26 2005
@@ -0,0 +1 @@
+#
\ No newline at end of file
Copied: py/dist/py/execnet/testing/test_gateway.py (from r8046, py/dist/py/execnet/test_gateway.py)
==============================================================================
--- py/dist/py/execnet/test_gateway.py (original)
+++ py/dist/py/execnet/testing/test_gateway.py Mon Jan 3 13:14:26 2005
@@ -139,7 +139,7 @@
portrange = (7770, 7800)
cls.proxygw = py.execnet.PopenGateway()
socketserverbootstrap = py.code.Source(
- mypath.dirpath('bin', 'startserver.py').read(),
+ mypath.dirpath().dirpath('bin', 'startserver.py').read(),
"""
import socket
portrange = channel.receive()
Deleted: /py/dist/py/magic/test_assertion.py
==============================================================================
--- /py/dist/py/magic/test_assertion.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,53 +0,0 @@
-import py
-
-def setup_module(mod):
- py.magic.invoke(assertion=1)
-
-def teardown_module(mod):
- py.magic.revoke(assertion=1)
-
-def f():
- return 2
-
-def test_assert():
- try:
- assert f() == 3
- except AssertionError, e:
- s = str(e)
- assert s.startswith('assert 2 == 3\n')
-
-def test_assert_within_finally():
- class A:
- def f():
- pass
- excinfo = py.test.raises(TypeError, """
- try:
- A().f()
- finally:
- i = 42
- """)
- s = excinfo.exception_text
- assert s.find("takes no argument") != -1
-
- #def g():
- # A.f()
- #excinfo = getexcinfo(TypeError, g)
- #msg = getmsg(excinfo)
- #assert msg.find("must be called with A") != -1
-
-
-def test_assert_multiline_1():
- try:
- assert (f() ==
- 3)
- except AssertionError, e:
- s = str(e)
- assert s.startswith('assert 2 == 3\n')
-
-def test_assert_multiline_2():
- try:
- assert (f() == (4,
- 3)[-1])
- except AssertionError, e:
- s = str(e)
- assert s.startswith('assert 2 ==')
Deleted: /py/dist/py/magic/test_autopath.py
==============================================================================
--- /py/dist/py/magic/test_autopath.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,89 +0,0 @@
-import py
-import sys
-
-class TestAutoPath:
- getauto = "from py.magic import autopath ; autopath = autopath()"
- def __init__(self):
- self.root = py.test.config.tmpdir.ensure('autoconfigure', dir=1)
- self.initdir = self.root.ensure('pkgdir', dir=1)
- self.initdir.ensure('__init__.py')
- self.initdir2 = self.initdir.ensure('initdir2', dir=1)
- self.initdir2.ensure('__init__.py')
-
- def test_import_autoconfigure__file__with_init(self):
- testpath = self.initdir2 / 'autoconfiguretest.py'
- d = {'__file__' : str(testpath)}
- oldsyspath = sys.path[:]
- try:
- exec self.getauto in d
- conf = d['autopath']
- assert conf.dirpath() == self.initdir2
- assert conf.pkgdir == self.initdir
- assert str(self.root) in sys.path
- exec self.getauto in d
- assert conf is not d['autopath']
- finally:
- sys.path[:] = oldsyspath
-
- def test_import_autoconfigure__file__with_py_exts(self):
- for ext in '.pyc', '.pyo':
- testpath = self.initdir2 / ('autoconfiguretest' + ext)
- d = {'__file__' : str(testpath)}
- oldsyspath = sys.path[:]
- try:
- exec self.getauto in d
- conf = d['autopath']
- assert conf == self.initdir2.join('autoconfiguretest.py')
- assert conf.pkgdir == self.initdir
- assert str(self.root) in sys.path
- exec self.getauto in d
- assert conf is not d['autopath']
- finally:
- sys.path[:] = oldsyspath
-
- def test_import_autoconfigure___file__without_init(self):
- testpath = self.root / 'autoconfiguretest.py'
- d = {'__file__' : str(testpath)}
- oldsyspath = sys.path[:]
- try:
- exec self.getauto in d
- conf = d['autopath']
- assert conf.dirpath() == self.root
- assert conf.pkgdir == self.root
- syspath = sys.path[:]
- assert str(self.root) in syspath
- exec self.getauto in d
- assert conf is not d['autopath']
- finally:
- sys.path[:] = oldsyspath
-
- def test_import_autoconfigure__nofile(self):
- p = self.initdir2 / 'autoconfiguretest.py'
- oldsysarg = sys.argv
- sys.argv = [str(p)]
- oldsyspath = sys.path[:]
- try:
- d = {}
- exec self.getauto in d
- conf = d['autopath']
- assert conf.dirpath() == self.initdir2
- assert conf.pkgdir == self.initdir
- syspath = sys.path[:]
- assert str(self.root) in syspath
- finally:
- sys.path[:] = oldsyspath
- sys.argv = sys.argv
-
-
- def test_import_autoconfigure__nofile_interactive(self):
- oldsysarg = sys.argv
- sys.argv = ['']
- oldsyspath = sys.path[:]
- try:
- py.test.raises(ValueError,'''
- d = {}
- exec self.getauto in d
- ''')
- finally:
- sys.path[:] = oldsyspath
- sys.argv = sys.argv
Deleted: /py/dist/py/magic/test_exprinfo.py
==============================================================================
--- /py/dist/py/magic/test_exprinfo.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,103 +0,0 @@
-
-import sys
-import py
-from py.__impl__.magic.exprinfo import getmsg, interpret
-
-def getexcinfo(exc, obj, *args, **kwargs):
- try:
- obj(*args, **kwargs)
- except KeyboardInterrupt:
- raise
- except exc:
- return sys.exc_info()
- else:
- raise AssertionError, "%r(*%r, **%r) did not raise" %(
- obj, args, kwargs)
-
-def test_assert_exprinfo():
- def g():
- a = 1
- b = 2
- assert a == b
- excinfo = getexcinfo(AssertionError, g)
- msg = getmsg(excinfo)
- assert msg == 'assert 1 == 2'
-
-def test_nested_scopes():
- def g():
- a = 1
- def h():
- return a
- b = 2
- assert h() == b
- excinfo = getexcinfo(AssertionError, g)
- msg = getmsg(excinfo)
- assert msg.startswith('assert 1 == 2\n + where 1 = ')
-
-def test_nested_scopes_2():
- a = 1
- def g():
- b = 2
- assert a == b
- excinfo = getexcinfo(AssertionError, g)
- msg = getmsg(excinfo)
- assert msg == 'assert 1 == 2'
-
-def test_assert_func_argument_type_error():
- def f ():
- pass
- def g():
- f(1)
- excinfo = getexcinfo(TypeError, g)
- msg = getmsg(excinfo)
- assert msg.find("takes no argument") != -1
-
- class A:
- def f():
- pass
- def g():
- A().f()
- excinfo = getexcinfo(TypeError, g)
- msg = getmsg(excinfo)
- assert msg.find("takes no argument") != -1
-
- def g():
- A.f()
- excinfo = getexcinfo(TypeError, g)
- msg = getmsg(excinfo)
- assert msg.find("must be called with A") != -1
-
-def global_f():
- return 42
-
-def test_exprinfo_funccall():
- def g():
- assert global_f() == 43
- excinfo = getexcinfo(AssertionError, g)
- msg = getmsg(excinfo)
- assert msg == 'assert 42 == 43\n + where 42 = global_f()'
-
-def test_keyboard_interrupt():
- # XXX this test is slightly strange because it is not
- # clear that "interpret" should execute "raise" statements
- # ... but it apparently currently does and it's nice to
- # exercise the code because the exprinfo-machinery is
- # not much executed when all tests pass ...
-
- class DummyCode:
- co_filename = 'dummy'
- co_firstlineno = 0
- co_name = 'dummy'
- class DummyFrame:
- f_globals = f_locals = {}
- f_code = DummyCode
- f_lineno = 0
-
- for exstr in "SystemExit", "KeyboardInterrupt", "MemoryError":
- ex = eval(exstr)
- try:
- interpret("raise %s" % exstr, py.code.Frame(DummyFrame))
- except ex:
- pass
- else:
- raise AssertionError, "ex %s didn't pass through" %(exstr, )
Deleted: /py/dist/py/magic/test_invoke.py
==============================================================================
--- /py/dist/py/magic/test_invoke.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,15 +0,0 @@
-import __builtin__ as bltin
-import py
-import inspect
-
-def check_assertion():
- excinfo = py.test.raises(AssertionError, "assert 1 == 2")
- assert excinfo.exception_text == "assert 1 == 2"
-
-def test_invoke_assertion():
- py.magic.invoke(assertion=True)
- try:
- check_assertion()
- finally:
- py.magic.revoke(assertion=True)
-
Deleted: /py/dist/py/magic/test_patch.py
==============================================================================
--- /py/dist/py/magic/test_patch.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,31 +0,0 @@
-from py.test import raises
-from py.magic import patch, revert
-
-def test_patch_revert():
- class a:
- pass
- raises(AttributeError, "patch(a, 'i', 42)")
-
- a.i = 42
- patch(a, 'i', 23)
- assert a.i == 23
- revert(a, 'i')
- assert a.i == 42
-
-def test_double_patch():
- class a:
- i = 42
- assert patch(a, 'i', 2) == 42
- assert patch(a, 'i', 3) == 2
- assert a.i == 3
- assert revert(a, 'i') == 3
- assert a.i == 2
- assert revert(a, 'i') == 2
- assert a.i == 42
-
-def test_valueerror():
- class a:
- i = 2
- pass
- raises(ValueError, "revert(a, 'i')")
-
Deleted: /py/dist/py/magic/test_viewtype.py
==============================================================================
--- /py/dist/py/magic/test_viewtype.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,55 +0,0 @@
-from py.magic import View
-
-def test_class_dispatch():
- ### Use a custom class hierarchy with existing instances
-
- class Picklable(View):
- pass
-
- class Simple(Picklable):
- __view__ = object
- def pickle(self):
- return repr(self.__obj__)
-
- class Seq(Picklable):
- __view__ = list, tuple, dict
- def pickle(self):
- return ';'.join([Picklable(item).pickle() for item in self.__obj__])
-
- class Dict(Seq):
- __view__ = dict
- def pickle(self):
- return Seq.pickle(self) + '!' + Seq(self.values()).pickle()
-
- assert Picklable(123).pickle() == '123'
- assert Picklable([1,[2,3],4]).pickle() == '1;2;3;4'
- assert Picklable({1:2}).pickle() == '1!2'
-
-
-def test_custom_class_hierarchy():
- ### Use a custom class hierarchy based on attributes of existing instances
-
- class Operation:
- "Existing class that I don't want to change."
- def __init__(self, opname, *args):
- self.opname = opname
- self.args = args
-
- existing = [Operation('+', 4, 5),
- Operation('getitem', '', 'join'),
- Operation('setattr', 'x', 'y', 3),
- Operation('-', 12, 1)]
-
- class PyOp(View):
- def __viewkey__(self):
- return self.opname
- def generate(self):
- return '%s(%s)' % (self.opname, ', '.join(map(repr, self.args)))
-
- class PyBinaryOp(PyOp):
- __view__ = ('+', '-', '*', '/')
- def generate(self):
- return '%s %s %s' % (self.args[0], self.opname, self.args[1])
-
- codelines = [PyOp(op).generate() for op in existing]
- assert codelines == ["4 + 5", "getitem('', 'join')", "setattr('x', 'y', 3)", "12 - 1"]
Added: py/dist/py/magic/testing/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/magic/testing/__init__.py Mon Jan 3 13:14:26 2005
@@ -0,0 +1 @@
+#
\ No newline at end of file
Deleted: /py/dist/py/misc/test_api.py
==============================================================================
--- /py/dist/py/misc/test_api.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,43 +0,0 @@
-
-from py.test import raises
-import py
-import sys
-import inspect
-
-class TestAPI_V0_namespace_consistence:
- def test_path_entrypoints(self):
- assert inspect.ismodule(py.path)
- assert_class('py.path', 'local')
- assert_class('py.path', 'svnwc')
- assert_class('py.path', 'svnurl')
- assert_class('py.path', 'extpy')
- assert_class('py.path', 'checker')
-
- def test_magic_entrypoints(self):
- assert_class('py.magic', 'View')
- assert_function('py.magic', 'invoke')
- assert_function('py.magic', 'revoke')
- assert_function('py.magic', 'patch')
- assert_function('py.magic', 'revoke')
-
- def test_process_entrypoints(self):
- assert_function('py.process', 'cmdexec')
-
- def XXXtest_utest_entrypoints(self):
- # XXX TOBECOMPLETED
- assert_function('py.test', 'main')
- #assert_module('std.utest', 'collect')
-
-def assert_class(modpath, name):
- mod = __import__(modpath, None, None, [name])
- obj = getattr(mod, name)
- fullpath = modpath + '.' + name
- assert obj.__module__ == modpath
- if sys.version_info >= (2,3):
- assert obj.__name__ == name
-
-def assert_function(modpath, name):
- mod = __import__(modpath, None, None, [name])
- obj = getattr(mod, name)
- assert hasattr(obj, 'func_doc')
- #assert obj.func_name == name
Deleted: /py/dist/py/misc/test_cache.py
==============================================================================
--- /py/dist/py/misc/test_cache.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,55 +0,0 @@
-import py
-from cache import BuildcostAccessCache, AgingCache
-
-class BasicCacheAPITest:
- cache = None
- def test_getorbuild(self):
- val = self.cache.getorbuild(-42, lambda: 42)
- assert val == 42
- val = self.cache.getorbuild(-42, lambda: 23)
- assert val == 42
-
- def test_cache_get_key_error(self):
- assert self.cache.getentry(-23) == None
-
- def test_delentry_non_raising(self):
- val = self.cache.getorbuild(100, lambda: 100)
- self.cache.delentry(100)
- assert self.cache.getentry(100) is None
-
- def test_delentry_raising(self):
- val = self.cache.getorbuild(100, lambda: 100)
- self.cache.delentry(100)
- py.test.raises(KeyError, "self.cache.delentry(100, raising=True)")
-
-class TestBuildcostAccess(BasicCacheAPITest):
- cache = BuildcostAccessCache(maxentries=128)
-
- def test_cache_works_somewhat_simple(self):
- cache = BuildcostAccessCache()
- for x in range(cache.maxentries):
- y = cache.getorbuild(x, lambda: x)
- assert x == y
- for x in range(cache.maxentries):
- assert cache.getorbuild(x, None) == x
- for x in range(cache.maxentries/2):
- assert cache.getorbuild(x, None) == x
- assert cache.getorbuild(x, None) == x
- assert cache.getorbuild(x, None) == x
- val = cache.getorbuild(cache.maxentries * 2, lambda: 42)
- assert val == 42
- # check that recently used ones are still there
- # and are not build again
- for x in range(cache.maxentries/2):
- assert cache.getorbuild(x, None) == x
- assert cache.getorbuild(cache.maxentries*2, None) == 42
-
-
-class TestAging(BasicCacheAPITest):
- maxsecs = 0.02
- cache = AgingCache(maxentries=128, maxseconds=maxsecs)
-
- def test_cache_eviction(self):
- self.cache.getorbuild(17, lambda: 17)
- py.std.time.sleep(self.maxsecs*1.1)
- assert self.cache.getentry(17) is None
Deleted: /py/dist/py/misc/test_error.py
==============================================================================
--- /py/dist/py/misc/test_error.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,10 +0,0 @@
-
-import py
-
-import errno
-
-def test_error_classes():
- for name in errno.errorcode.values():
- x = getattr(py.error, name)
- assert issubclass(x, py.error.Error)
- assert issubclass(x, EnvironmentError)
Deleted: /py/dist/py/misc/test_initpkg.py
==============================================================================
--- /py/dist/py/misc/test_initpkg.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,80 +0,0 @@
-import py
-import types
-
-def test_dir():
- from py.__impl__.initpkg import Module
- for name in dir(py):
- if not name.startswith('_'):
- obj = getattr(py, name)
- if hasattr(obj, '__map__'): # isinstance(obj, Module):
- keys = dir(obj)
- assert len(keys) > 0
- assert getattr(obj, '__map__') == {}
-
-def test_virtual_module_identity():
- from py import path as path1
- from py import path as path2
- assert path1 is path2
- from py.path import local as local1
- from py.path import local as local2
- assert local1 is local2
-
-def test_importing_all_implementations():
- base = py.path.local(py.__file__).dirpath()
- nodirs = (
- base.join('test', 'test', 'data'),
- base.join('path', 'extpy', 'test_data'),
- base.join('path', 'gateway',),
- base.join('documentation',),
- base.join('test', 'test', 'import_test'),
- base.join('magic', 'greenlet'),
- base.join('bin'),
- base.join('execnet', 'bin'),
- )
- for p in base.visit('*.py', py.path.checker(dotfile=0)):
- relpath = p.new(ext='').relto(base)
- if base.sep in relpath: # not std/*.py itself
- for x in nodirs:
- if p.relto(x):
- break
- else:
- relpath = relpath.replace(base.sep, '.')
- modpath = 'py.__impl__.%s' % relpath
- assert __import__(modpath)
-
-def test_shahexdigest():
- hex = py.__package__.shahexdigest()
- assert len(hex) == 40
-
-def test_getzipdata():
- s = py.__package__.getzipdata()
-
-def test_getrev():
- d = py.__package__.getrev()
- try:
- svnversion = py.path.local.sysfind('svnversion')
- except py.error.ENOENT:
- py.test.skip("cannot test svnversion, 'svnversion' binary not found")
- v = svnversion.sysexec(py.path.local(py.__file__).dirpath())
- assert v.startswith(str(d))
-
-# the following test should abasically work in the future
-def XXXtest_virtual_on_the_fly():
- py.initpkg('my', {
- 'x.abspath' : 'os.path.abspath',
- 'x.local' : 'py.path.local',
- 'y' : 'smtplib',
- 'z.cmdexec' : 'py.process.cmdexec',
- })
- from my.x import abspath
- from my.x import local
- import smtplib
- from my import y
- assert y is smtplib
- from my.z import cmdexec
- from py.process import cmdexec as cmdexec2
- assert cmdexec is cmdexec2
-
-##def test_help():
-# help(std.path)
-# #assert False
Deleted: /py/dist/py/misc/test_std.py
==============================================================================
--- /py/dist/py/misc/test_std.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,13 +0,0 @@
-
-import py
-
-def test_os():
- import os
- assert py.std.os is os
-
-def test_import_error_converts_to_attributeerror():
- py.test.raises(AttributeError, "py.std.xyzalskdj")
-
-def test_std_gets_it():
- for x in py.std.sys.modules:
- assert x in py.std.__dict__
Added: py/dist/py/misc/testing/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/misc/testing/__init__.py Mon Jan 3 13:14:26 2005
@@ -0,0 +1 @@
+#
\ No newline at end of file
Copied: py/dist/py/misc/testing/test_cache.py (from r8046, py/dist/py/misc/test_cache.py)
==============================================================================
--- py/dist/py/misc/test_cache.py (original)
+++ py/dist/py/misc/testing/test_cache.py Mon Jan 3 13:14:26 2005
@@ -1,5 +1,5 @@
import py
-from cache import BuildcostAccessCache, AgingCache
+from py.__impl__.misc.cache import BuildcostAccessCache, AgingCache
class BasicCacheAPITest:
cache = None
Copied: py/dist/py/misc/testing/test_initpkg.py (from r8046, py/dist/py/misc/test_initpkg.py)
==============================================================================
--- py/dist/py/misc/test_initpkg.py (original)
+++ py/dist/py/misc/testing/test_initpkg.py Mon Jan 3 13:14:26 2005
@@ -22,11 +22,11 @@
def test_importing_all_implementations():
base = py.path.local(py.__file__).dirpath()
nodirs = (
- base.join('test', 'test', 'data'),
- base.join('path', 'extpy', 'test_data'),
+ base.join('test', 'testing', 'test'),
+ base.join('path', 'extpy', 'testing', 'test_data'),
base.join('path', 'gateway',),
base.join('documentation',),
- base.join('test', 'test', 'import_test'),
+ base.join('test', 'testing', 'import_test'),
base.join('magic', 'greenlet'),
base.join('bin'),
base.join('execnet', 'bin'),
Deleted: /py/dist/py/path/extpy/inc_pseudofs.py
==============================================================================
--- /py/dist/py/path/extpy/inc_pseudofs.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,12 +0,0 @@
-
-samplefile = 'samplefile\n'
-samplepickle = {}
-
-class sampledir:
- otherfile = 'otherfile'
-
-class otherdir:
- init = 42
-
-class execfile:
- x = 42
Deleted: /py/dist/py/path/extpy/inc_test_extpy.py
==============================================================================
--- /py/dist/py/path/extpy/inc_test_extpy.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,18 +0,0 @@
-from __future__ import generators
-
-class A:
- x1 = 42
- def func(self):
- pass
-
- def genfunc(self):
- yield 2
-
-class B:
- x2 = 23
-
-class Nested:
- class Class:
- def borgfunc(self): pass
-
-
Deleted: /py/dist/py/path/extpy/test_extpy.py
==============================================================================
--- /py/dist/py/path/extpy/test_extpy.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,201 +0,0 @@
-import os
-import py
-
-from py.__impl__.path.test import common
-
-mypath = py.magic.autopath().dirpath('inc_test_extpy.py')
-
-class TestExtPyCommonTests(common.CommonPathTests):
- def setup_class(cls):
- cls.root = py.path.extpy(
- py.magic.autopath().dirpath('inc_pseudofs.py'))
-
- def test_file(self):
- assert self.root.join('samplefile').check(file=1)
- assert self.root.join('otherdir').check(file=0)
-
-class TestExtPy:
- def setup_class(cls):
- cls.root = py.path.extpy(mypath)
-
- def test_join(self):
- p = self.root.join('A')
- obj = p.resolve()
- assert hasattr(obj, '__bases__')
- assert obj.x1 == 42
-
- def test_listdir_module(self):
- l = self.root.listdir()
- basenames = [x.basename for x in l]
- dlist = dir(self.root.resolve())
- for name in dlist:
- assert name in basenames
- for name in basenames:
- assert name in dlist
-
- def test_listdir_class(self):
- l = self.root.join('A').listdir()
- basenames = [x.basename for x in l]
- dlist = dir(self.root.resolve().A)
- for name in dlist:
- assert name in basenames
- for name in basenames:
- assert name in dlist
-
- def listobj(self):
- l = self.root.listobj(basestarts='path')
- assert len(l) == 1
- assert l[0] == path
-
- def test_visit(self):
- l = list(self.root.visit(py.path.checker(basename='borgfunc')))
- assert len(l) == 1
- obj = l[0]
- assert str(obj).endswith('Nested.Class.borgfunc')
- assert obj.resolve() == self.root.resolve().Nested.Class.borgfunc
-
- def test_visit_fnmatch(self):
- l = list(self.root.visit('borg*'))
- assert len(l) == 1
- obj = l[0]
- assert str(obj).endswith('Nested.Class.borgfunc')
- assert obj.resolve() == self.root.resolve().Nested.Class.borgfunc
-
- #def test_join_from_empty(self):
- # p = path.py('')
- # n = p.join('tokenize')
- # assert str(n) == 'tokenize'
- #
- # p = path.py('', ns=os)
- # n = p.join('getlogin')
- # assert str(n) == 'getlogin'
-
- #def test_unspecifiedpypath_lists_modules(self):
- # p = path.py('')
- # l = p.listdir()
- # for i in l:
- # assert '.' not in str(i)
- #
- # for j in sys.modules:
- # for i in l:
- # if j.startswith(str(i)):
- # break
- # else:
- # self.fail("%s is not in sys.modules")
-
- #def test_main_works(self):
- # m = path.py('__main__')
- # import __main__
- # assert m.resolve() is __main__
-
- def test_relto(self):
- m1 = self.root.new(modpath='a.b.c.d')
- m2 = self.root.new(modpath='a.b')
- m3 = self.root.new(modpath='')
- res = m1.relto(m2)
- assert str(res) == 'c.d'
- assert m2.relto(m3) == 'a.b'
-
- def test_basename(self):
- m1 = self.root.new(modpath='a.b.hello')
- assert m1.basename == 'hello'
- assert m1.check(basename='hello')
- assert not m1.check(basename='nono')
- assert m1.check(basestarts='he')
- assert not m1.check(basestarts='42')
-
- def test_dirpath(self):
- m1 = self.root.new(modpath='a.b.hello')
- m2 = self.root.new(modpath='a.b')
- m3 = self.root.new(modpath='a')
- m4 = self.root.new(modpath='')
- assert m1.dirpath() == m2
- assert m2.dirpath() == m3
- assert m3.dirpath() == m4
-
- def test_function(self):
- p = self.root.join('A.func')
- assert p.check(func=1)
- p = self.root.join('A.x1')
- assert p.check(func=0)
-
- def test_generatorfunction(self):
- p = self.root.join('A.genfunc')
- assert p.check(genfunc=1)
- p = self.root.join('A.func')
- assert p.check(genfunc=0)
- p = self.root.join('A')
- assert p.check(genfunc=0)
-
- def test_class(self):
- p = self.root.join('A')
- assert p.check(class_=1)
-
- def test_hashing_equality(self):
- x = self.root
- y = self.root.new()
- assert x == y
- assert hash(x) == hash(y)
-
- def test_parts2(self):
- x = self.root.new(modpath='os.path.abspath')
- l = x.parts()
- assert len(l) == 4
- assert self.root.join('') == l[0]
- assert self.root.join('os') == l[1]
- assert self.root.join('os.path') == l[2]
- assert self.root.join('os.path.abspath') == l[3]
-
-#class TestExtPyWithModule:
-# def test_module(self):
-# import os
-# x = py.path.extpy(os, 'path.abspath')
-# assert x.check()
-# assert x.resolve() is os.path.abspath
-# #def setup_class(cls):
- # cls.root = py.path.extpy(mypath)
-
-class TestEval:
- disabled = True
- def test_funccall(self):
- p = path.py('os.path.join("a", "b")')
- s = p.resolve()
- assert s == os.path.join("a", "b")
-
- def test_invalid1(self):
- p = path.py('os.path.qwe("a", "b")')
- s = test.raises(py.error.ENOENT, "p.resolve()")
-
- def test_syntaxerror(self):
- p = path.py('os.path.qwe("a", ')
- s = test.raises(ValueError, "p.resolve()")
-
-class TestErrors:
- def test_ENOENT(self):
- p = py.path.extpy(mypath, 'somesuch')
- py.test.raises(py.error.ENOENT, p.resolve)
-
- def test_ENOENT_really(self):
- p = py.path.extpy(mypath.new(basename='notexist'), 'somesuch')
- py.test.raises(py.error.ENOENT, p.resolve)
-
- #def test_ImportError():
- # p = path.py('__std.utest.test.data.failingimport.someattr')
- # utest.raises(ImportError, p.resolve)
-
-class ExampleClass:
- testattr = 1
-
-def test_no_newline():
- filepath = mypath.dirpath() / 'test_data' / 'no_trailing_newline.py'
- pyc = filepath.dirpath() / 'no_trailing_newline.pyc'
- if pyc.check(exists=1):
- pyc.remove()
- data = filepath.read()
- assert not data.endswith('\n') and not data.endswith('\r'), (
- "The file must not end with a newline (that's the point of "
- "this test")
- #print repr(data)
- mod_extpy = py.path.extpy(filepath)
- #print mod_extpy.resolve()
- assert mod_extpy.resolve().test
Added: py/dist/py/path/extpy/testing/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/path/extpy/testing/__init__.py Mon Jan 3 13:14:26 2005
@@ -0,0 +1 @@
+#
\ No newline at end of file
Deleted: /py/dist/py/path/local/popen5/test_subprocess.py
==============================================================================
--- /py/dist/py/path/local/popen5/test_subprocess.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,551 +0,0 @@
-import sys
-import os
-import py
-from py.__impl__.path.local.popen5 import subprocess
-
-mswindows = (sys.platform == "win32")
-
-#
-# Depends on the following external programs: Python
-#
-
-if mswindows:
- SETBINARY = ('import msvcrt; msvcrt.setmode(sys.stdout.fileno(), '
- 'os.O_BINARY);')
-else:
- SETBINARY = ''
-
-# In a debug build, stuff like "[6580 refs]" is printed to stderr at
-# shutdown time. That frustrates tests trying to check stderr produced
-# from a spawned Python process.
-def remove_stderr_debug_decorations(stderr):
- return py.std.re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr)
-
-class TestPopen5(py.test.compat.TestCase):
- disabled = True
- def mkstemp(self):
- """wrapper for mkstemp, calling mktemp if mkstemp is not available"""
- if hasattr(tempfile, "mkstemp"):
- return py.std.tempfile.mkstemp()
- else:
- fname = py.std.tempfile.mktemp()
- return os.open(fname, os.O_RDWR|os.O_CREAT), fname
-
- #
- # Generic tests
- #
- def test_call_seq(self):
- # call() function with sequence argument
- rc = subprocess.call([sys.executable, "-c",
- "import sys; sys.exit(47)"])
- self.assertEqual(rc, 47)
-
- def test_call_kwargs(self):
- # call() function with keyword args
- newenv = os.environ.copy()
- newenv["FRUIT"] = "banana"
- rc = subprocess.call([sys.executable, "-c",
- 'import sys, os;' \
- 'sys.exit(os.getenv("FRUIT")=="banana")'],
- env=newenv)
- self.assertEqual(rc, 1)
-
- def test_stdin_none(self):
- # .stdin is None when not redirected
- p = subprocess.Popen([sys.executable, "-c", 'print "banana"'],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- p.wait()
- self.assertEqual(p.stdin, None)
-
- def test_stdout_none(self):
- # .stdout is None when not redirected
- p = subprocess.Popen([sys.executable, "-c",
- 'print " this bit of output is from a '
- 'test of stdout in a different '
- 'process ..."'],
- stdin=subprocess.PIPE, stderr=subprocess.PIPE)
- p.wait()
- self.assertEqual(p.stdout, None)
-
- def test_stderr_none(self):
- # .stderr is None when not redirected
- p = subprocess.Popen([sys.executable, "-c", 'print "banana"'],
- stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- p.wait()
- self.assertEqual(p.stderr, None)
-
- def test_executable(self):
- p = subprocess.Popen(["somethingyoudonthave",
- "-c", "import sys; sys.exit(47)"],
- executable=sys.executable)
- p.wait()
- self.assertEqual(p.returncode, 47)
-
- def test_stdin_pipe(self):
- # stdin redirection
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys; sys.exit(sys.stdin.read() == "pear")'],
- stdin=subprocess.PIPE)
- p.stdin.write("pear")
- p.stdin.close()
- p.wait()
- self.assertEqual(p.returncode, 1)
-
- def test_stdin_filedes(self):
- # stdin is set to open file descriptor
- tf = py.std.tempfile.TemporaryFile()
- d = tf.fileno()
- os.write(d, "pear")
- os.lseek(d, 0, 0)
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys; sys.exit(sys.stdin.read() == "pear")'],
- stdin=d)
- p.wait()
- self.assertEqual(p.returncode, 1)
-
- def test_stdin_fileobj(self):
- # stdin is set to open file object
- tf = py.std.tempfile.TemporaryFile()
- tf.write("pear")
- tf.seek(0)
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys; sys.exit(sys.stdin.read() == "pear")'],
- stdin=tf)
- p.wait()
- self.assertEqual(p.returncode, 1)
-
- def test_stdout_pipe(self):
- # stdout redirection
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys; sys.stdout.write("orange")'],
- stdout=subprocess.PIPE)
- self.assertEqual(p.stdout.read(), "orange")
-
- def test_stdout_filedes(self):
- # stdout is set to open file descriptor
- tf = py.std.tempfile.TemporaryFile()
- d = tf.fileno()
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys; sys.stdout.write("orange")'],
- stdout=d)
- p.wait()
- os.lseek(d, 0, 0)
- self.assertEqual(os.read(d, 1024), "orange")
-
- def test_stdout_fileobj(self):
- # stdout is set to open file object
- tf = py.std.tempfile.TemporaryFile()
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys; sys.stdout.write("orange")'],
- stdout=tf)
- p.wait()
- tf.seek(0)
- self.assertEqual(tf.read(), "orange")
-
- def test_stderr_pipe(self):
- # stderr redirection
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys; sys.stderr.write("strawberry")'],
- stderr=subprocess.PIPE)
- self.assertEqual(remove_stderr_debug_decorations(p.stderr.read()),
- "strawberry")
-
- def test_stderr_filedes(self):
- # stderr is set to open file descriptor
- tf = py.std.tempfile.TemporaryFile()
- d = tf.fileno()
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys; sys.stderr.write("strawberry")'],
- stderr=d)
- p.wait()
- os.lseek(d, 0, 0)
- self.assertEqual(remove_stderr_debug_decorations(os.read(d, 1024)),
- "strawberry")
-
- def test_stderr_fileobj(self):
- # stderr is set to open file object
- tf = py.std.tempfile.TemporaryFile()
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys; sys.stderr.write("strawberry")'],
- stderr=tf)
- p.wait()
- tf.seek(0)
- self.assertEqual(remove_stderr_debug_decorations(tf.read()),
- "strawberry")
-
- def test_stdout_stderr_pipe(self):
- # capture stdout and stderr to the same pipe
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys;' \
- 'sys.stdout.write("apple");' \
- 'sys.stdout.flush();' \
- 'sys.stderr.write("orange")'],
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
- output = p.stdout.read()
- stripped = remove_stderr_debug_decorations(output)
- self.assertEqual(stripped, "appleorange")
-
- def test_stdout_stderr_file(self):
- # capture stdout and stderr to the same open file
- tf = py.std.tempfile.TemporaryFile()
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys;' \
- 'sys.stdout.write("apple");' \
- 'sys.stdout.flush();' \
- 'sys.stderr.write("orange")'],
- stdout=tf,
- stderr=tf)
- p.wait()
- tf.seek(0)
- output = tf.read()
- stripped = remove_stderr_debug_decorations(output)
- self.assertEqual(stripped, "appleorange")
-
- def test_cwd(self):
- tmpdir = os.getenv("TEMP", "/tmp")
- tmpdir = os.path.realpath(tmpdir)
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;' \
- 'sys.stdout.write(os.getcwd())'],
- stdout=subprocess.PIPE,
- cwd=tmpdir)
- normcase = os.path.normcase
- self.assertEqual(normcase(p.stdout.read()), normcase(tmpdir))
-
- def test_env(self):
- newenv = os.environ.copy()
- newenv["FRUIT"] = "orange"
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;' \
- 'sys.stdout.write(os.getenv("FRUIT"))'],
- stdout=subprocess.PIPE,
- env=newenv)
- self.assertEqual(p.stdout.read(), "orange")
-
- def test_communicate(self):
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;' \
- 'sys.stderr.write("pineapple");' \
- 'sys.stdout.write(sys.stdin.read())'],
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- (stdout, stderr) = p.communicate("banana")
- self.assertEqual(stdout, "banana")
- self.assertEqual(remove_stderr_debug_decorations(stderr),
- "pineapple")
-
- def test_communicate_returns(self):
- # communicate() should return None if no redirection is active
- p = subprocess.Popen([sys.executable, "-c",
- "import sys; sys.exit(47)"])
- (stdout, stderr) = p.communicate()
- self.assertEqual(stdout, None)
- self.assertEqual(stderr, None)
-
- def test_communicate_pipe_buf(self):
- # communicate() with writes larger than pipe_buf
- # This test will probably deadlock rather than fail, if
- # communicate() does not work properly.
- x, y = os.pipe()
- if mswindows:
- pipe_buf = 512
- else:
- pipe_buf = os.fpathconf(x, "PC_PIPE_BUF")
- os.close(x)
- os.close(y)
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;'
- 'sys.stdout.write(sys.stdin.read(47));' \
- 'sys.stderr.write("xyz"*%d);' \
- 'sys.stdout.write(sys.stdin.read())' % pipe_buf],
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- string_to_write = "abc"*pipe_buf
- (stdout, stderr) = p.communicate(string_to_write)
- self.assertEqual(stdout, string_to_write)
-
- def test_writes_before_communicate(self):
- # stdin.write before communicate()
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;' \
- 'sys.stdout.write(sys.stdin.read())'],
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- p.stdin.write("banana")
- (stdout, stderr) = p.communicate("split")
- self.assertEqual(stdout, "bananasplit")
- self.assertEqual(remove_stderr_debug_decorations(stderr), "")
-
- def test_universal_newlines(self):
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;' + SETBINARY +
- 'sys.stdout.write("line1\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line2\\r");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line3\\r\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line4\\r");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("\\nline5");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("\\nline6");'],
- stdout=subprocess.PIPE,
- universal_newlines=1)
- stdout = p.stdout.read()
- if hasattr(open, 'newlines'):
- # Interpreter with universal newline support
- self.assertEqual(stdout,
- "line1\nline2\nline3\nline4\nline5\nline6")
- else:
- # Interpreter without universal newline support
- self.assertEqual(stdout,
- "line1\nline2\rline3\r\nline4\r\nline5\nline6")
-
- def test_universal_newlines_communicate(self):
- # universal newlines through communicate()
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;' + SETBINARY +
- 'sys.stdout.write("line1\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line2\\r");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line3\\r\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line4\\r");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("\\nline5");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("\\nline6");'],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- universal_newlines=1)
- (stdout, stderr) = p.communicate()
- if hasattr(open, 'newlines'):
- # Interpreter with universal newline support
- self.assertEqual(stdout,
- "line1\nline2\nline3\nline4\nline5\nline6")
- else:
- # Interpreter without universal newline support
- self.assertEqual(stdout, "line1\nline2\rline3\r\nline4\r\nline5\nline6")
-
- def test_no_leaking(self):
- # Make sure we leak no resources
- max_handles = 1026 # too much for most UNIX systems
- if mswindows:
- max_handles = 65 # a full test is too slow on Windows
- for i in range(max_handles):
- p = subprocess.Popen([sys.executable, "-c",
- "import sys;sys.stdout.write(sys.stdin.read())"],
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- data = p.communicate("lime")[0]
- self.assertEqual(data, "lime")
-
-
- def test_list2cmdline(self):
- self.assertEqual(subprocess.list2cmdline(['a b c', 'd', 'e']),
- '"a b c" d e')
- self.assertEqual(subprocess.list2cmdline(['ab"c', '\\', 'd']),
- 'ab\\"c \\ d')
- self.assertEqual(subprocess.list2cmdline(['a\\\\\\b', 'de fg', 'h']),
- 'a\\\\\\b "de fg" h')
- self.assertEqual(subprocess.list2cmdline(['a\\"b', 'c', 'd']),
- 'a\\\\\\"b c d')
- self.assertEqual(subprocess.list2cmdline(['a\\\\b c', 'd', 'e']),
- '"a\\\\b c" d e')
- self.assertEqual(subprocess.list2cmdline(['a\\\\b\\ c', 'd', 'e']),
- '"a\\\\b\\ c" d e')
-
-
- def test_poll(self):
- p = subprocess.Popen([sys.executable,
- "-c", "import time; time.sleep(1)"])
- count = 0
- while p.poll() is None:
- py.std.time.sleep(0.1)
- count += 1
- # We expect that the poll loop probably went around about 10 times,
- # but, based on system scheduling we can't control, it's possible
- # poll() never returned None. It "should be" very rare that it
- # didn't go around at least twice.
- self.assert_(count >= 2)
- # Subsequent invocations should just return the returncode
- self.assertEqual(p.poll(), 0)
-
-
- def test_wait(self):
- p = subprocess.Popen([sys.executable,
- "-c", "import time; time.sleep(2)"])
- self.assertEqual(p.wait(), 0)
- # Subsequent invocations should just return the returncode
- self.assertEqual(p.wait(), 0)
-
- #
- # POSIX tests
- #
- if not mswindows:
- def test_exceptions(self):
- # catched & re-raised exceptions
- try:
- p = subprocess.Popen([sys.executable, "-c", ""],
- cwd="/this/path/does/not/exist")
- except OSError, e:
- # The attribute child_traceback should contain "os.chdir"
- # somewhere.
- self.assertNotEqual(e.child_traceback.find("os.chdir"), -1)
- else:
- self.fail("Expected OSError")
-
- def test_run_abort(self):
- # returncode handles signal termination
- p = subprocess.Popen([sys.executable,
- "-c", "import os; os.abort()"])
- p.wait()
- self.assertEqual(-p.returncode, py.std.signal.SIGABRT)
-
- def test_preexec(self):
- # preexec function
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;' \
- 'sys.stdout.write(os.getenv("FRUIT"))'],
- stdout=subprocess.PIPE,
- preexec_fn=lambda: os.putenv("FRUIT", "apple"))
- self.assertEqual(p.stdout.read(), "apple")
-
- def test_close_fds(self):
- # Make sure we have some fds open
- os.pipe()
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;' \
- 'sys.stdout.write(str(os.dup(0)))'],
- stdout=subprocess.PIPE, close_fds=1)
- # When all fds are closed, the next free fd should be 3.
- self.assertEqual(p.stdout.read(), "3")
-
- def test_args_string(self):
- # args is a string
- f, fname = self.mkstemp()
- os.write(f, "#!/bin/sh\n")
- os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" %
- sys.executable)
- os.close(f)
- os.chmod(fname, 0700)
- p = subprocess.Popen(fname)
- p.wait()
- self.assertEqual(p.returncode, 47)
- os.remove(fname)
-
- def test_invalid_args(self):
- # invalid arguments should raise ValueError
- self.assertRaises(ValueError, subprocess.call,
- [sys.executable,
- "-c", "import sys; sys.exit(47)"],
- startupinfo=47)
- self.assertRaises(ValueError, subprocess.call,
- [sys.executable,
- "-c", "import sys; sys.exit(47)"],
- creationflags=47)
-
- def test_shell_sequence(self):
- # Run command through the shell (sequence)
- newenv = os.environ.copy()
- newenv["FRUIT"] = "apple"
- p = subprocess.Popen(["echo $FRUIT"], shell=1,
- stdout=subprocess.PIPE,
- env=newenv)
- self.assertEqual(p.stdout.read().strip(), "apple")
-
- def test_shell_string(self):
- # Run command through the shell (string)
- newenv = os.environ.copy()
- newenv["FRUIT"] = "apple"
- p = subprocess.Popen("echo $FRUIT", shell=1,
- stdout=subprocess.PIPE,
- env=newenv)
- self.assertEqual(p.stdout.read().strip(), "apple")
-
- def test_call_string(self):
- # call() function with string argument on UNIX
- f, fname = self.mkstemp()
- os.write(f, "#!/bin/sh\n")
- os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" %
- sys.executable)
- os.close(f)
- os.chmod(fname, 0700)
- rc = subprocess.call(fname)
- self.assertEqual(rc, 47)
-
-
- #
- # Windows tests
- #
- if mswindows:
- def test_startupinfo(self):
- # startupinfo argument
- # We uses hardcoded constants, because we do not want to
- # depend on win32all.
- STARTF_USESHOWWINDOW = 1
- SW_MAXIMIZE = 3
- startupinfo = subprocess.STARTUPINFO()
- startupinfo.dwFlags = STARTF_USESHOWWINDOW
- startupinfo.wShowWindow = SW_MAXIMIZE
- # Since Python is a console process, it won't be affected
- # by wShowWindow, but the argument should be silently
- # ignored
- subprocess.call([sys.executable, "-c", "import sys; sys.exit(0)"],
- startupinfo=startupinfo)
-
- def test_creationflags(self):
- # creationflags argument
- CREATE_NEW_CONSOLE = 16
- sys.stderr.write(" a DOS box should flash briefly ...\n")
- subprocess.call(sys.executable +
- ' -c "import time; time.sleep(0.25)"',
- creationflags=CREATE_NEW_CONSOLE)
-
- def test_invalid_args(self):
- # invalid arguments should raise ValueError
- self.assertRaises(ValueError, subprocess.call,
- [sys.executable,
- "-c", "import sys; sys.exit(47)"],
- preexec_fn=lambda: 1)
- self.assertRaises(ValueError, subprocess.call,
- [sys.executable,
- "-c", "import sys; sys.exit(47)"],
- close_fds=True)
-
- def test_shell_sequence(self):
- # Run command through the shell (sequence)
- newenv = os.environ.copy()
- newenv["FRUIT"] = "physalis"
- p = subprocess.Popen(["set"], shell=1,
- stdout=subprocess.PIPE,
- env=newenv)
- self.assertNotEqual(p.stdout.read().find("physalis"), -1)
-
- def test_shell_string(self):
- # Run command through the shell (string)
- newenv = os.environ.copy()
- newenv["FRUIT"] = "physalis"
- p = subprocess.Popen("set", shell=1,
- stdout=subprocess.PIPE,
- env=newenv)
- self.assertNotEqual(p.stdout.read().find("physalis"), -1)
-
- def test_call_string(self):
- # call() function with string argument on Windows
- rc = subprocess.call(sys.executable +
- ' -c "import sys; sys.exit(47)"')
- self.assertEqual(rc, 47)
-
-
-#def test_main():
-# test_support.run_unittest(ProcessTestCase)
-#
-#if __name__ == "__main__":
-# test_main()
Added: py/dist/py/path/local/popen5/testing/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/path/local/popen5/testing/__init__.py Mon Jan 3 13:14:26 2005
@@ -0,0 +1 @@
+#
\ No newline at end of file
Deleted: /py/dist/py/path/local/test_local.py
==============================================================================
--- /py/dist/py/path/local/test_local.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,199 +0,0 @@
-import py
-from py.path import local, checker
-from py.__impl__.path.test.fscommon import CommonFSTests, setuptestfs
-
-class LocalSetup:
- def setup_class(cls):
- cls.root = py.test.config.tmpdir / 'TestLocalPath'
- cls.root.ensure(dir=1)
- setuptestfs(cls.root)
-
- def setup_method(self, method):
- self.tmpdir = self.root.ensure('tmpdir', dir=1)
-
- def teardown_method(self, method):
- self.tmpdir.remove(rec=1)
-
-class TestLocalPath(LocalSetup, CommonFSTests):
- def test_initialize_curdir(self):
- assert str(local()) == py.std.os.getcwd()
-
- def test_initialize_reldir(self):
- curdir = py.std.os.curdir
- try:
- py.std.os.chdir(str(self.root))
- p = local('samplefile')
- assert p.check()
- finally:
- py.std.os.chdir(curdir)
-
- def test_eq_with_strings(self):
- path1 = self.root.join('sampledir')
- path2 = str(path1)
- assert path1 == path2
- assert path2 == path1
- path3 = self.root.join('samplefile')
- assert path3 != path2
- assert path2 != path3
-
- def test_dump(self):
- import tempfile
- try:
- fd, name = tempfile.mkstemp()
- f = py.std.os.fdopen(fd)
- except AttributeError:
- name = tempfile.mktemp()
- f = open(name, 'w+')
- try:
- d = {'answer' : 42}
- path = local(name)
- path.dumpobj(d)
- from cPickle import load
- dnew = load(f)
- assert d == dnew
- finally:
- f.close()
- py.std.os.remove(name)
-
- def test_setmtime(self):
- import tempfile
- import time
- try:
- fd, name = tempfile.mkstemp()
- py.std.os.close(fd)
- except AttributeError:
- name = tempfile.mktemp()
- open(name, 'w').close()
- try:
- mtime = int(time.time())-100
- path = local(name)
- assert path.mtime() != mtime
- path.setmtime(mtime)
- assert path.mtime() == mtime
- path.setmtime()
- assert path.mtime() != mtime
- finally:
- py.std.os.remove(name)
-
- def test_normpath(self):
- new1 = self.root.join("/otherdir")
- new2 = self.root.join("otherdir")
- assert str(new1) == str(new2)
-
- def test_mkdtemp_creation(self):
- d = local.mkdtemp()
- try:
- assert d.check(dir=1)
- finally:
- d.remove(rec=1)
-
- def test_tmproot(self):
- d = local.mkdtemp()
- tmproot = local.get_temproot()
- try:
- assert d.check(dir=1)
- assert d.dirpath() == tmproot
- finally:
- d.remove(rec=1)
-
- def test_chdir(self):
- tmpdir = self.tmpdir.realpath()
- old = local()
- try:
- res = tmpdir.chdir()
- assert str(res) == str(old)
- assert py.std.os.getcwd() == str(tmpdir)
- finally:
- old.chdir()
-
- def test_ensure_filepath_withdir(self):
- tmpdir = self.tmpdir
- newfile = tmpdir.join('test1','test2')
- newfile.ensure()
- assert newfile.check(file=1)
-
- def test_ensure_filepath_withoutdir(self):
- tmpdir = self.tmpdir
- newfile = tmpdir.join('test1')
- t = newfile.ensure()
- assert t == newfile
- assert newfile.check(file=1)
-
- def test_ensure_dirpath(self):
- tmpdir = self.tmpdir
- newfile = tmpdir.join('test1','test2')
- t = newfile.ensure(dir=1)
- assert t == newfile
- assert newfile.check(dir=1)
-
-class TestExecution(LocalSetup):
- disabled = py.std.sys.platform == 'win32'
-
- def test_sysfind(self):
- x = py.path.local.sysfind('test')
- assert x.check(file=1)
- py.test.raises(py.error.ENOENT, """
- py.path.local.sysfind('jaksdkasldqwe')
- """)
-
- def test_sysfind_multiple(self):
- dir = py.test.config.tmpdir.ensure('sysfind', dir=1)
- env = py.std.os.environ
- oldpath = env['PATH']
- try:
- env['PATH'] += ":%s:%s" % (dir.ensure('a'),
- dir.join('b'))
- dir.ensure('b', 'a')
- checker = lambda x: x.dirpath().basename == 'b'
- x = py.path.local.sysfind('a', checker=checker)
- assert x.basename == 'a'
- assert x.dirpath().basename == 'b'
- checker = lambda x: None
- py.test.raises(py.error.ENOENT, """
- py.path.local.sysfind('a', checker=checker)
- """)
- finally:
- env['PATH'] = oldpath
- #dir.remove()
-
- def test_sysexec(self):
- x = py.path.local.sysfind('ls')
- out = x.sysexec()
- for x in py.path.local():
- assert out.find(x.basename) != -1
-
- def test_sysexec_failing(self):
- x = py.path.local.sysfind('false')
- py.test.raises(py.process.cmdexec.Error, """
- x.sysexec('aksjdkasjd')
- """)
-
- def test_make_numbered_dir(self):
- root = self.tmpdir
- for i in range(10):
- numdir = local.make_numbered_dir(root, 'base.', keep=2)
- assert numdir.check()
- assert numdir.basename == 'base.%d' %i
- if i>=1:
- assert numdir.new(ext=str(i-1)).check()
- if i>=2:
- assert numdir.new(ext=str(i-2)).check()
- if i>=3:
- assert not numdir.new(ext=str(i-3)).check()
-
- def test_error_preservation(self):
- py.test.raises (EnvironmentError, self.root.join('qwoeqiwe').mtime)
- py.test.raises (EnvironmentError, self.root.join('qwoeqiwe').read)
-
- #def test_parentdirmatch(self):
- # local.parentdirmatch('std', startmodule=__name__)
-
-#class XTestLocalPath(TestLocalPath):
-# def __init__(self):
-# TestLocalPath.__init__(self)
-# self.root = local(self.root)
-#
-#class XXTestLocalPath(TestLocalPath):
-# def __init__(self):
-# TestLocalPath.__init__(self)
-# self.root = local(self.root)
Deleted: /py/dist/py/path/local/test_posix.py
==============================================================================
--- /py/dist/py/path/local/test_posix.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,178 +0,0 @@
-import py
-import sys
-from py.__impl__.path.test.fscommon import setuptestfs
-checker = py.path.checker
-local = py.path.local
-
-class TestPOSIXLocalPath:
- #root = local(TestLocalPath.root)
- disabled = sys.platform == 'win32'
-
- def setup_class(cls):
- cls.root = py.test.config.tmpdir / 'TestPosixLocalPath'
- cls.root.ensure(dir=1)
- setuptestfs(cls.root)
-
- def test_hardlink(self):
- tmpdir = local(local.mkdtemp())
- try:
- linkpath = tmpdir.join('test')
- filepath = tmpdir.join('file')
- filepath.write("Hello")
- linkpath.mklinkto(filepath)
- assert filepath.read() == linkpath.read()
- finally:
- tmpdir.remove(rec=1)
-
- def test_symlink_are_identical(self):
- tmpdir = local(local.mkdtemp())
- try:
- filepath = tmpdir.join('file')
- filepath.write("Hello")
- linkpath = tmpdir.join('test')
- linkpath.mksymlinkto(filepath)
- assert filepath.read() == linkpath.read()
- finally:
- tmpdir.remove(rec=1)
-
- def test_symlink_isfile(self):
- tmpdir = local(local.mkdtemp())
- try:
- linkpath = tmpdir.join('test')
- filepath = tmpdir.join('file')
- filepath.write("")
- linkpath.mksymlinkto(filepath)
- assert linkpath.check(file=1)
- assert not linkpath.check(link=0, file=1)
- finally:
- tmpdir.remove(rec=1)
-
- def test_symlink_relative(self):
- tmpdir = local(local.mkdtemp())
- try:
- linkpath = tmpdir.join('test')
- filepath = tmpdir.join('file')
- filepath.write("Hello")
- linkpath.mksymlinkto(filepath, absolute=False)
- assert linkpath.readlink() == "file"
- assert filepath.read() == linkpath.read()
- finally:
- tmpdir.remove(rec=1)
-
- def test_relto_with_root(self):
- y = self.root.join('x').relto(py.path.local('/'))
- assert y[0] == str(self.root)[1]
-
- def test_visit_recursive_symlink(self):
- tmpdir = local.mkdtemp()
- try:
- linkpath = tmpdir.join('test')
- linkpath.mksymlinkto(tmpdir)
- visitor = tmpdir.visit(None, checker(link=0))
- assert list(visitor) == [linkpath]
- #check.equal(list(tmpdir.visit()), [linkpath])
- finally:
- tmpdir.remove(rec=1)
-
- def test_symlink_isdir(self):
- tmpdir = local.mkdtemp()
- try:
- linkpath = tmpdir.join('test')
- linkpath.mksymlinkto(tmpdir)
- assert linkpath.check(dir=1)
- assert not linkpath.check(link=0, dir=1)
- finally:
- tmpdir.remove(rec=1)
-
- def test_symlink_remove(self):
- tmpdir = local.mkdtemp().realpath()
- try:
- linkpath = tmpdir.join('test')
- linkpath.mksymlinkto(linkpath) # point to itself
- assert linkpath.check(link=1)
- linkpath.remove()
- assert not linkpath.check()
- finally:
- tmpdir.remove(rec=1)
-
- def test_realpath_file(self):
- tmpdir = local.mkdtemp()
- try:
- linkpath = tmpdir.join('test')
- filepath = tmpdir.join('file')
- filepath.write("")
- linkpath.mksymlinkto(filepath)
- realpath = linkpath.realpath()
- assert realpath.basename == 'file'
- finally:
- tmpdir.remove(rec=1)
-
- def test_owner(self):
- from pwd import getpwuid
- assert getpwuid(self.root.stat().st_uid)[0] == self.root.owner()
-
- def test_group(self):
- from grp import getgrgid
- assert getgrgid(self.root.stat().st_gid)[0] == self.root.group()
-
- def XXXtest_atime(self):
- # XXX disabled. this test is just not platform independent enough
- # because acesstime resolution is very different through
- # filesystems even on one platform.
- import time
- path = self.root.join('samplefile')
- atime = path.atime()
- time.sleep(1)
- path.read(1)
- assert path.atime() != atime
-
- def testcommondir(self):
- # XXX This is here in local until we find a way to implement this
- # using the subversion command line api.
- p1 = self.root.join('something')
- p2 = self.root.join('otherthing')
- assert p1.commondir(p2) == self.root
- assert p2.commondir(p1) == self.root
-
- def testcommondir_nocommon(self):
- # XXX This is here in local until we find a way to implement this
- # using the subversion command line api.
- p1 = self.root.join('something')
- p2 = local(os.sep+'blabla')
- assert p1.commondir(p2) is None
-
-
- def test_chmod_simple_int(self):
- print "self.root is", self.root
- mode = self.root.mode()
- self.root.chmod(mode/2)
- try:
- assert self.root.mode() != mode
- finally:
- self.root.chmod(mode)
- assert self.root.mode() == mode
-
- def test_chmod_rec_int(self):
- # XXX fragile test
- print "self.root is", self.root
- recfilter = checker(dotfile=0)
- oldmodes = {}
- for x in self.root.visit(rec=recfilter):
- oldmodes[x] = x.mode()
- self.root.chmod(0772, rec=1)
- try:
- for x in self.root.visit(rec=recfilter):
- assert x.mode() & 0777 == 0772
- finally:
- for x,y in oldmodes.items():
- x.chmod(y)
-
- def test_chown_identity(self):
- owner = self.root.owner()
- group = self.root.group()
- self.root.chown(owner, group)
-
- def test_chown_identity_rec_mayfail(self):
- owner = self.root.owner()
- group = self.root.group()
- self.root.chown(owner, group)
Added: py/dist/py/path/local/testing/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/path/local/testing/__init__.py Mon Jan 3 13:14:26 2005
@@ -0,0 +1 @@
+#
\ No newline at end of file
Deleted: /py/dist/py/path/svn/svntestbase.py
==============================================================================
--- /py/dist/py/path/svn/svntestbase.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,107 +0,0 @@
-import py
-from py import path, test, process
-from py.__impl__.path.test.fscommon import CommonFSTests
-from py.__impl__.path.svn import cache
-
-class CommonSvnTests(CommonFSTests):
-
- def setup_method(self, meth):
- bn = meth.func_name
- for x in 'test_remove', 'test_move':
- if bn.startswith(x):
- py.test.skip(
- "tests for modifying svn needs better test state management")
-
- def test_propget(self):
- url = self.root.join("samplefile")
- value = url.propget('svn:eol-style')
- assert value == 'native'
-
- def test_proplist(self):
- url = self.root.join("samplefile")
- res = url.proplist()
- assert res['svn:eol-style'] == 'native'
-
- def test_info(self):
- url = self.root.join("samplefile")
- res = url.info()
- assert res.size > len("samplefile") and res.created_rev >= 0
-
- def xxxtest_info_log(self):
- url = self.root.join("samplefile")
- res = url.log(rev_start=1155, rev_end=1155, verbose=True)
- assert res[0].revision == 1155 and res[0].author == "jum"
- from time import gmtime
- t = gmtime(res[0].date)
- assert t.tm_year == 2003 and t.tm_mon == 7 and t.tm_mday == 17
-
-class CommonCommandAndBindingTests(CommonSvnTests):
- def test_trailing_slash_is_stripped(self):
- # XXX we need to test more normalizing properties
- url = self.root.join("/")
- assert self.root == url
-
- #def test_different_revs_compare_unequal(self):
- # newpath = self.root.new(rev=1199)
- # assert newpath != self.root
-
- def test_exists_svn_root(self):
- assert self.root.check()
-
- #def test_not_exists_rev(self):
- # url = self.root.__class__(self.rooturl, rev=500)
- # assert url.check(exists=0)
-
- #def test_nonexisting_listdir_rev(self):
- # url = self.root.__class__(self.rooturl, rev=500)
- # raises(py.error.ENOENT, url.listdir)
-
- #def test_newrev(self):
- # url = self.root.new(rev=None)
- # assert url.rev == None
- # assert url.strpath == self.root.strpath
- # url = self.root.new(rev=10)
- # assert url.rev == 10
-
- #def test_info_rev(self):
- # url = self.root.__class__(self.rooturl, rev=1155)
- # url = url.join("samplefile")
- # res = url.info()
- # assert res.size > len("samplefile") and res.created_rev == 1155
-
- # the following tests are easier if we have a path class
- def test_repocache_simple(self):
- repocache = cache.RepoCache()
- repocache.put(self.root.strpath, 42)
- url, rev = repocache.get(self.root.join('test').strpath)
- assert rev == 42
- assert url == self.root.strpath
-
- def test_repocache_notimeout(self):
- repocache = cache.RepoCache()
- repocache.timeout = 0
- repocache.put(self.root.strpath, self.root.rev)
- url, rev = repocache.get(self.root.strpath)
- assert rev == -1
- assert url == self.root.strpath
-
- def test_repocache_outdated(self):
- repocache = cache.RepoCache()
- repocache.put(self.root.strpath, 42, timestamp=0)
- url, rev = repocache.get(self.root.join('test').strpath)
- assert rev == -1
- assert url == self.root.strpath
-
- def _test_getreporev(self):
- """ this test runs so slow it's usually disabled """
- old = cache.repositories.repos
- try:
- _repocache.clear()
- root = self.root.new(rev=-1)
- url, rev = cache.repocache.get(root.strpath)
- assert rev>=0
- assert url == svnrepourl
- finally:
- repositories.repos = old
-
-#cache.repositories.put(svnrepourl, 1200, 0)
Deleted: /py/dist/py/path/svn/test_urlcommand.py
==============================================================================
--- /py/dist/py/path/svn/test_urlcommand.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,23 +0,0 @@
-import sys, os
-import py
-from svntestbase import CommonCommandAndBindingTests
-from test_wccommand import getrepowc
-
-class TestSvnCommandPath(CommonCommandAndBindingTests):
- def __init__(self):
- repo, wc = getrepowc()
- self.root = py.path.svnurl(repo)
-
- def xtest_copy_file(self):
- raise py.test.Skipped(msg="XXX fix svnurl first")
-
- def xtest_copy_dir(self):
- py.test.skipp("XXX fix svnurl first")
-
- def XXXtest_info_log(self):
- url = self.root.join("samplefile")
- res = url.log(rev_start=1155, rev_end=1155, verbose=True)
- assert res[0].revision == 1155 and res[0].author == "jum"
- from time import gmtime
- t = gmtime(res[0].date)
- assert t.tm_year == 2003 and t.tm_mon == 7 and t.tm_mday == 17
Deleted: /py/dist/py/path/svn/test_wccommand.py
==============================================================================
--- /py/dist/py/path/svn/test_wccommand.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,209 +0,0 @@
-import py
-from svntestbase import CommonSvnTests
-from py.__impl__.path.test.fscommon import setuptestfs
-
-# make a wc directory out of a given root url
-# cache previously obtained wcs!
-#
-def getrepowc():
- repo = py.test.config.tmpdir / 'path' / 'repo'
- wcdir = py.test.config.tmpdir / 'path' / 'wc'
- if not repo.check():
- assert not wcdir.check()
- repo.ensure(dir=1)
- try:
- py.process.cmdexec('svnadmin create %s' % repo)
- except py.process.cmdexec.Error:
- repo.remove()
- raise py.test.skip('could not create temporary svn test repository')
- wcdir.ensure(dir=1)
- print "created svn repository", repo
- wc = py.path.svnwc(wcdir)
- wc.checkout(url='file://%s' % repo)
- print "checked out new repo into", wc
- setuptestfs(wc)
- wc.join('samplefile').propset('svn:eol-style', 'native')
- wc.commit("testrepo setup rev 1")
- wc.ensure('anotherfile').write('hello')
- wc.commit('second rev')
- wc.join('anotherfile').write('world')
- wc.commit('third rev')
- else:
- print "using repository at %s" % repo
- wc = py.path.svnwc(wcdir)
- return ("file://%s" % repo, wc)
-
-class TestWCSvnCommandPath(CommonSvnTests):
- def __init__(self):
- repo, self.root = getrepowc()
-
- def test_status_attributes_simple(self):
- def assert_nochange(p):
- s = p.status()
- assert not s.modified
- assert not s.prop_modified
- assert not s.added
- assert not s.deleted
-
- dpath = self.root.join('sampledir')
- assert_nochange(self.root.join('sampledir'))
- assert_nochange(self.root.join('samplefile'))
-
- def test_status_added(self):
- nf = self.root.join('newfile')
- nf.write('hello')
- nf.add()
- try:
- s = nf.status()
- assert s.added
- assert not s.modified
- assert not s.prop_modified
- finally:
- nf.revert()
-
- def test_status_change(self):
- nf = self.root.join('samplefile')
- try:
- nf.write(nf.read() + 'change')
- s = nf.status()
- assert not s.added
- assert s.modified
- assert not s.prop_modified
- finally:
- nf.revert()
-
- def test_status_added_ondirectory(self):
- sampledir = self.root.join('sampledir')
- try:
- t2 = sampledir.mkdir('t2')
- t1 = t2.join('t1')
- t1.write('test')
- t1.add()
- s = sampledir.status(rec=1)
- assert t1 in s.added
- assert t2 in s.added
- finally:
- t2.revert(rec=1)
- t2.localpath.remove(rec=1)
-
- def test_status_unknown(self):
- t1 = self.root.join('un1')
- try:
- t1.write('test')
- s = self.root.status()
- assert t1 in s.unknown
- finally:
- t1.localpath.remove()
-
- def test_status_unchanged(self):
- r = self.root
- s = self.root.status(rec=1)
- assert r.join('samplefile') in s.unchanged
- assert r.join('sampledir') in s.unchanged
- assert r.join('sampledir/otherfile') in s.unchanged
-
- def test_status_update(self):
- r = self.root
- try:
- r.update(rev=1)
- s = r.status(updates=1, rec=1)
- assert r.join('anotherfile') in s.update_available
- #assert len(s.update_available) == 1
- finally:
- r.update()
-
- def test_diff(self):
- p = self.root / 'anotherfile'
- out = p.diff(rev=2)
- assert out.find('hello') != -1
-
- def test_join_abs(self):
- s = str(self.root.localpath)
- n = self.root.join(s, abs=1)
- assert self.root == n
-
- def test_join_abs2(self):
- assert self.root.join('samplefile', abs=1) == self.root.join('samplefile')
-
- def test_str_gives_localpath(self):
- assert str(self.root) == str(self.root.localpath)
-
- def test_versioned(self):
- assert self.root.check(versioned=1)
- assert self.root.join('samplefile').check(versioned=1)
- assert not self.root.join('notexisting').check(versioned=1)
- notexisting = self.root.join('hello').localpath
- try:
- notexisting.write("")
- assert self.root.join('hello').check(versioned=0)
- finally:
- notexisting.remove()
-
- def test_properties(self):
- try:
- self.root.propset('gaga', 'this')
- assert self.root.propget('gaga') == 'this'
- assert self.root in self.root.status().prop_modified
- assert 'gaga' in self.root.proplist()
- assert self.root.proplist()['gaga'] == 'this'
-
- finally:
- self.root.propdel('gaga')
-
- def test_proplist_recursive(self):
- s = self.root.join('samplefile')
- s.propset('gugu', 'that')
- try:
- p = self.root.proplist(rec=1)
- assert self.root / 'samplefile' in p
- finally:
- s.propdel('gugu')
-
- def test_long_properties(self):
- value = """
- vadm:posix : root root 0100755
- Properties on 'chroot/dns/var/bind/db.net.xots':
- """
- try:
- self.root.propset('gaga', value)
- backvalue = self.root.propget('gaga')
- assert backvalue == value
- #assert len(backvalue.split('\n')) == 1
- finally:
- self.root.propdel('gaga')
-
-
- def test_ensure(self):
- newpath = self.root.ensure('a', 'b', 'c')
- try:
- assert newpath.check(exists=1, versioned=1)
- finally:
- self.root.join('a').remove(force=1)
-
- def test_not_versioned(self):
- p = self.root.localpath.mkdir('whatever')
- f = self.root.localpath.ensure('testcreatedfile')
- try:
- assert self.root.join('whatever').check(versioned=0)
- assert self.root.join('testcreatedfile').check(versioned=0)
- assert not self.root.join('testcreatedfile').check(versioned=1)
- finally:
- p.remove(rec=1)
- f.remove()
-
- #def test_log(self):
- # l = self.root.log()
- # assert len(l) == 3 # might need to be upped if more tests are added
-
-class XTestWCSvnCommandPathSpecial:
-
- rooturl = 'http://codespeak.net/svn/py.path/trunk/dist/py.path/test/data'
- #def test_update_none_rev(self):
- # path = tmpdir.join('checkouttest')
- # wcpath = newpath(xsvnwc=str(path), url=self.rooturl)
- # try:
- # wcpath.checkout(rev=2100)
- # wcpath.update()
- # assert wcpath.info().rev > 2100
- # finally:
- # wcpath.localpath.remove(rec=1)
Added: py/dist/py/path/svn/testing/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/path/svn/testing/__init__.py Mon Jan 3 13:14:26 2005
@@ -0,0 +1 @@
+#
\ No newline at end of file
Modified: py/dist/py/path/test/test_api.py
==============================================================================
--- py/dist/py/path/test/test_api.py (original)
+++ py/dist/py/path/test/test_api.py Mon Jan 3 13:14:26 2005
@@ -1,5 +1,5 @@
from py import path, test
-from py.__impl__.path.svn.test_wccommand import getrepowc
+from py.__impl__.path.svn.testing.test_wccommand import getrepowc
class TestAPI:
def __init__(self):
Deleted: /py/dist/py/process/test_cmdexec.py
==============================================================================
--- /py/dist/py/process/test_cmdexec.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,25 +0,0 @@
-from py import test
-from py.process import cmdexec
-
-class Test_exec_cmd:
- def test_simple(self):
- out = cmdexec('echo hallo')
- assert out.strip() == 'hallo'
-
- def test_simple_error(self):
- test.raises (cmdexec.Error, cmdexec, 'exit 1')
-
- def test_simple_error_exact_status(self):
- try:
- cmdexec('exit 1')
- except cmdexec.Error, e:
- assert e.status == 1
-
- def test_err(self):
- try:
- cmdexec('echoqweqwe123 hallo')
- raise AssertionError, "command succeeded but shouldn't"
- except cmdexec.Error, e:
- assert hasattr(e, 'err')
- assert hasattr(e, 'out')
- assert e.err or e.out
Added: py/dist/py/process/testing/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/process/testing/__init__.py Mon Jan 3 13:14:26 2005
@@ -0,0 +1 @@
+#
\ No newline at end of file
Deleted: /py/dist/py/test/report/test_memo.py
==============================================================================
--- /py/dist/py/test/report/test_memo.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,27 +0,0 @@
-import py
-
-def setup_module(mod):
- mod.tmpdir = py.path.local.make_numbered_dir()
-def teardown_module(mod):
- mod.tmpdir.remove()
- del mod.tmpdir
-
-#def test_equal_should_raise():
-# check.equal(1,2)
-
-#class MyUnit(collect.Auto, collect.Unit):
-# def execute(self, runner):
-# try:
-#
-def test_memoreporter():
- reporter = py.test.MemoReporter()
- p = tmpdir.join('memoimport.py')
- p.write('raise IOError')
- collector = py.test.collect.Module(p)
- #main(collector=collector, reporter=reporter)
- #collect_errors = reporter.getlist(collect.Error)
- #assert len(collect_errors) == 1
- ##print collect_errors
-
-if __name__=='__main__':
- test.main()
Added: py/dist/py/test/report/testing/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/test/report/testing/__init__.py Mon Jan 3 13:14:26 2005
@@ -0,0 +1 @@
+#
\ No newline at end of file
Deleted: /py/dist/py/test/test_collect.py
==============================================================================
--- /py/dist/py/test/test_collect.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,143 +0,0 @@
-from __future__ import generators
-import py
-from py.__impl__.test import collect
-autopath = py.magic.autopath()
-testdir = autopath.dirpath('test')
-assert testdir.check(dir=1)
-datadir = testdir / 'data'
-
-
-def test_failing_import_execfile():
- fn = datadir / 'failingimport.py'
- l = list(collect.Module(py.path.extpy(fn)))
- assert l
- ex, = l
- assert issubclass(ex.excinfo.type, ImportError)
-
-def test_failing_import_directory():
- class MyDirectory(collect.Directory):
- fil = py.path.checker(basestarts="testspecial_", ext='.py')
- l = list(MyDirectory(datadir))
- assert len(l) == 1
- assert isinstance(l[0], collect.Module)
- l2 = list(l[0])
- assert l2
- exc = l2[0]
- assert isinstance(exc, collect.Error)
- assert issubclass(exc.excinfo.type, ImportError)
-
-def test_module_file_not_found():
- fn = testdir.join('nada','no')
- l = list(collect.Module(fn))
- assert len(l) == 1
- assert isinstance(l[0], collect.Error)
- assert isinstance(l[0].excinfo.value, py.error.ENOENT)
-
-def test_syntax_error_in_module():
- modpath = py.path.extpy(datadir.join('syntax_error.py'))
- l2 = list(collect.Module(modpath))
- assert len(l2) == 1
- assert isinstance(l2[0], collect.Error)
- assert issubclass(l2[0].excinfo.type, SyntaxError)
-
-def test_disabled_class():
- extpy = py.path.extpy(datadir.join('disabled.py'))
- l = list(collect.Class(extpy))
- assert len(l) == 0
-
-class TestCustomCollector:
- def test_custom_collect(self):
- l = list(collect.Module(datadir.join('Collector.py')))
- for item in l:
- assert isinstance(item, py.test.Item)
- assert len(l) == 3
- #for x in l2:
- # assert isinstance(x, Unit)
- # x.execute()
-
-class Testsomeclass:
- disabled = True
- def test_something():
- raise ValueError
-
-l = []
-def test_1():
- l.append(1)
-def test_2():
- l.append(2)
-def test_3():
- assert l == [1,2]
-class Testmygroup:
- reslist = []
- def test_1(self):
- self.reslist.append(1)
- def test_2(self):
- self.reslist.append(2)
- def test_3(self):
- self.reslist.append(3)
- def test_4(self):
- assert self.reslist == [1,2,3]
-
-#
-# some tests related to "generating tests"
-#
-l2=[]
-
-def func1():
- print "in func1"
- l2.append(1)
-
-def func2(i):
- print "in func2 with param %d" % i
- l2.append(i)
-
-def test_generator():
- yield func1
- yield func2, 2
- yield func2, 3
-
-def test_stateful_previous():
- x = l2
- assert x == [1,2,3]
-
-class TestGeneratorMethod:
- l3 = []
- def func1(self, i):
- self.l3.append(i)
-
- def test_generator(self):
- yield self.func1, 4
- yield self.func1, 5
-
- def test_previous_generator_worked(self):
- assert self.l3 == [4,5]
-
-def test_custom_collection_from_conftest():
- o = py.test.config.tmpdir.ensure('customconfigtest', dir=1)
- o.ensure('conftest.py').write("""if 1:
- import py
- class MyItem(py.test.Item):
- pass
- class Directory(py.test.collect.Directory):
- def fil(self, fspath):
- return fspath.check(basestarts='check_')
- class Module(py.test.collect.Module):
- def collect_function(self, extpy):
- if extpy.check(basestarts='check_', func=1):
- yield self.Item(extpy)
- class Class(py.test.collect.Class):
- def collect_method(self, extpy):
- if extpy.check(basestarts='check_', func=1):
- yield MyItem(extpy)
- """)
- o.ensure('somedir', 'check_something').write("""if 1:
- def check_func():
- assert 42 == 42
- class TestClass:
- def check_method(self):
- assert 23 == 23
- """)
- from py.__impl__.test.collect import getfscollector
- units = list(getfscollector(o).iterunits())
- assert len(units) == 2
- assert units[1].__class__.__name__ == 'MyItem'
Deleted: /py/dist/py/test/test_compat.py
==============================================================================
--- /py/dist/py/test/test_compat.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,51 +0,0 @@
-from __future__ import generators
-import py
-
-class TestCompatTestCaseSetupSemantics(py.test.compat.TestCase):
- globlist = []
-
- def setUp(self):
- self.__dict__.setdefault('l', []).append(42)
- self.globlist.append(self)
-
- def tearDown(self):
- self.l.pop()
-
- def test_issetup(self):
- l = self.l
- assert len(l) == 1
- assert l[-1] == 42
- self.checkmultipleinstances()
-
- def test_issetup2(self):
- l = self.l
- assert len(l) == 1
- assert l[-1] == 42
- self.checkmultipleinstances()
-
- def checkmultipleinstances(self):
- for x,y in zip(self.globlist, self.globlist[1:]):
- assert x is not y
-
-class TestCompatAssertions(py.test.compat.TestCase):
- nameparamdef = {
- 'failUnlessEqual,assertEqual,assertEquals': ('1, 1', '1, 0'),
- 'assertNotEquals,failIfEqual': ('0, 1', '0,0'),
- 'failUnless,assert_': ('1', 'None'),
- 'failIf': ('0', '1'),
- }
-
- sourcelist = []
- for names, (paramok, paramfail) in nameparamdef.items():
- for name in names.split(','):
- source = """
- def test_%(name)s(self):
- self.%(name)s(%(paramok)s)
- #self.%(name)s(%(paramfail)s)
-
- def test_%(name)s_failing(self):
- self.assertRaises(py.test.Item.Failed,
- self.%(name)s, %(paramfail)s)
- """ % locals()
- co = py.code.Source(source).compile()
- exec co
Deleted: /py/dist/py/test/test_config.py
==============================================================================
--- /py/dist/py/test/test_config.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,52 +0,0 @@
-from __future__ import generators
-import py
-config = py.test.config
-
-class MyClass:
- def getoptions(self):
- yield config.Option('-v', action="count", dest="verbose", help="verbose")
-
-def xtest_verbose():
- obj = MyClass()
- args = config.parseargs(['-v', 'hello'], obj)
- assert args == ['hello']
- assert hasattr(obj, 'option')
- assert hasattr(obj.option, 'verbose')
- assert obj.option.verbose
-
-def xtest_verbose_default():
- obj = MyClass()
- args = config.parseargs(['hello'], obj)
- assert args, ['hello']
- assert hasattr(obj, 'option')
- assert hasattr(obj.option, 'verbose')
- assert not obj.option.verbose
-
-def test_tmpdir():
- d1 = config.tmpdir
- d2 = config.tmpdir
- assert d1 == d2
-
-def test_config_order():
- from py.__impl__.test import config
- o = py.test.config.tmpdir.ensure('configorder', dir=1)
- o.ensure('conftest.py').write('x=1 ; import py ; py._x = [x]')
- o.ensure('a/conftest.py').write('x=2 ; import py ; py._x.append(x)')
- o.ensure('a/b/c/conftest.py').write('x=3 ; import py ; py._x.append(x)')
- cfg = config.Config()
- cfg.readconfiguration(o)
- assert cfg.getfirst('x') == 1
- assert py._x == [1]
-
- cfg = config.Config()
- cfg.readconfiguration(o.join('a/b/c'))
- assert cfg.getfirst('x') == 1
- assert py._x == [1,2,3]
-
-def test_getconfigvalue():
- from py.__impl__.test import config
- cfg = config.Config()
- o = py.test.config.tmpdir.ensure('configtest', dir=1)
- o.ensure('conftest.py').write('x=1')
- assert cfg.getconfigvalue(o, 'x') == 1
- py.test.raises(ValueError, "cfg.getconfigvalue(o, 'y')")
Deleted: /py/dist/py/test/test_raises.py
==============================================================================
--- /py/dist/py/test/test_raises.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,14 +0,0 @@
-from py import test
-
-def somefunc(x, y):
- assert x == y
-
-class TestClass:
- def test_raises(self):
- test.raises(ValueError, "int('qwe')")
-
- def test_raises_syntax_error(self):
- test.raises(SyntaxError, "qwe qwe qwe")
-
- def test_raises_function(self):
- test.raises(ValueError, int, 'hello')
Added: py/dist/py/test/testing/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/test/testing/__init__.py Mon Jan 3 13:14:26 2005
@@ -0,0 +1 @@
+#
\ No newline at end of file
Deleted: /py/dist/py/test/tool/test_outerrcapture.py
==============================================================================
--- /py/dist/py/test/tool/test_outerrcapture.py Mon Jan 3 13:14:26 2005
+++ (empty file)
@@ -1,24 +0,0 @@
-import sys
-from py import test
-from py.__impl__.test.tool.outerrcapture import SimpleOutErrCapture
-
-def test_capturing_simple():
- cap = SimpleOutErrCapture()
- print "hello world"
- print >>sys.stderr, "hello error"
- out, err = cap.reset()
- assert out == "hello world\n"
- assert err == "hello error\n"
-
-def test_capturing_error():
- cap = SimpleOutErrCapture()
- print "hello"
- cap.reset()
- test.raises(AttributeError, "cap.reset()")
-
-def test_capturing_error_recursive():
- cap = SimpleOutErrCapture()
- cap2 = SimpleOutErrCapture()
- print "hello"
- cap2.reset()
- test.raises(AttributeError, "cap2.reset()")
Added: py/dist/py/test/tool/testing/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/test/tool/testing/__init__.py Mon Jan 3 13:14:26 2005
@@ -0,0 +1 @@
+#
\ No newline at end of file
More information about the pytest-commit
mailing list