/home/johnny/projects/merlinux/py/dist/py/path/svn/testing/svntestbase.py:7
import sys
import py
from py import path, test, process
from py.__.path.testing.fscommon import CommonFSTests, setuptestfs
from py.__.path.svn import cache, svncommon
-> mypath = py.magic.autopath()
repodump = mypath.dirpath('repotest.dump')
# make a wc directory out of a given root url
# cache previously obtained wcs!
#
def getrepowc(reponame='a~bc$aaa~', wcname='wc'):
repo = py.test.ensuretemp(reponame)
wcdir = py.test.ensuretemp(wcname)
if not repo.listdir():
#assert not wcdir.check()
repo.ensure(dir=1)
try:
py.process.cmdexec('svnadmin create "%s"' %
svncommon.escape(repo))
py.process.cmdexec('svnadmin load -q "%s" <"%s"' %
(svncommon.escape(repo), repodump))
except py.process.cmdexec.Error:
raise
repo.remove()
raise py.test.skip('could not create temporary svn test repository')
print "created svn repository", repo
wcdir.ensure(dir=1)
wc = py.path.svnwc(wcdir)
if py.std.sys.platform == 'win32':
repo = '/' + str(repo).replace('\\', '/')
wc.checkout(url='file://%s' % repo)
print "checked out new repo into", wc
else:
print "using repository at", repo
wc = py.path.svnwc(wcdir)
return ("file://%s" % repo, wc)
/home/johnny/projects/merlinux/py/dist/py/path/svn/testing/test_wccommand.py:2
import py
-> from py.__.path.svn.testing.svntestbase import CommonSvnTests, getrepowc
from py.__.path.svn.wccommand import InfoSvnWCCommand
from py.__.path.svn.wccommand import parse_wcinfotime
from py.__.path.svn import svncommon
try:
svnversion = py.path.local.sysfind('svn')
except py.error.ENOENT:
py.test.skip("cannot test py.path.svn, 'svn' binary not found")
class TestWCSvnCommandPath(CommonSvnTests):
def setup_class(cls):
repo, cls.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)
# Comparing just the file names, because paths are unpredictable
# on Windows. (long vs. 8.3 paths)
assert t1.basename in [item.basename for item in s.added]
assert t2.basename in [item.basename for item 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()
# Comparing just the file names, because paths are unpredictable
# on Windows. (long vs. 8.3 paths)
assert t1.basename in [item.basename for item in s.unknown]
finally:
t1.localpath.remove()
def test_status_unchanged(self):
r = self.root
s = self.root.status(rec=1)
# Comparing just the file names, because paths are unpredictable
# on Windows. (long vs. 8.3 paths)
assert r.join('samplefile').basename in [item.basename
for item in s.unchanged]
assert r.join('sampledir').basename in [item.basename
for item in s.unchanged]
assert r.join('sampledir/otherfile').basename in [item.basename
for item in s.unchanged]
def test_status_update(self):
r = self.root
try:
r.update(rev=1)
s = r.status(updates=1, rec=1)
# Comparing just the file names, because paths are unpredictable
# on Windows. (long vs. 8.3 paths)
assert r.join('anotherfile').basename in [item.basename for
item 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_blame(self):
p = self.root.join('samplepickle')
lines = p.blame()
assert sum([l[0] for l in lines]) == len(lines)
for l1, l2 in zip(p.readlines(), [l[2] for l in lines]):
assert l1 == l2
assert [l[1] for l in lines] == ['hpk'] * len(lines)
p = self.root.join('samplefile')
lines = p.blame()
assert sum([l[0] for l in lines]) == len(lines)
for l1, l2 in zip(p.readlines(), [l[2] for l in lines]):
assert l1 == l2
assert [l[1] for l in lines] == ['hpk'] * len(lines)
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)
# TODO: Why does my copy of svn think .svn is versioned?
#assert self.root.join('.svn').check(versioned=0)
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'
# Comparing just the file names, because paths are unpredictable
# on Windows. (long vs. 8.3 paths)
assert self.root.basename in [item.basename for item 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)
# Comparing just the file names, because paths are unpredictable
# on Windows. (long vs. 8.3 paths)
assert (self.root / 'samplefile').basename in [item.basename
for item 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)
newpath.write("hello")
newpath.ensure()
assert newpath.read() == "hello"
finally:
self.root.join('a').remove(force=1)
def test_commit(self):
newpath = self.root.ensure('committest', 'foo')
parent = newpath.dirpath()
try:
assert newpath.check()
newpath.write('foo')
parent.add()
newpath.add()
parent.commit('test commit')
assert parent.status().added == []
assert parent.status().modified == []
finally:
parent.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()
/home/johnny/projects/merlinux/py/dist/py/path/testing/test_api.py:3
from py import path, test
import py
-> from py.__.path.svn.testing.test_wccommand import getrepowc
class TestAPI:
def setup_class(cls):
cls.root = py.test.ensuretemp(cls.__name__)
def repr_eval_test(self, p):
r = repr(p)
from py.path import local,svnurl, svnwc, extpy
y = eval(r)
assert y == p
def test_deprecated_checker(self):
py.test.deprecated_call(py.path.checker)
def test_defaultlocal(self):
p = path.local()
assert hasattr(p, 'atime')
#assert hasattr(p, 'group') # XXX win32?
assert hasattr(p, 'setmtime')
assert p.check()
assert p.check(local=1)
assert p.check(svnwc=0)
assert p.check(extpy=0)
assert not p.check(svnwc=1)
self.repr_eval_test(p)
#assert p.std.path()
def test_local(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')
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)
/home/johnny/projects/merlinux/py/dist/py/misc/testing/test_initpkg.py:69
def check_import(modpath):
print "checking import", modpath
-> assert __import__(modpath)
/home/johnny/projects/merlinux/py/dist/py/test/item.py:79
def execute(self, target, *args):
""" default implementation for calling a test target is to
simply call it.
"""
-> target(*args)
/home/johnny/projects/merlinux/py/dist/py/test/item.py:73
def run(self):
self.state.prepare(self)
-> self.execute(self.obj, *self.args)
/home/johnny/projects/merlinux/py/dist/py/test/rsession/executor.py:22
def execute(self):
try:
-> self.item.run()
outcome = Outcome()
except py.test.Item.Skipped, e:
outcome = Outcome(skipped=str(e))
except (KeyboardInterrupt, SystemExit):
raise
except:
excinfo = py.code.ExceptionInfo()
if isinstance(self.item, py.test.Function):
fun = self.item.obj # hope this is stable
code = py.code.Code(fun)
excinfo.traceback = excinfo.traceback.cut(
path=code.path, firstlineno=code.firstlineno)
outcome = Outcome(excinfo=excinfo, setupfailure=False)
if self.usepdb:
if self.reporter is not None:
self.reporter(report.ImmediateFailure(self.item,
ReprOutcome(outcome.make_repr())))
import pdb
pdb.post_mortem(excinfo._excinfo[2])
# XXX hmm, we probably will not like to continue from that point
# or we do?
raise SystemExit()
outcome.stdout = ""
outcome.stderr = ""
return outcome
/home/johnny/projects/merlinux/py/dist/py/test/rsession/local.py:31
def plain_runner(item, session, reporter):
# box executor is doing stdout/err catching for us, let's do it here
startcapture(session)
r = RunExecutor(item, usepdb=session.config.option.usepdb, reporter=reporter)
-> outcome = r.execute()
outcome = ReprOutcome(outcome.make_repr())
outcome.stdout, outcome.stderr = finishcapture(session)
return outcome
/home/johnny/projects/merlinux/py/dist/py/test/rsession/local.py:47
def apigen_runner(item, session, reporter):
r = RunExecutor(item, reporter=reporter)
session.tracer.start_tracing()
-> retval = plain_runner(item, session, reporter)
session.tracer.end_tracing()
return retval