[py-svn] r6940 - in py/dist/py: . execnet magic path path/local path/pypath path/svn path/svnwc process test test/report test/tool
hpk at codespeak.net
hpk at codespeak.net
Thu Oct 14 22:00:11 CEST 2004
Author: hpk
Date: Thu Oct 14 22:00:10 2004
New Revision: 6940
Added:
py/dist/py/execnet/test_gateway.py
- copied unchanged from r6931, py/dist/py/execnet/gateway_test.py
py/dist/py/execnet/test_source.py
- copied unchanged from r6931, py/dist/py/execnet/source_test.py
py/dist/py/magic/test_assertion.py
- copied unchanged from r6931, py/dist/py/magic/assertion_test.py
py/dist/py/magic/test_autopath.py
- copied unchanged from r6934, py/dist/py/magic/autopath_test.py
py/dist/py/magic/test_dyncode.py
- copied unchanged from r6931, py/dist/py/magic/dyncode_test.py
py/dist/py/magic/test_exprinfo.py
- copied unchanged from r6931, py/dist/py/magic/exprinfo_test.py
py/dist/py/magic/test_invoke.py
- copied, changed from r6931, py/dist/py/magic/invoke_test.py
py/dist/py/magic/test_patch.py
- copied unchanged from r6931, py/dist/py/magic/patch_test.py
py/dist/py/magic/test_viewtype.py
- copied unchanged from r6931, py/dist/py/magic/viewtype_test.py
py/dist/py/path/local/test_local.py
- copied unchanged from r6934, py/dist/py/path/local/local_test.py
py/dist/py/path/pypath/test_pypath.py
- copied unchanged from r6931, py/dist/py/path/pypath/pypath_test.py
py/dist/py/path/svn/test_command.py
- copied, changed from r6934, py/dist/py/path/svn/command_test.py
py/dist/py/path/svnwc/test_command.py
- copied unchanged from r6934, py/dist/py/path/svnwc/command_test.py
py/dist/py/path/test_api.py
- copied, changed from r6931, py/dist/py/path/api_test.py
py/dist/py/process/test_cmdexec.py
- copied unchanged from r6931, py/dist/py/process/cmdexec_test.py
py/dist/py/test/report/test_memo.py
- copied unchanged from r6931, py/dist/py/test/report/memo_test.py
py/dist/py/test/test_collect.py
- copied unchanged from r6931, py/dist/py/test/collect_test.py
py/dist/py/test/test_compat.py
- copied unchanged from r6931, py/dist/py/test/compat_test.py
py/dist/py/test/test_config.py
- copied unchanged from r6931, py/dist/py/test/config_test.py
py/dist/py/test/test_raises.py
- copied unchanged from r6931, py/dist/py/test/raises_test.py
py/dist/py/test/tool/test_outerrcapture.py
- copied unchanged from r6931, py/dist/py/test/tool/outerrcapture_test.py
py/dist/py/test_api.py
- copied unchanged from r6931, py/dist/py/api_test.py
py/dist/py/test_initpkg.py
- copied unchanged from r6931, py/dist/py/initpkg_test.py
Removed:
py/dist/py/api_test.py
py/dist/py/execnet/gateway_test.py
py/dist/py/execnet/source_test.py
py/dist/py/initpkg_test.py
py/dist/py/magic/assertion_test.py
py/dist/py/magic/autopath_test.py
py/dist/py/magic/dyncode_test.py
py/dist/py/magic/exprinfo_test.py
py/dist/py/magic/invoke_test.py
py/dist/py/magic/patch_test.py
py/dist/py/magic/viewtype_test.py
py/dist/py/path/api_test.py
py/dist/py/path/local/local_test.py
py/dist/py/path/pypath/pypath_test.py
py/dist/py/path/svn/command_test.py
py/dist/py/path/svnwc/command_test.py
py/dist/py/process/cmdexec_test.py
py/dist/py/test/collect_test.py
py/dist/py/test/compat_test.py
py/dist/py/test/config_test.py
py/dist/py/test/raises_test.py
py/dist/py/test/report/memo_test.py
py/dist/py/test/tool/outerrcapture_test.py
Modified:
py/dist/py/execnet/register.py
Log:
- move XX_test.py to test_XX.py for all testfiles.
i was getting tired of having "completion" collissions
and it seems more consistent to always require a
test or "Test" prefix for test files, classes and methods
Deleted: /py/dist/py/api_test.py
==============================================================================
--- /py/dist/py/api_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,54 +0,0 @@
-
-from py.test import raises
-import py
-import sys
-import inspect
-
-class API_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', 'py')
- assert_class('py.path', 'checker')
- assert_class('py.path', 'invchecker')
- assert_class('py.path', 'NotFound')
- assert_class('py.path', 'Denied')
-
- 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')
-
- assert inspect.ismodule(py.magic.dyncode)
- assert_function('py.magic.dyncode', 'compile')
- assert_function('py.magic.dyncode', 'compile2')
- assert_function('py.magic.dyncode', 'findsource')
- assert_function('py.magic.dyncode', 'getsource')
- assert_function('py.magic.dyncode', 'listtb')
- assert_function('py.magic.dyncode', 'findsource')
-
- def test_process_entrypoints(self):
- assert_function('py.process', 'cmdexec')
-
- def test_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/execnet/gateway_test.py
==============================================================================
--- /py/dist/py/execnet/gateway_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,177 +0,0 @@
-import os, sys
-import py
-from py.__impl__.execnet.source import Source
-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)
-
- def test_channel_close(self):
- channel = self.fac.new()
- channel._close()
- channel.waitclose(0.1)
-
- def test_channel_close_error(self):
- channel = self.fac.new()
- channel._close("error")
- py.test.raises(gateway.RemoteError, channel.waitclose, 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')
- import time
- time.sleep(0.1)
- x = channel.receive()
- assert x == 42
- py.test.raises(gateway.RemoteError, channel.receive)
-
-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 = 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
Modified: py/dist/py/execnet/register.py
==============================================================================
--- py/dist/py/execnet/register.py (original)
+++ py/dist/py/execnet/register.py Thu Oct 14 22:00:10 2004
@@ -5,7 +5,6 @@
import py
from py.__impl__.execnet import inputoutput, gateway
-py.magic.invoke(dyncode=True)
class InstallableGateway(gateway.Gateway):
""" initialize gateways on both sides of a inputoutput object. """
Deleted: /py/dist/py/execnet/source_test.py
==============================================================================
--- /py/dist/py/execnet/source_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,40 +0,0 @@
-
-from py.__impl__.execnet.source import Source
-
-def test_source_str_function():
- x = Source("3")
- assert str(x) == "3"
-
- x = Source(" 3")
- assert str(x) == "3"
-
- x = Source("""
- 3
- """)
- assert str(x) == "3"
-
-def test_source_indent_simple():
- source = Source("raise ValueError")
- source.putaround(
- "try:",
- """
- except ValueError:
- x = 42
- else:
- x = 23""")
- assert str(source)=="""\
-try:
- raise ValueError
-except ValueError:
- x = 42
-else:
- x = 23"""
-
-def XXXtest_source_indent_simple():
- x = StrSource("x=3")
- assert not x.isindented()
- x.indent("try:", "except: pass")
- assert x.read() == "try:\n x=3\nexcept: pass"
-
- #x.indent("try:",
- # """except:
Deleted: /py/dist/py/initpkg_test.py
==============================================================================
--- /py/dist/py/initpkg_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,60 +0,0 @@
-import py
-import types
-
-def test_dir():
- for name in dir(py):
- if not name.startswith('_'):
- obj = getattr(py, name)
- if isinstance(obj, types.ModuleType):
- 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()
- 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
- if relpath.find('test/data') != -1:
- continue
- if relpath.find('bin/') != -1:
- continue
- 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()
-
-# 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/magic/assertion_test.py
==============================================================================
--- /py/dist/py/magic/assertion_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,43 +0,0 @@
-
-from py.test import main
-from py.__impl__.magic import assertion
-
-def f():
- return 2
-
-def test_assert():
- assertion.invoke()
- try:
- try:
- assert f() == 3
- except AssertionError, e:
- s = str(e)
- assert s.startswith('assert 2 == 3\n')
- finally:
- assertion.revoke()
-
-def test_assert_multiline_1():
- assertion.invoke()
- try:
- try:
- assert (f() ==
- 3)
- except AssertionError, e:
- s = str(e)
- assert s.startswith('assert 2 == 3\n')
- finally:
- assertion.revoke()
-
-def test_assert_multiline_2():
- assertion.invoke()
- try:
- try:
- assert (f() == (4,
- 3)[-1])
- except AssertionError, e:
- s = str(e)
- assert s.startswith('assert 2 ==')
- finally:
- assertion.revoke()
-
-main()
Deleted: /py/dist/py/magic/autopath_test.py
==============================================================================
--- /py/dist/py/magic/autopath_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,91 +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
-
-py.test.main()
Deleted: /py/dist/py/magic/dyncode_test.py
==============================================================================
--- /py/dist/py/magic/dyncode_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,78 +0,0 @@
-import sys
-import os
-#print "dyncode_test: __name__ ==", __name__
-from py import test
-from py.__impl__.magic import dyncode
-
-def test_dyncode_trace():
- source = """
- def f():
- raise ValueError
- """
- co = dyncode.compile2(source)
- exec co
- excinfo = test.raises(ValueError, f)
- filename, lineno = dyncode.tbinfo(excinfo[2])
- line = dyncode.getline(filename, lineno)
- assert line.strip() == 'raise ValueError'
-
-def test_dyncode_trace_multiple():
- test_dyncode_trace()
- test_dyncode_trace()
-
-def test_unique_filenames():
- fn1 = dyncode._makedynfilename('fn','source')
- fn2 = dyncode._makedynfilename('fn','source')
- assert fn1 != fn2
-
-def test_syntaxerror_rerepresentation():
- ex = test.raises(SyntaxError, dyncode.compile2, 'x x')[1]
- assert ex.lineno == 1
- assert ex.offset == 3
- assert ex.text.strip(), 'x x'
-
-def test_getfuncsource_dynamic():
- source = """
- def f():
- raise ValueError
-
- def g(): pass
- """
- co = dyncode.compile2(source)
- exec co
- source = dyncode.getsource(f)
- assert dyncode.getsource(f) == 'def f():\n raise ValueError\n'
- assert dyncode.getsource(g) == 'def g(): pass\n'
-
-def test_getpyfile():
- fn = dyncode.getpyfile(dyncode)
- assert os.path.exists(fn)
-
-def test_getstartingblock_singleline():
- class A:
- def __init__(self, *args):
- frame = sys._getframe(1)
- self.source = dyncode.getparseablestartingblock(frame)
-
- x = A('x', 'y')
-
- l = [i for i in x.source.split('\n') if i.strip()]
- assert len(l) == 1
-
-def test_getstartingblock_multiline():
- class A:
- def __init__(self, *args):
- frame = sys._getframe(1)
- self.source = dyncode.getparseablestartingblock(frame)
-
- x = A('x',
- 'y' \
- ,
- 'z')
-
- l = [i for i in x.source.split('\n') if i.strip()]
- assert len(l) == 4
-
-if __name__ == '__main__':
- test.main()
-
Deleted: /py/dist/py/magic/exprinfo_test.py
==============================================================================
--- /py/dist/py/magic/exprinfo_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,54 +0,0 @@
-
-import sys
-from py.test import main
-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 == 'AssertionError: assert 1 == 2'
-
-def global_f():
- return 42
-
-def test_exprinfo_funccall():
- def g():
- assert global_f() == 43
- excinfo = getexcinfo(AssertionError, g)
- msg = getmsg(excinfo)
- assert msg == 'AssertionError: 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 DummyFrame:
- f_globals = f_locals = {}
- for exstr in "SystemExit", "KeyboardInterrupt", "MemoryError":
- ex = eval(exstr)
- try:
- interpret("raise %s" % exstr, DummyFrame)
- except ex:
- pass
- else:
- raise AssertionError, "ex %s didn't pass through" %(exstr, )
-
-main()
Deleted: /py/dist/py/magic/invoke_test.py
==============================================================================
--- /py/dist/py/magic/invoke_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,34 +0,0 @@
-import __builtin__ as bltin
-from py.magic import invoke, revoke
-from py.test import raises
-import inspect
-
-def check_dyncode():
- co = compile('x=3', 'bogus', 'exec')
- s = inspect.getfile(co)
- assert s
- line = inspect.getsource(co)
- assert line.strip() == "x=3"
-
-def check_assertion():
- excinfo = raises(AssertionError, "assert 1 == 2")
- value = excinfo[1]
- print value
- assert str(value) == "assert 1 == 2"
-
-def test_invoke_dyncode():
- old = compile
- invoke(dyncode=True)
- try:
- assert compile != old
- check_dyncode()
- finally:
- revoke(dyncode=True)
-
-def test_invoke_assertion():
- invoke(assertion=True)
- try:
- check_assertion()
- finally:
- revoke(assertion=True)
-
Deleted: /py/dist/py/magic/patch_test.py
==============================================================================
--- /py/dist/py/magic/patch_test.py Thu Oct 14 22:00:10 2004
+++ (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')")
-
Copied: py/dist/py/magic/test_invoke.py (from r6931, py/dist/py/magic/invoke_test.py)
==============================================================================
--- py/dist/py/magic/invoke_test.py (original)
+++ py/dist/py/magic/test_invoke.py Thu Oct 14 22:00:10 2004
@@ -1,6 +1,5 @@
import __builtin__ as bltin
-from py.magic import invoke, revoke
-from py.test import raises
+import py
import inspect
def check_dyncode():
@@ -11,24 +10,24 @@
assert line.strip() == "x=3"
def check_assertion():
- excinfo = raises(AssertionError, "assert 1 == 2")
+ excinfo = py.test.raises(AssertionError, "assert 1 == 2")
value = excinfo[1]
print value
assert str(value) == "assert 1 == 2"
def test_invoke_dyncode():
old = compile
- invoke(dyncode=True)
+ py.magic.invoke(dyncode=True)
try:
assert compile != old
check_dyncode()
finally:
- revoke(dyncode=True)
+ py.magic.revoke(dyncode=True)
def test_invoke_assertion():
- invoke(assertion=True)
+ py.magic.invoke(assertion=True)
try:
check_assertion()
finally:
- revoke(assertion=True)
+ py.magic.revoke(assertion=True)
Deleted: /py/dist/py/magic/viewtype_test.py
==============================================================================
--- /py/dist/py/magic/viewtype_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,59 +0,0 @@
-from py import test
-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"]
-
-test.main()
-
Deleted: /py/dist/py/path/api_test.py
==============================================================================
--- /py/dist/py/path/api_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,59 +0,0 @@
-from py import path, test
-from py.__impl__.path.svnwc.command_test import getrepowc
-
-class TestAPI:
- def __init__(self):
- self.root = test.config.tmpdir.ensure('local', dir=1)
-
- def repr_eval_test(self, p):
- r = repr(p)
- from py.path import local,svnurl, svnwc, py
- y = eval(r)
- assert y == p
-
- def test_defaultlocal(self):
- p = path.local()
- assert hasattr(p, 'atime')
- assert hasattr(p, 'group')
- assert hasattr(p, 'setmtime')
- assert p.check()
- assert p.check(local=1)
- assert p.check(svnwc=0)
- assert not p.check(svnwc=1)
- self.repr_eval_test(p)
-
- #assert p.std.path()
-
- def test_xlocal(self):
- p = path.local()
- assert hasattr(p, 'atime')
- assert hasattr(p, 'setmtime')
- assert p.check()
- assert p.check(local=1)
- self.repr_eval_test(p)
-
- def test_svnurl(self):
- p = path.svnurl('http://codespeak.net/svn/py.path')
- assert p.check(svnurl=1)
- self.repr_eval_test(p)
-
- def test_svnwc(self):
- p = path.svnwc(self.root)
- assert p.check(svnwc=1)
- self.repr_eval_test(p)
-
- def test_passing_svnurl(self):
- repourl, rootwc = getrepowc()
- p = path.svnurl(repourl)
- assert p.check()
- w = path.svnwc(None, p)
- self.repr_eval_test(p)
-
- def test_pypath(self):
- p = path.py('smtplib.SMTP')
- self.repr_eval_test(p)
-
-
-if __name__ == '__main__':
- test.main()
-
Deleted: /py/dist/py/path/local/local_test.py
==============================================================================
--- /py/dist/py/path/local/local_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,359 +0,0 @@
-import sys, os
-from py.test import main, raises, config
-from py.path import local, checker
-from py.__impl__.path.test.commonfs import CommonFSTests, setuptestfs
-
-class TestLocalPath(CommonFSTests):
- def __init__(self):
- print "tmpdir is", config.tmpdir
- self.root = config.tmpdir / 'local'
- self.root.ensure(dir=1)
- setuptestfs(self.root)
-
- def test_initialize_curdir(self):
- assert str(local()) == os.getcwd()
-
- def test_initialize_reldir(self):
- curdir = os.curdir
- try:
- os.chdir(str(self.root))
- p = local('samplefile')
- assert p.check()
- finally:
- 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 = 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()
- os.remove(name)
-
- def test_setmtime(self):
- import tempfile
- import time
- try:
- fd, name = tempfile.mkstemp()
- 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:
- 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_ensure_filepath_withdir(self):
- tmpdir = local.mkdtemp()
- try:
- newfile = tmpdir.join('test1','test2')
- newfile.ensure()
- assert newfile.check(file=1)
- finally:
- tmpdir.remove(rec=1)
-
- def test_ensure_filepath_withoutdir(self):
- tmpdir = local.mkdtemp()
- try:
- newfile = tmpdir.join('test1')
- t = newfile.ensure()
- assert t == newfile
- assert newfile.check(file=1)
- finally:
- tmpdir.remove(rec=1)
-
- def test_ensure_dirpath(self):
- tmpdir = local.mkdtemp()
- try:
- newfile = tmpdir.join('test1','test2')
- t = newfile.ensure(dir=1)
- assert t == newfile
- assert newfile.check(dir=1)
- finally:
- tmpdir.remove(rec=1)
-
- def test_mkdir(self):
- tmpdir = local.mkdtemp()
- try:
- new = tmpdir.join('test1')
- new.mkdir()
- assert new.check(dir=1)
-
- new = tmpdir.mkdir('test2')
- assert new.check(dir=1)
- assert tmpdir.join('test2') == new
- finally:
- tmpdir.remove(rec=1)
-
- def test_chdir(self):
- import os
- old = local()
- tmpdir = local.mkdtemp()
- try:
- res = tmpdir.chdir()
- assert str(res) == str(old)
- assert os.getcwd() == str(tmpdir)
- finally:
- old.chdir()
- tmpdir.remove(rec=1)
-
-
-class TestPOSIXLocalPath:
- #root = local(TestLocalPath.root)
- disabled = sys.platform == 'win32'
-
- def __init__(self):
- print "tmpdir is", config.tmpdir
- self.root = config.tmpdir / 'local'
- self.root.ensure(dir=1)
- setuptestfs(self.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_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()
- try:
- linkpath = tmpdir.join('test')
- linkpath.mksymlinkto(linkpath) # point to itself
- assert linkpath.check(dir=0)
- 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.get('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)
-
-class TestMisc:
- root = local(TestLocalPath.root)
-
- def test_make_numbered_dir(self):
- root = local.mkdtemp()
- try:
- for i in range(10):
- numdir = local.make_numbered_dir(root, 'base.', keep=2)
- assert numdir.check()
- assert numdir.get('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()
- finally:
- #print "root was", root
- root.remove(rec=1)
-
- def test_error_preservation(self):
- raises (OSError, self.root.join('qwoeqiwe').mtime)
- raises (IOError, 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)
-
-if __name__ == '__main__':
- main()
-
Deleted: /py/dist/py/path/pypath/pypath_test.py
==============================================================================
--- /py/dist/py/path/pypath/pypath_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,168 +0,0 @@
-import sys, os
-from py import path, test
-from py.__impl__.path.pypath import pypath
-
-class TestPyPath:
- root = path.py(pypath.__name__)
-
- def test_join(self):
- p = self.root.join('PyPath')
- obj = p.resolve()
- assert obj is path.py
-
- def test_listdir_module(self):
- l = self.root.listdir()
- basenames = [x.basename for x in l]
- dlist = dir(pypath)
- 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('PyPath').listdir()
- basenames = [x.basename for x in l]
- dlist = dir(pypath.PyPath)
- 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):
- PyPath = pypath.PyPath
- l = list(self.root.visit(path.checker(basename='PyPath')))
- assert len(l) == 1
- obj = l[0]
- assert str(obj).endswith('path.pypath.pypath.PyPath')
- assert obj.resolve() is PyPath
-
- def test_visit_fnmatch(self):
- PyPath = pypath.PyPath
- l = list(self.root.visit('PyPath'))
- assert len(l) == 1
- obj = l[0]
- assert str(obj).endswith('path.pypath.pypath.PyPath')
- assert obj.resolve() is PyPath
-
- def test_specified_base_empty_path(self):
- p = path.py('', ns=ExampleClass)
- l = p.listdir()
- basenames = [x.basename for x in l]
- assert 'testattr' in basenames
-
- 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 = path.py('a.b.c.d')
- m2 = path.py('a.b')
- m3 = path.py('')
- res = m1.relto(m2)
- assert str(res) == 'c.d'
- assert m2.relto(m3) == str(m2)
-
- def test_basename(self):
- m1 = path.py('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 = path.py('a.b.hello')
- m2 = path.py('a.b')
- m3 = path.py('a')
- m4 = path.py()
- assert m1.dirpath() == m2
- assert m2.dirpath() == m3
- assert m3.dirpath() == m4
-
- def test_function(self):
- class A:
- i = 3
- def func(self):
- pass
- p = path.py('func', ns=A)
- assert p.check(func=1)
- p = path.py('i', ns=A)
- assert p.check(func=0)
-
- def test_hashing_equality(self):
- x = path.py('os.path')
- y = path.py('os.path')
- assert x == y
- assert hash(x) == hash(y)
-
- def test_parents(self):
- x = path.py('os.path.abspath')
- l = x.parts()
- assert len(l) == 4
- assert path.py('') == l[0]
- assert path.py('os') == l[1]
- assert path.py('os.path') == l[2]
- assert path.py('os.path.abspath') == l[3]
-
-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(path.NotFound, "p.resolve()")
-
- def test_syntaxerror(self):
- p = path.py('os.path.qwe("a", ')
- s = test.raises(ValueError, "p.resolve()")
-
-class TestErrors:
- def test_FileNotFound(self):
- p = path.py('somesuch')
- test.raises(path.NotFound, p.resolve)
- p = path.py('email.whatever')
- test.raises(path.NotFound, p.resolve)
-
- def test_attributeerror(self):
- p = path.py('os.path.qabspath')
- test.raises(path.NotFound, p.resolve)
-
- #def test_ImportError():
- # p = path.py('__std.utest.test.data.failingimport.someattr')
- # utest.raises(ImportError, p.resolve)
-
-class ExampleClass:
- testattr = 1
-
-test.main()
Deleted: /py/dist/py/path/svn/command_test.py
==============================================================================
--- /py/dist/py/path/svn/command_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,23 +0,0 @@
-import sys, os
-import py
-from py.__impl__.path.test import svncommonfs
-from py.__impl__.path.svnwc.command_test import getrepowc
-
-class TestSvnCommandPath(svncommonfs.CommonCommandAndBindingTests):
- def __init__(self):
- repo, wc = getrepowc()
- self.root = py.path.svnurl(repo)
-
- def xtest_copy_file(self):
- raise py.test.run.Skipped(msg="XXX fix svnurl first")
-
- def xtest_copy_dir(self):
- raise py.test.run.Skipped(msg="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
Copied: py/dist/py/path/svn/test_command.py (from r6934, py/dist/py/path/svn/command_test.py)
==============================================================================
--- py/dist/py/path/svn/command_test.py (original)
+++ py/dist/py/path/svn/test_command.py Thu Oct 14 22:00:10 2004
@@ -1,7 +1,7 @@
import sys, os
import py
from py.__impl__.path.test import svncommonfs
-from py.__impl__.path.svnwc.command_test import getrepowc
+from py.__impl__.path.svnwc.test_command import getrepowc
class TestSvnCommandPath(svncommonfs.CommonCommandAndBindingTests):
def __init__(self):
Deleted: /py/dist/py/path/svnwc/command_test.py
==============================================================================
--- /py/dist/py/path/svnwc/command_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,209 +0,0 @@
-import py
-from py.__impl__.path.test.svncommonfs import CommonSvnTests
-from py.__impl__.path.test.commonfs 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.run.Skipped(msg='could not create temporary svn test repository')
- wcdir.ensure(dir=1)
- print "created svn repository", repo
- wc = py.path.svnwc(wcdir, url='file://%s' % repo)
- wc.checkout()
- 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)
Copied: py/dist/py/path/test_api.py (from r6931, py/dist/py/path/api_test.py)
==============================================================================
--- py/dist/py/path/api_test.py (original)
+++ py/dist/py/path/test_api.py Thu Oct 14 22:00:10 2004
@@ -1,5 +1,5 @@
from py import path, test
-from py.__impl__.path.svnwc.command_test import getrepowc
+from py.__impl__.path.svnwc.test_command import getrepowc
class TestAPI:
def __init__(self):
Deleted: /py/dist/py/process/cmdexec_test.py
==============================================================================
--- /py/dist/py/process/cmdexec_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,26 +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
-test.main()
Deleted: /py/dist/py/test/collect_test.py
==============================================================================
--- /py/dist/py/test/collect_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,84 +0,0 @@
-from __future__ import generators
-from py import test, path
-from py.magic import autopath ; autopath = autopath()
-testdir = autopath.dirpath('test')
-assert testdir.check(dir=1)
-datadir = testdir / 'data'
-
-def test_failing_import_execfile():
- fn = datadir / 'failingimport.py'
- l = list(test.collect.Execfile(fn))
- assert l
- ex, = l
- assert issubclass(ex.excinfo[0], ImportError)
-
-def test_failing_import_directory():
- class MyDirectory(test.collect.Directory):
- fil = path.checker(basestarts="testspecial_", ext='.py')
- l = list(MyDirectory(datadir))
- assert len(l) == 1
- assert isinstance(l[0], test.collect.Execfile)
- l2 = list(l[0])
- assert l2
- exc = l2[0]
- assert isinstance(exc, test.collect.Error)
- assert issubclass(exc.excinfo[0], ImportError)
-
-def test_execfile_file_not_found():
- fn = testdir.join('nada','no')
- l = list(test.collect.Execfile(fn))
- assert len(l) == 1
- assert isinstance(l[0], test.collect.Error)
- import traceback
- print traceback.print_exception(*l[0].excinfo)
- assert isinstance(l[0].excinfo[1], (IOError, OSError))
-
-def test_syntax_error_in_module():
- modpath = 'py.__impl__.utest.test.data.syntax_error.whatever'
- l2 = list(test.collect.Module(modpath))
- assert len(l2) == 1
- assert isinstance(l2[0], test.collect.Error)
- assert issubclass(l2[0].excinfo[0], path.Invalid)
-
-def test_disabled_class():
- class x:
- class y:
- disabled = True
- def test_method(self): pass
- l = list(test.collect.Class(path.py('', ns=x)))
- assert not l
-
-class TestCustomCollector:
- def test_custom_collect(self):
- l = list(test.collect.Execfile(datadir.join('Collector.py')))
- assert len(l) == 3
- for unit in l:
- assert isinstance(unit, test.Unit)
- #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]
-
-test.main()
Deleted: /py/dist/py/test/compat_test.py
==============================================================================
--- /py/dist/py/test/compat_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,53 +0,0 @@
-from __future__ import generators
-from py import test, magic
-
-class TestCompatTestCaseSetupSemantics(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(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(test.run.Failed,
- self.%(name)s, %(paramfail)s)
- """ % locals()
- co = magic.dyncode.compile2(source)
- exec co
-
-test.main()
Deleted: /py/dist/py/test/config_test.py
==============================================================================
--- /py/dist/py/test/config_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,30 +0,0 @@
-from __future__ import generators
-from py import test
-from py.test import 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
-
-test.main()
Deleted: /py/dist/py/test/raises_test.py
==============================================================================
--- /py/dist/py/test/raises_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,17 +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')
-
-
-test.main()
Deleted: /py/dist/py/test/report/memo_test.py
==============================================================================
--- /py/dist/py/test/report/memo_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,23 +0,0 @@
-from py import test, path
-
-datadir = test.config.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 = test.MemoReporter()
- p = datadir.join('memoimport.py')
- p.write('raise IOError')
- collector = test.collect.Execfile(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()
Deleted: /py/dist/py/test/tool/outerrcapture_test.py
==============================================================================
--- /py/dist/py/test/tool/outerrcapture_test.py Thu Oct 14 22:00:10 2004
+++ (empty file)
@@ -1,26 +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()")
-
-test.main()
More information about the pytest-commit
mailing list