[py-svn] r33174 - in py/branch/apigen/py: . bin code code/testing documentation/apigen path/svn path/svn/testing rest/testing test/rsession test/rsession/testing test/rsession/webdata test/terminal test/testing test/tracer test/tracer/testing
fijal at codespeak.net
fijal at codespeak.net
Wed Oct 11 18:43:26 CEST 2006
Author: fijal
Date: Wed Oct 11 18:43:18 2006
New Revision: 33174
Added:
py/branch/apigen/py/documentation/apigen/roadmap.txt
- copied unchanged from r33173, py/dist/py/documentation/apigen/roadmap.txt
Modified:
py/branch/apigen/py/__init__.py
py/branch/apigen/py/bin/py.rest
py/branch/apigen/py/code/testing/test_excinfo.py
py/branch/apigen/py/code/traceback2.py
py/branch/apigen/py/documentation/apigen/assumptions.txt
py/branch/apigen/py/path/svn/svncommon.py
py/branch/apigen/py/path/svn/testing/svntestbase.py
py/branch/apigen/py/path/svn/testing/test_urlcommand.py
py/branch/apigen/py/path/svn/testing/test_wccommand.py
py/branch/apigen/py/path/svn/urlcommand.py
py/branch/apigen/py/path/svn/wccommand.py
py/branch/apigen/py/rest/testing/test_convert.py
py/branch/apigen/py/test/rsession/box.py
py/branch/apigen/py/test/rsession/hostmanage.py
py/branch/apigen/py/test/rsession/master.py
py/branch/apigen/py/test/rsession/rsession.py
py/branch/apigen/py/test/rsession/slave.py
py/branch/apigen/py/test/rsession/testing/test_boxing.py
py/branch/apigen/py/test/rsession/testing/test_rsession.py
py/branch/apigen/py/test/rsession/testing/test_slave.py
py/branch/apigen/py/test/rsession/testing/test_web.py
py/branch/apigen/py/test/rsession/webdata/ (props changed)
py/branch/apigen/py/test/rsession/webjs.py
py/branch/apigen/py/test/terminal/terminal.py
py/branch/apigen/py/test/testing/test_session.py
py/branch/apigen/py/test/tracer/description.py
py/branch/apigen/py/test/tracer/docstorage.py
py/branch/apigen/py/test/tracer/testing/test_docgen.py
py/branch/apigen/py/test/tracer/testing/test_rest.py
Log:
Merged branches. One conflict only! but a lot of failing tests for various reasons (They've been failing before merge in some particular cases).
Modified: py/branch/apigen/py/__init__.py
==============================================================================
--- py/branch/apigen/py/__init__.py (original)
+++ py/branch/apigen/py/__init__.py Wed Oct 11 18:43:18 2006
@@ -28,6 +28,7 @@
'test.fail' : ('./test/item.py', 'fail'),
'test.exit' : ('./test/session.py', 'exit'),
'test.compat.TestCase' : ('./test/compat.py', 'TestCase'),
+ 'test.remote' : ('./test/rsession/rsession.py', 'remote_options'),
# configuration/initialization related test api
'test.Config' : ('./test/config.py', 'Config'),
Modified: py/branch/apigen/py/bin/py.rest
==============================================================================
--- py/branch/apigen/py/bin/py.rest (original)
+++ py/branch/apigen/py/bin/py.rest Wed Oct 11 18:43:18 2006
@@ -66,8 +66,13 @@
process_configfile(p, options.debug)
else:
if options.topdf:
- process_rest_file(p.localpath,
- options.stylesheet,
+ cfg = p.new(ext=".rst2pdfconfig")
+ if cfg.check():
+ print "using config file %s" % (cfg, )
+ process_configfile(cfg, options.debug)
+ else:
+ process_rest_file(p.localpath,
+ options.stylesheet,
options.debug)
else:
rest.process(p)
Modified: py/branch/apigen/py/code/testing/test_excinfo.py
==============================================================================
--- py/branch/apigen/py/code/testing/test_excinfo.py (original)
+++ py/branch/apigen/py/code/testing/test_excinfo.py Wed Oct 11 18:43:18 2006
@@ -111,6 +111,23 @@
recindex = traceback.recursionindex()
assert recindex == 3
+ def test_traceback_no_recursion_index(self):
+ def do_stuff():
+ raise RuntimeError
+ def reraise_me():
+ import sys
+ exc, val, tb = sys.exc_info()
+ raise exc, val, tb
+ def f(n):
+ try:
+ do_stuff()
+ except:
+ reraise_me()
+ excinfo = py.test.raises(RuntimeError, f, 8)
+ traceback = excinfo.traceback
+ recindex = traceback.recursionindex()
+ assert recindex is None
+
def test_traceback_getcrashentry(self):
def i():
__tracebackhide__ = True
Modified: py/branch/apigen/py/code/traceback2.py
==============================================================================
--- py/branch/apigen/py/code/traceback2.py (original)
+++ py/branch/apigen/py/code/traceback2.py Wed Oct 11 18:43:18 2006
@@ -34,10 +34,14 @@
self.exprinfo = x
return self.exprinfo
+ def getfirstlinesource(self):
+ return self.frame.code.firstlineno
+
def getsource(self):
""" return failing source code. """
source = self.frame.code.fullsource
- start, end = self.frame.code.firstlineno, self.lineno
+ start = self.getfirstlinesource()
+ end = self.lineno
try:
_, end = source.getstatementrange(end)
except IndexError:
@@ -114,7 +118,7 @@
def recursionindex(self):
cache = {}
for i, entry in py.builtin.enumerate(self):
- key = entry.frame.code.path, entry.frame.lineno
+ key = entry.frame.code.path, entry.lineno
#print "checking for recursion at", key
l = cache.setdefault(key, [])
if l:
Modified: py/branch/apigen/py/documentation/apigen/assumptions.txt
==============================================================================
--- py/branch/apigen/py/documentation/apigen/assumptions.txt (original)
+++ py/branch/apigen/py/documentation/apigen/assumptions.txt Wed Oct 11 18:43:18 2006
@@ -33,3 +33,8 @@
object which was really used, than least basic superclass of arguments
that went inside).
+Milestone 1:
+------------
+
+Date is set till sprint in Duesseldorf.
+
Modified: py/branch/apigen/py/path/svn/svncommon.py
==============================================================================
--- py/branch/apigen/py/path/svn/svncommon.py (original)
+++ py/branch/apigen/py/path/svn/svncommon.py Wed Oct 11 18:43:18 2006
@@ -5,9 +5,10 @@
import py
from py.__.path import common
-ALLOWED_CHARS = "_ -/\\=$." #add characters as necessary when tested
+ALLOWED_CHARS = "_ -/\\=$.~" #add characters as necessary when tested
if sys.platform == "win32":
ALLOWED_CHARS += ":"
+ALLOWED_CHARS_HOST = ALLOWED_CHARS + '@:'
def _getsvnversion(ver=[]):
try:
@@ -25,12 +26,11 @@
text = str(text).replace('$', '\\$')
return text
-
-def _check_for_bad_chars(text):
+def _check_for_bad_chars(text, allowed_chars=ALLOWED_CHARS):
for c in str(text):
if c.isalnum():
continue
- if c in ALLOWED_CHARS:
+ if c in allowed_chars:
continue
return True
return False
Modified: py/branch/apigen/py/path/svn/testing/svntestbase.py
==============================================================================
--- py/branch/apigen/py/path/svn/testing/svntestbase.py (original)
+++ py/branch/apigen/py/path/svn/testing/svntestbase.py Wed Oct 11 18:43:18 2006
@@ -10,7 +10,7 @@
# make a wc directory out of a given root url
# cache previously obtained wcs!
#
-def getrepowc(reponame='abc$aaa', wcname='wc'):
+def getrepowc(reponame='a~bc$aaa~', wcname='wc'):
repo = py.test.ensuretemp(reponame)
wcdir = py.test.ensuretemp(wcname)
if not repo.listdir():
Modified: py/branch/apigen/py/path/svn/testing/test_urlcommand.py
==============================================================================
--- py/branch/apigen/py/path/svn/testing/test_urlcommand.py (original)
+++ py/branch/apigen/py/path/svn/testing/test_urlcommand.py Wed Oct 11 18:43:18 2006
@@ -12,9 +12,25 @@
repo, wc = getrepowc()
cls.root = py.path.svnurl(repo)
- def test_svnurl_characters(self):
- test1 = py.path.svnurl("svn+ssh://hello/world")
+ def test_svnurl_characters_simple(self):
+ py.path.svnurl("svn+ssh://hello/world")
+
+ def test_svnurl_characters_at_user(self):
+ py.path.svnurl("http://user@host.com/some/dir")
+
+ def test_svnurl_characters_at_path(self):
+ py.test.raises(ValueError, 'py.path.svnurl("http://host.com/foo@bar")')
+
+ def test_svnurl_characters_colon_port(self):
+ py.path.svnurl("http://host.com:8080/some/dir")
+
+ def test_svnurl_characters_colon_path(self):
+ py.test.raises(ValueError, 'py.path.svnurl("http://host.com/foo:bar")')
+
+ def test_svnurl_characters_tilde_end(self):
+ py.path.svnurl("http://host.com/some/file~")
+ # XXX
def xtest_copy_file(self):
raise py.test.Skipped(msg="XXX fix svnurl first")
@@ -29,7 +45,6 @@
t = gmtime(res[0].date)
assert t.tm_year == 2003 and t.tm_mon == 7 and t.tm_mday == 17
-
class TestSvnInfoCommand:
def test_svn_1_2(self):
Modified: py/branch/apigen/py/path/svn/testing/test_wccommand.py
==============================================================================
--- py/branch/apigen/py/path/svn/testing/test_wccommand.py (original)
+++ py/branch/apigen/py/path/svn/testing/test_wccommand.py Wed Oct 11 18:43:18 2006
@@ -299,5 +299,8 @@
def test_info(self):
self.wc.info().rev = 0
-def test_badchars():
+def test_characters_at():
py.test.raises(ValueError, "py.path.svnwc('/tmp/@@@:')")
+
+def test_characters_tilde():
+ py.path.svnwc('/tmp/test~')
Modified: py/branch/apigen/py/path/svn/urlcommand.py
==============================================================================
--- py/branch/apigen/py/path/svn/urlcommand.py (original)
+++ py/branch/apigen/py/path/svn/urlcommand.py Wed Oct 11 18:43:18 2006
@@ -22,10 +22,12 @@
self = object.__new__(cls)
if not isinstance(path, str):
path = str(path)
- parts = path.split(":")
+ proto, uri = path.split("://", 1)
+ host, uripath = uri.split('/', 1)
# only check for bad chars in the non-protocol parts
- # XXX don't check svn+ssh host sections either
- if len(parts) > 2 or svncommon._check_for_bad_chars(''.join(parts[1:])):
+ if (svncommon._check_for_bad_chars(host, svncommon.ALLOWED_CHARS_HOST)
+ or svncommon._check_for_bad_chars(uripath,
+ svncommon.ALLOWED_CHARS)):
raise ValueError("bad char in path %s" % (path, ))
path = path.rstrip('/')
self.strpath = path
Modified: py/branch/apigen/py/path/svn/wccommand.py
==============================================================================
--- py/branch/apigen/py/path/svn/wccommand.py (original)
+++ py/branch/apigen/py/path/svn/wccommand.py Wed Oct 11 18:43:18 2006
@@ -23,11 +23,12 @@
def __new__(cls, wcpath=None):
self = object.__new__(cls)
- if isinstance(wcpath, cls):
- if wcpath.__class__ == cls:
- return wcpath
- wcpath = wcpath.localpath
- if svncommon._check_for_bad_chars(str(wcpath)):
+ if isinstance(wcpath, cls):
+ if wcpath.__class__ == cls:
+ return wcpath
+ wcpath = wcpath.localpath
+ if svncommon._check_for_bad_chars(str(wcpath),
+ svncommon.ALLOWED_CHARS):
raise ValueError("bad char in wcpath %s" % (wcpath, ))
self.localpath = py.path.local(wcpath)
return self
Modified: py/branch/apigen/py/rest/testing/test_convert.py
==============================================================================
--- py/branch/apigen/py/rest/testing/test_convert.py (original)
+++ py/branch/apigen/py/rest/testing/test_convert.py Wed Oct 11 18:43:18 2006
@@ -9,6 +9,7 @@
py.test.skip("ghostscript, graphviz and latex needed")
def test_convert_dot():
+ py.test.skip("Check nothing right now")
# XXX not really clear that the result is valid pdf/eps
dot = datadir.join("example1.dot")
convert_dot(dot, "pdf")
@@ -21,6 +22,7 @@
eps.remove()
def test_latexformula():
+ py.test.skip("Check nothing right now")
png = datadir.join("test.png")
formula = r'$$Entropy(T) = - \sum^{m}_{j=1} \frac{|T_j|}{|T|} \log \frac{|T_j|}{|T|}$$'
#does not crash
Modified: py/branch/apigen/py/test/rsession/box.py
==============================================================================
--- py/branch/apigen/py/test/rsession/box.py (original)
+++ py/branch/apigen/py/test/rsession/box.py Wed Oct 11 18:43:18 2006
@@ -208,7 +208,60 @@
self.stdoutrepr = self.PYTESTSTDOUT.read()
self.stderrrepr = self.PYTESTSTDERR.read()
return self.stdoutrepr, self.stderrrepr
+
+def screen_run():
+ # XXX: we *do* bootstrapping once again here
+ # which sucks a lot
+ # XXX: We need to make some kind of *blocking* fifo, cause
+ # we have really no idea when we'll arrive
+ import os
+ import py
+
+ try:
+ pass
+ except:
+ pass
+ import pdb;pdb.set_trace()
+
+class ScreenBox(FileBox):
+ def run(self):
+ tempdir = py.test.ensuretemp("box")
+ self.tempdir = tempdir
+ self.PYTESTRETVAL = tempdir.join('retval')
+ self.PYTESTINPUT = tempdir.join('input')
+ #self.PYTESTINPUT.write(marshal.dumps({'args':self.args, \
+ # 'kwargs':self.kwargs, 'fun':self.fun}))
+
+ pid = os.fork()
+ if pid:
+ self.parent()
+ else:
+ os.chdir(str(py.path.local(py.__file__).dirpath().dirpath()))
+ screen = str(py.path.local.sysfind("screen"))
+ #os.execv(screen, ["python"])
+ os.execv(screen, ["screen", "-d", "-m", "-L", "--", "python", \
+ "-c", "from py.__.test.rsession import box\nbox.screen_run()"])
+ return pid
+
+ def parent(self):
+ pid, exitstat = os.wait()
+ self.signal = exitstat & 0x7f
+ self.exitstat = exitstat & 0xff00
+ import pdb;pdb.set_trace()
+ #if not exitstat:
+ # retval = self.PYTESTRETVAL.open()
+ # try:
+ # retval_data = retval.read()
+ # finally:
+ # retval.close()
+ # self.retval = marshal.loads(retval_data)
+ #else:
+ self.retval = None
+
+ self.stdoutrepr = py.path.local(__file__).dirpath().join("screenlog.0").read()
+ self.stderrrepr = ""
+ return self.stdoutrepr, self.stderrrepr
RealBox = FileBox
Box = FileBox
Modified: py/branch/apigen/py/test/rsession/hostmanage.py
==============================================================================
--- py/branch/apigen/py/test/rsession/hostmanage.py (original)
+++ py/branch/apigen/py/test/rsession/hostmanage.py Wed Oct 11 18:43:18 2006
@@ -29,7 +29,7 @@
def init_hosts(reporter, sshhosts, relpath, pkgdir, rsync_roots=None, \
- remote_python=None):
+ remote_python=None, remote_options={}):
assert pkgdir.join("__init__.py").check(), (
"%s probably wrong" %(pkgdir,))
assert relpath, relpath
@@ -70,7 +70,8 @@
# hosts ready
for host, gw, remoterootpath in hosts:
- ch = setup_slave(gw, os.path.join(remoterootpath, pkgdir.basename))
+ ch = setup_slave(gw, os.path.join(remoterootpath, pkgdir.basename),
+ remote_options)
nodes.append(MasterNode(ch, reporter))
return nodes
Modified: py/branch/apigen/py/test/rsession/master.py
==============================================================================
--- py/branch/apigen/py/test/rsession/master.py (original)
+++ py/branch/apigen/py/test/rsession/master.py Wed Oct 11 18:43:18 2006
@@ -43,11 +43,12 @@
break
waiter()
-def setup_slave(gateway, pkgpath):
+def setup_slave(gateway, pkgpath, options={}):
from py.__.test.rsession import slave
import os
ch = gateway.remote_exec(str(py.code.Source(slave.setup, "setup()")))
#if hasattr(gateway, 'sshaddress'):
# assert not os.path.isabs(pkgpath)
ch.send(str(pkgpath))
+ ch.send(options)
return ch
Modified: py/branch/apigen/py/test/rsession/rsession.py
==============================================================================
--- py/branch/apigen/py/test/rsession/rsession.py (original)
+++ py/branch/apigen/py/test/rsession/rsession.py Wed Oct 11 18:43:18 2006
@@ -17,6 +17,15 @@
from py.__.test.terminal.out import getout
+class RemoteOptions(object):
+ def __init__(self, d):
+ self.d = d
+
+ def __getattr__(self, attr):
+ return self.d[attr]
+
+remote_options = RemoteOptions({'we_are_remote':False})
+
class Reporter(object):
def __init__(self, config, hosts):
self.config = config
Modified: py/branch/apigen/py/test/rsession/slave.py
==============================================================================
--- py/branch/apigen/py/test/rsession/slave.py (original)
+++ py/branch/apigen/py/test/rsession/slave.py Wed Oct 11 18:43:18 2006
@@ -47,19 +47,34 @@
try:
node = getnode(nextitem)
res = node.run(nextitem[1:])
+ except py.test.Item.Skipped, s:
+ send(Outcome(skipped=str(s)).make_repr())
except:
excinfo = py.code.ExceptionInfo()
send(Outcome(excinfo=excinfo, is_critical=True).make_repr())
else:
send(res)
+def setup_screen():
+ # We cannot easily just assume that we do have full communication
+ # channels, so we have to provide a new ones.
+ import thread
+ import os, sys
+ # the idea is simple: we create another process in which we perform
+ # read/write operations on both channels
+
+
def setup():
import os, sys
pkgdir = channel.receive() # path is ready
+ options = channel.receive() # options stuff, should be dictionary
basedir = os.path.dirname(pkgdir)
pkgname = os.path.basename(pkgdir)
sys.path.insert(0, basedir)
import py
+ from py.__.test.rsession.rsession import RemoteOptions
+ options['we_are_remote'] = True
+ py.test.remote = RemoteOptions(options)
# XXX the following assumes that py lib is there, a bit
# much of an assumtion
mod = __import__(pkgname)
Modified: py/branch/apigen/py/test/rsession/testing/test_boxing.py
==============================================================================
--- py/branch/apigen/py/test/rsession/testing/test_boxing.py (original)
+++ py/branch/apigen/py/test/rsession/testing/test_boxing.py Wed Oct 11 18:43:18 2006
@@ -7,7 +7,7 @@
if sys.platform == 'win32':
py.test.skip("rsession is unsupported on Windows.")
-from py.__.test.rsession.box import Box, RealBox
+from py.__.test.rsession.box import Box, RealBox, ScreenBox
from py.__.test.rsession.testing import example2
from py.__.test.rsession.conftest import option
@@ -71,4 +71,3 @@
assert b.exitstat == 0
assert b.signal == 0
assert b.retval == 2
-
Modified: py/branch/apigen/py/test/rsession/testing/test_rsession.py
==============================================================================
--- py/branch/apigen/py/test/rsession/testing/test_rsession.py (original)
+++ py/branch/apigen/py/test/rsession/testing/test_rsession.py Wed Oct 11 18:43:18 2006
@@ -7,7 +7,8 @@
from py.__.test.rsession.rsession import RSession
from py.__.test.rsession.hostmanage import init_hosts, teardown_hosts
from py.__.test.rsession.testing.test_slave import funcfail_spec,\
- funcpass_spec, funcskip_spec, funcprint_spec, funcprintfail_spec
+ funcpass_spec, funcskip_spec, funcprint_spec, funcprintfail_spec, \
+ funcoptioncustom_spec, funcoption_spec
def setup_module(mod):
mod.pkgdir = py.path.local(py.__file__).dirpath()
@@ -30,7 +31,7 @@
def test_getpkdir_no_inits():
tmp = py.test.ensuretemp("getpkdir1")
fn = tmp.ensure("hello.py")
- py.test.raises(AssertionError, "RSession.getpkgdir(fn)")
+ assert RSession.getpkgdir(fn) == fn
def test_make_colitems():
one = pkgdir.join("initpkg.py")
@@ -112,6 +113,7 @@
tmpdir = py.path.local(py.__file__).dirpath().dirpath()
tmpdir.ensure("sub", "conftest.py").write(py.code.Source("""
disthosts = %r
+ distrsync_roots = ["sub", "py"]
""" % self.hosts[:1]))
tmpdir.ensure("sub", "__init__.py")
tmpdir.ensure("sub", "test_one.py").write(py.code.Source("""
@@ -126,7 +128,7 @@
"""))
args = [str(tmpdir.join("sub"))]
config, args = py.test.Config.parse(args)
- rsession = RSession(config)
+ rsession = RSession(config)
allevents = []
rsession.main(args, reporter=allevents.append)
testevents = [x for x in allevents
@@ -156,7 +158,8 @@
setup_events = []
teardown_events = []
- nodes = init_hosts(setup_events.append, hosts, 'pytesttest', pkgdir)
+ nodes = init_hosts(setup_events.append, hosts, 'pytesttest', pkgdir,
+ rsync_roots=["py"])
teardown_hosts(teardown_events.append,
[node.channel for node in nodes], nodes)
@@ -179,7 +182,8 @@
hosts = self.hosts
allevents = []
- nodes = init_hosts(allevents.append, hosts, 'pytesttest', pkgdir)
+ nodes = init_hosts(allevents.append, hosts, 'pytesttest', pkgdir,
+ rsync_roots=["py"])
from py.__.test.rsession.testing.test_executor \
import ItemTestPassing, ItemTestFailing, ItemTestSkipping
@@ -211,3 +215,30 @@
# one of passed for each node has non-empty stdout
passed_stdout = [i for i in passed if i.outcome.stdout == 'samfing\n']
assert len(passed_stdout) == len(nodes), passed
+
+ def test_config_pass(self):
+ """ Tests options object passing master -> server
+ """
+ allevents = []
+ hosts = self.hosts
+ nodes = init_hosts(allevents.append, hosts, 'pytesttest', pkgdir,
+ rsync_roots=["py"], remote_options={'custom':'custom'})
+
+ rootcol = py.test.collect.Directory(pkgdir.dirpath())
+ itempass = rootcol.getitembynames(funcoption_spec)
+ itempassaswell = rootcol.getitembynames(funcoptioncustom_spec)
+
+ for node in nodes:
+ node.send(itempass)
+ node.send(itempassaswell)
+
+ teardown_hosts(allevents.append, [node.channel for node in nodes], nodes)
+ events = [i for i in allevents
+ if isinstance(i, report.ReceivedItemOutcome)]
+ passed = [i for i in events
+ if i.outcome.passed]
+ skipped = [i for i in events
+ if i.outcome.skipped]
+ assert len(passed) == 2 * len(nodes)
+ assert len(skipped) == 0
+ assert len(events) == len(passed)
Modified: py/branch/apigen/py/test/rsession/testing/test_slave.py
==============================================================================
--- py/branch/apigen/py/test/rsession/testing/test_slave.py (original)
+++ py/branch/apigen/py/test/rsession/testing/test_slave.py Wed Oct 11 18:43:18 2006
@@ -29,11 +29,20 @@
print "samfing elz"
asddsa
-funcpass_spec = "py/test/rsession/testing/test_slave.py/funcpass".split("/")
-funcfail_spec = "py/test/rsession/testing/test_slave.py/funcfail".split("/")
-funcskip_spec = "py/test/rsession/testing/test_slave.py/funcskip".split("/")
-funcprint_spec = "py/test/rsession/testing/test_slave.py/funcprint".split("/")
-funcprintfail_spec = "py/test/rsession/testing/test_slave.py/funcprintfail".split("/")
+def funcoption():
+ assert py.test.remote.we_are_remote
+
+def funcoptioncustom():
+ assert py.test.remote.custom == "custom"
+
+BASE = "py/test/rsession/testing/test_slave.py/"
+funcpass_spec = (BASE + "funcpass").split("/")
+funcfail_spec = (BASE + "funcfail").split("/")
+funcskip_spec = (BASE + "funcskip").split("/")
+funcprint_spec = (BASE + "funcprint").split("/")
+funcprintfail_spec = (BASE + "funcprintfail").split("/")
+funcoption_spec = (BASE + "funcoption").split("/")
+funcoptioncustom_spec = (BASE + "funcoptioncustom").split("/")
# ----------------------------------------------------------------------
@@ -107,9 +116,19 @@
def test_slave_setup_fails_on_import_error():
from py.__.test.rsession.slave import setup
tmp = py.test.ensuretemp("slavesetup")
- class C:
+ class C:
+ def __init__(self):
+ self.count = 0
+
def receive(self):
- return str(tmp)
+ if self.count == 0:
+ retval = str(tmp)
+ elif self.count == 1:
+ retval = {}
+ else:
+ raise NotImplementedError("mora data")
+ self.count += 1
+ return retval
try:
exec py.code.Source(setup, "setup()").compile() in {
'channel': C()}
@@ -123,8 +142,18 @@
tmp = py.test.ensuretemp("slavesetup2")
x = tmp.ensure("sometestpackage", "__init__.py")
class C:
+ def __init__(self):
+ self.count = 0
+
def receive(self):
- return str(x.dirpath())
+ if self.count == 0:
+ retval = str(x.dirpath())
+ elif self.count == 1:
+ retval = {}
+ else:
+ raise NotImplementedError("mora data")
+ self.count += 1
+ return retval
try:
exec py.code.Source(setup, "setup()").compile() in {'channel': C()}
except AttributeError: # channel.send
Modified: py/branch/apigen/py/test/rsession/testing/test_web.py
==============================================================================
--- py/branch/apigen/py/test/rsession/testing/test_web.py (original)
+++ py/branch/apigen/py/test/rsession/testing/test_web.py Wed Oct 11 18:43:18 2006
@@ -10,6 +10,7 @@
commproxy.USE_MOCHIKIT = False
Options.debug_transform = True
+ Options.use_pdb = False
except ImportError:
py.test.skip("No PyPy detected")
Modified: py/branch/apigen/py/test/rsession/webjs.py
==============================================================================
--- py/branch/apigen/py/test/rsession/webjs.py (original)
+++ py/branch/apigen/py/test/rsession/webjs.py Wed Oct 11 18:43:18 2006
@@ -2,10 +2,14 @@
""" javascript source for py.test distributed
"""
+import py
from py.__.test.rsession.web import exported_methods
-from pypy.translator.js.modules import _dom as dom
-from pypy.translator.js.helper import __show_traceback
-from pypy.translator.transformer.debug import traceback_handler
+try:
+ from pypy.translator.js.modules import _dom as dom
+ from pypy.translator.js.helper import __show_traceback
+ from pypy.translator.transformer.debug import traceback_handler
+except ImportError, s:
+ py.test.skip("Cannot import: %s" % str(s))
def create_elem(s):
return dom.get_document().createElement(s)
Modified: py/branch/apigen/py/test/terminal/terminal.py
==============================================================================
--- py/branch/apigen/py/test/terminal/terminal.py (original)
+++ py/branch/apigen/py/test/terminal/terminal.py Wed Oct 11 18:43:18 2006
@@ -294,11 +294,13 @@
else:
self.out.line("")
source = self.getentrysource(entry)
+ firstsourceline = entry.getfirstlinesource()
+ marker_location = entry.lineno - firstsourceline
if entry == last:
- self.repr_source(source, 'E')
+ self.repr_source(source, 'E', marker_location)
self.repr_failure_explanation(excinfo, source)
else:
- self.repr_source(source, '>')
+ self.repr_source(source, '>', marker_location)
self.out.line("")
self.out.line("[%s:%d]" %(entry.frame.code.path, entry.lineno+1))
self.repr_locals(entry)
@@ -387,11 +389,19 @@
source = py.code.Source("[failure to get at sourcelines from %r]\n" % entry)
return source.deindent()
- def repr_source(self, source, marker=">"):
- for line in source[:-1]:
- self.out.line(" " + line)
- lastline = source[-1]
- self.out.line(marker + " " + lastline)
+ def repr_source(self, source, marker=">", marker_location=-1):
+ if marker_location < 0:
+ marker_location += len(source)
+ if marker_location < 0:
+ marker_location = 0
+ if marker_location >= len(source):
+ marker_location = len(source) - 1
+ for i in range(len(source)):
+ if i == marker_location:
+ prefix = marker + " "
+ else:
+ prefix = " "
+ self.out.line(prefix + source[i])
def repr_failure_explanation(self, excinfo, source):
try:
Modified: py/branch/apigen/py/test/testing/test_session.py
==============================================================================
--- py/branch/apigen/py/test/testing/test_session.py (original)
+++ py/branch/apigen/py/test/testing/test_session.py Wed Oct 11 18:43:18 2006
@@ -306,6 +306,31 @@
assert out.find("""[Exception("Ha Ha fooled you, I'm a broken repr().") raised in repr()]""") != -1 #'
assert out.find("[unknown exception raised in repr()]") != -1
+ def test_E_on_correct_line(self):
+ o = tmpdir.ensure('E_on_correct_line', dir=1)
+ tfile = o.join('test_correct_line.py')
+ source = py.code.Source("""
+ import py
+ def test_hello():
+ assert (None ==
+ ['a',
+ 'b',
+ 'c'])
+ """)
+ tfile.write(source)
+ session = self.session
+ session.main([o])
+ out = self.file.getvalue()
+ print 'Output of simulated "py.test test_correct_line.py":'
+ print out
+ i = out.find('test_correct_line.py:')
+ assert i >= 0
+ linenum = int(out[i+len('test_correct_line.py:')]) # a single char
+ line_to_report = source[linenum-1]
+ expected_output = '\nE ' + line_to_report + '\n'
+ print 'Looking for:', expected_output
+ assert expected_output in out
+
from py.__.test.terminal.remote import getrootdir
class TestRemote:
Modified: py/branch/apigen/py/test/tracer/description.py
==============================================================================
--- py/branch/apigen/py/test/tracer/description.py (original)
+++ py/branch/apigen/py/test/tracer/description.py Wed Oct 11 18:43:18 2006
@@ -1,5 +1,8 @@
-from pypy.annotation import model
+try:
+ from pypy.annotation import model
+except ImportError:
+ pass
import types
Modified: py/branch/apigen/py/test/tracer/docstorage.py
==============================================================================
--- py/branch/apigen/py/test/tracer/docstorage.py (original)
+++ py/branch/apigen/py/test/tracer/docstorage.py Wed Oct 11 18:43:18 2006
@@ -9,8 +9,12 @@
from py.__.test.tracer.description import FunctionDesc, ClassDesc, MethodDesc, \
Desc
-from pypy.annotation.policy import AnnotatorPolicy
-from pypy.annotation.bookkeeper import Bookkeeper
+
+try:
+ from pypy.annotation.policy import AnnotatorPolicy
+ from pypy.annotation.bookkeeper import Bookkeeper
+except ImportError:
+ py.test.skip("No PyPy")
class DummyAnnotator(object):
policy = AnnotatorPolicy()
Modified: py/branch/apigen/py/test/tracer/testing/test_docgen.py
==============================================================================
--- py/branch/apigen/py/test/tracer/testing/test_docgen.py (original)
+++ py/branch/apigen/py/test/tracer/testing/test_docgen.py Wed Oct 11 18:43:18 2006
@@ -5,14 +5,18 @@
import py
import sys
-from py.__.test.tracer.tracer import DocStorage, Tracer
-from py.__.test.tracer.testing.runtest import cut_pyc
-from pypy.annotation import model
+try:
+ from py.__.test.tracer.tracer import DocStorage, Tracer
+ from py.__.test.tracer.testing.runtest import cut_py
+ from pypy.annotation import model
+except ImportError, s:
+ py.test.skip("Cannot import: %s" % str(s))
#def setup_module(mod):
# data_path = py.path.local(mod.__file__).dirpath().join("data")
# sys.path.insert(0, str(data_path))
+
def fun(a, b, c):
"Some docstring"
return "d"
Modified: py/branch/apigen/py/test/tracer/testing/test_rest.py
==============================================================================
--- py/branch/apigen/py/test/tracer/testing/test_rest.py (original)
+++ py/branch/apigen/py/test/tracer/testing/test_rest.py Wed Oct 11 18:43:18 2006
@@ -4,12 +4,15 @@
import py
-from py.__.test.tracer.genrest import ViewVC, RestGen, PipeWriter, DirWriter,\
- DirectPaste
-from py.__.test.tracer.tracer import DocStorage, Tracer
-
-from StringIO import StringIO
-from py.__.test.tracer.testing.runtest import cut_pyc
+try:
+ from py.__.test.tracer.genrest import ViewVC, RestGen, PipeWriter, DirWriter,\
+ DirectPaste
+ from py.__.test.tracer.tracer import DocStorage, Tracer
+
+ from StringIO import StringIO
+ from py.__.test.tracer.testing.runtest import cut_pyc
+except ImportError, s:
+ py.test.skip("Cannot import: %s" % str(s))
def test_links():
vcview = ViewVC("http://codespeak.net/viewvc/")
More information about the py-svn
mailing list