[svn r37877] Intermediate checkin for some privatising of attributes
--HG-- branch : trunk
This commit is contained in:
parent
46a91b3705
commit
1dca2498fb
|
@ -29,7 +29,7 @@ import py
|
||||||
def configproperty(name):
|
def configproperty(name):
|
||||||
def fget(self):
|
def fget(self):
|
||||||
#print "retrieving %r property from %s" %(name, self.fspath)
|
#print "retrieving %r property from %s" %(name, self.fspath)
|
||||||
return self.config.getvalue(name, self.fspath)
|
return self._config.getvalue(name, self.fspath)
|
||||||
return property(fget)
|
return property(fget)
|
||||||
|
|
||||||
class Collector(object):
|
class Collector(object):
|
||||||
|
@ -44,7 +44,10 @@ class Collector(object):
|
||||||
def __init__(self, name, parent=None):
|
def __init__(self, name, parent=None):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.config = getattr(parent, 'config', py.test.config)
|
self._config = getattr(parent, '_config', py.test.config)
|
||||||
|
if parent is not None:
|
||||||
|
if hasattr(parent, 'config'):
|
||||||
|
py.test.pdb()
|
||||||
self.fspath = getattr(parent, 'fspath', None)
|
self.fspath = getattr(parent, 'fspath', None)
|
||||||
|
|
||||||
Module = configproperty('Module')
|
Module = configproperty('Module')
|
||||||
|
@ -73,8 +76,8 @@ class Collector(object):
|
||||||
return not self == other
|
return not self == other
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
s1 = self.getsortvalue()
|
s1 = self._getsortvalue()
|
||||||
s2 = other.getsortvalue()
|
s2 = other._getsortvalue()
|
||||||
#print "cmp", s1, s2
|
#print "cmp", s1, s2
|
||||||
return cmp(s1, s2)
|
return cmp(s1, s2)
|
||||||
|
|
||||||
|
@ -116,7 +119,7 @@ class Collector(object):
|
||||||
""" return a list of colitems for the given namelist. """
|
""" return a list of colitems for the given namelist. """
|
||||||
return [self.join(name) for name in namelist]
|
return [self.join(name) for name in namelist]
|
||||||
|
|
||||||
def getpathlineno(self):
|
def _getpathlineno(self):
|
||||||
return self.fspath, py.std.sys.maxint
|
return self.fspath, py.std.sys.maxint
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
|
@ -139,7 +142,7 @@ class Collector(object):
|
||||||
def listnames(self):
|
def listnames(self):
|
||||||
return [x.name for x in self.listchain()]
|
return [x.name for x in self.listchain()]
|
||||||
|
|
||||||
def getitembynames(self, namelist):
|
def _getitembynames(self, namelist):
|
||||||
if isinstance(namelist, str):
|
if isinstance(namelist, str):
|
||||||
namelist = namelist.split("/")
|
namelist = namelist.split("/")
|
||||||
cur = self
|
cur = self
|
||||||
|
@ -150,10 +153,10 @@ class Collector(object):
|
||||||
cur = next
|
cur = next
|
||||||
return cur
|
return cur
|
||||||
|
|
||||||
def haskeyword(self, keyword):
|
def _haskeyword(self, keyword):
|
||||||
return keyword in self.name
|
return keyword in self.name
|
||||||
|
|
||||||
def getmodpath(self):
|
def _getmodpath(self):
|
||||||
""" return dotted module path (relative to the containing). """
|
""" return dotted module path (relative to the containing). """
|
||||||
inmodule = False
|
inmodule = False
|
||||||
newl = []
|
newl = []
|
||||||
|
@ -169,7 +172,7 @@ class Collector(object):
|
||||||
newl.append(x.name)
|
newl.append(x.name)
|
||||||
return ".".join(newl)
|
return ".".join(newl)
|
||||||
|
|
||||||
def skipbykeyword(self, keyword):
|
def _skipbykeyword(self, keyword):
|
||||||
""" raise Skipped() exception if the given keyword
|
""" raise Skipped() exception if the given keyword
|
||||||
matches for this collector.
|
matches for this collector.
|
||||||
"""
|
"""
|
||||||
|
@ -185,7 +188,7 @@ class Collector(object):
|
||||||
|
|
||||||
def _matchonekeyword(self, key, chain):
|
def _matchonekeyword(self, key, chain):
|
||||||
for subitem in chain:
|
for subitem in chain:
|
||||||
if subitem.haskeyword(key):
|
if subitem._haskeyword(key):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -198,7 +201,7 @@ class Collector(object):
|
||||||
yieldtype = py.test.Item
|
yieldtype = py.test.Item
|
||||||
if isinstance(self, yieldtype):
|
if isinstance(self, yieldtype):
|
||||||
try:
|
try:
|
||||||
self.skipbykeyword(keyword)
|
self._skipbykeyword(keyword)
|
||||||
yield self
|
yield self
|
||||||
except py.test.Item.Skipped:
|
except py.test.Item.Skipped:
|
||||||
if reporterror is not None:
|
if reporterror is not None:
|
||||||
|
@ -220,21 +223,23 @@ class Collector(object):
|
||||||
excinfo = py.code.ExceptionInfo()
|
excinfo = py.code.ExceptionInfo()
|
||||||
reporterror((excinfo, self))
|
reporterror((excinfo, self))
|
||||||
|
|
||||||
def getsortvalue(self):
|
def _getsortvalue(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
captured_out = captured_err = None
|
captured_out = captured_err = None
|
||||||
def startcapture(self):
|
def startcapture(self):
|
||||||
return None # by default collectors don't capture output
|
return None # by default collectors don't capture output
|
||||||
|
|
||||||
def finishcapture(self):
|
def finishcapture(self):
|
||||||
return None # by default collectors don't capture output
|
return None # by default collectors don't capture output
|
||||||
def getouterr(self):
|
|
||||||
|
def _getouterr(self):
|
||||||
return self.captured_out, self.captured_err
|
return self.captured_out, self.captured_err
|
||||||
|
|
||||||
def _get_collector_trail(self):
|
def _get_collector_trail(self):
|
||||||
""" Shortcut
|
""" Shortcut
|
||||||
"""
|
"""
|
||||||
return self.config.get_collector_trail(self)
|
return self._config.get_collector_trail(self)
|
||||||
|
|
||||||
class FSCollector(Collector):
|
class FSCollector(Collector):
|
||||||
def __init__(self, fspath, parent=None):
|
def __init__(self, fspath, parent=None):
|
||||||
|
@ -356,7 +361,7 @@ class Module(FSCollector, PyCollectorMixin):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def startcapture(self):
|
def startcapture(self):
|
||||||
if not self.config.option.nocapture:
|
if not self._config.option.nocapture:
|
||||||
assert not hasattr(self, '_capture')
|
assert not hasattr(self, '_capture')
|
||||||
self._capture = py.io.StdCaptureFD()
|
self._capture = py.io.StdCaptureFD()
|
||||||
|
|
||||||
|
@ -418,7 +423,7 @@ class Class(PyCollectorMixin, Collector):
|
||||||
teardown_class = getattr(teardown_class, 'im_func', teardown_class)
|
teardown_class = getattr(teardown_class, 'im_func', teardown_class)
|
||||||
teardown_class(self.obj)
|
teardown_class(self.obj)
|
||||||
|
|
||||||
def getsortvalue(self):
|
def _getsortvalue(self):
|
||||||
# try to locate the class in the source - not nice, but probably
|
# try to locate the class in the source - not nice, but probably
|
||||||
# the most useful "solution" that we have
|
# the most useful "solution" that we have
|
||||||
try:
|
try:
|
||||||
|
@ -432,7 +437,7 @@ class Class(PyCollectorMixin, Collector):
|
||||||
pass
|
pass
|
||||||
# fall back...
|
# fall back...
|
||||||
for x in self.tryiter((py.test.collect.Generator, py.test.Item)):
|
for x in self.tryiter((py.test.collect.Generator, py.test.Item)):
|
||||||
return x.getsortvalue()
|
return x._getsortvalue()
|
||||||
|
|
||||||
class Instance(PyCollectorMixin, Collector):
|
class Instance(PyCollectorMixin, Collector):
|
||||||
def _getobj(self):
|
def _getobj(self):
|
||||||
|
@ -468,12 +473,12 @@ class Generator(PyCollectorMixin, Collector):
|
||||||
call, args = obj, ()
|
call, args = obj, ()
|
||||||
return call, args
|
return call, args
|
||||||
|
|
||||||
def getpathlineno(self):
|
def _getpathlineno(self):
|
||||||
code = py.code.Code(self.obj)
|
code = py.code.Code(self.obj)
|
||||||
return code.path, code.firstlineno
|
return code.path, code.firstlineno
|
||||||
|
|
||||||
def getsortvalue(self):
|
def _getsortvalue(self):
|
||||||
return self.getpathlineno()
|
return self._getpathlineno()
|
||||||
|
|
||||||
class DoctestFile(PyCollectorMixin, FSCollector):
|
class DoctestFile(PyCollectorMixin, FSCollector):
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
|
@ -75,14 +75,14 @@ class Config(object):
|
||||||
assert path.check(), "%s: path does not exist" %(path,)
|
assert path.check(), "%s: path does not exist" %(path,)
|
||||||
col = self._getrootcollector(path)
|
col = self._getrootcollector(path)
|
||||||
names = path.relto(col.fspath).split(path.sep)
|
names = path.relto(col.fspath).split(path.sep)
|
||||||
return col.getitembynames(names)
|
return col._getitembynames(names)
|
||||||
|
|
||||||
def _getrootcollector(self, path):
|
def _getrootcollector(self, path):
|
||||||
pkgpath = path.pypkgpath()
|
pkgpath = path.pypkgpath()
|
||||||
if pkgpath is None:
|
if pkgpath is None:
|
||||||
pkgpath = path.check(file=1) and path.dirpath() or path
|
pkgpath = path.check(file=1) and path.dirpath() or path
|
||||||
col = self.conftest.rget("Directory", pkgpath)(pkgpath)
|
col = self.conftest.rget("Directory", pkgpath)(pkgpath)
|
||||||
col.config = self
|
col._config = self
|
||||||
return col
|
return col
|
||||||
|
|
||||||
def addoptions(self, groupname, *specs):
|
def addoptions(self, groupname, *specs):
|
||||||
|
|
|
@ -32,7 +32,7 @@ class SetupState(object):
|
||||||
|
|
||||||
class Item(py.test.collect.Collector):
|
class Item(py.test.collect.Collector):
|
||||||
def startcapture(self):
|
def startcapture(self):
|
||||||
if not self.config.option.nocapture:
|
if not self._config.option.nocapture:
|
||||||
self._capture = py.io.StdCaptureFD()
|
self._capture = py.io.StdCaptureFD()
|
||||||
|
|
||||||
def finishcapture(self):
|
def finishcapture(self):
|
||||||
|
@ -57,13 +57,13 @@ class Function(Item):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s %r>" %(self.__class__.__name__, self.name)
|
return "<%s %r>" %(self.__class__.__name__, self.name)
|
||||||
|
|
||||||
def getpathlineno(self):
|
def _getpathlineno(self):
|
||||||
code = py.code.Code(self.obj)
|
code = py.code.Code(self.obj)
|
||||||
return code.path, code.firstlineno
|
return code.path, code.firstlineno
|
||||||
|
|
||||||
def getsortvalue(self):
|
def _getsortvalue(self):
|
||||||
if self.sort_value is None:
|
if self.sort_value is None:
|
||||||
return self.getpathlineno()
|
return self._getpathlineno()
|
||||||
return self.sort_value
|
return self.sort_value
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
|
@ -43,13 +43,13 @@ class Presenter(object):
|
||||||
""" This method represents py.test.Item info (path and module)
|
""" This method represents py.test.Item info (path and module)
|
||||||
"""
|
"""
|
||||||
root = item.fspath
|
root = item.fspath
|
||||||
modpath = item.getmodpath()
|
modpath = item._getmodpath()
|
||||||
try:
|
try:
|
||||||
fn, lineno = item.getpathlineno()
|
fn, lineno = item._getpathlineno()
|
||||||
except TypeError:
|
except TypeError:
|
||||||
assert isinstance(item.parent, py.test.collect.Generator)
|
assert isinstance(item.parent, py.test.collect.Generator)
|
||||||
# a generative test yielded a non-callable
|
# a generative test yielded a non-callable
|
||||||
fn, lineno = item.parent.getpathlineno()
|
fn, lineno = item.parent._getpathlineno()
|
||||||
if root == fn:
|
if root == fn:
|
||||||
self.out.sep("_", "entrypoint: %s" %(modpath))
|
self.out.sep("_", "entrypoint: %s" %(modpath))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -128,8 +128,6 @@ class AbstractReporter(object):
|
||||||
def repr_failure(self, item, outcome):
|
def repr_failure(self, item, outcome):
|
||||||
excinfo = outcome.excinfo
|
excinfo = outcome.excinfo
|
||||||
traceback = excinfo.traceback
|
traceback = excinfo.traceback
|
||||||
#if item and not self.config.option.fulltrace:
|
|
||||||
# path, firstlineno = item.getpathlineno()
|
|
||||||
if not traceback:
|
if not traceback:
|
||||||
self.out.line("empty traceback from item %r" % (item,))
|
self.out.line("empty traceback from item %r" % (item,))
|
||||||
return
|
return
|
||||||
|
|
|
@ -52,11 +52,7 @@ class SlaveNode(object):
|
||||||
self.pidinfo = pidinfo
|
self.pidinfo = pidinfo
|
||||||
|
|
||||||
def execute(self, itemspec):
|
def execute(self, itemspec):
|
||||||
#item = self.rootcollector.getitembynames(itemspec)
|
|
||||||
item = self.config._getcollector(itemspec)
|
item = self.config._getcollector(itemspec)
|
||||||
#if isinstance(item, py.test.Function):
|
|
||||||
# ex = Executor(item.obj, setup=item.setup)
|
|
||||||
#else:
|
|
||||||
ex = self.executor(item, config=self.config)
|
ex = self.executor(item, config=self.config)
|
||||||
if self.executor is AsyncExecutor:
|
if self.executor is AsyncExecutor:
|
||||||
cont, pid = ex.execute()
|
cont, pid = ex.execute()
|
||||||
|
|
|
@ -94,7 +94,7 @@ def test_box_executor():
|
||||||
|
|
||||||
def test_box_executor_stdout():
|
def test_box_executor_stdout():
|
||||||
rootcol = py.test.collect.Directory(rootdir)
|
rootcol = py.test.collect.Directory(rootdir)
|
||||||
item = rootcol.getitembynames(funcprint_spec)
|
item = rootcol._getitembynames(funcprint_spec)
|
||||||
ex = BoxExecutor(item, config=config)
|
ex = BoxExecutor(item, config=config)
|
||||||
outcome_repr = ex.execute()
|
outcome_repr = ex.execute()
|
||||||
outcome = ReprOutcome(outcome_repr)
|
outcome = ReprOutcome(outcome_repr)
|
||||||
|
@ -103,7 +103,7 @@ def test_box_executor_stdout():
|
||||||
|
|
||||||
def test_box_executor_stdout_error():
|
def test_box_executor_stdout_error():
|
||||||
rootcol = py.test.collect.Directory(rootdir)
|
rootcol = py.test.collect.Directory(rootdir)
|
||||||
item = rootcol.getitembynames(funcprintfail_spec)
|
item = rootcol._getitembynames(funcprintfail_spec)
|
||||||
ex = BoxExecutor(item, config=config)
|
ex = BoxExecutor(item, config=config)
|
||||||
outcome_repr = ex.execute()
|
outcome_repr = ex.execute()
|
||||||
outcome = ReprOutcome(outcome_repr)
|
outcome = ReprOutcome(outcome_repr)
|
||||||
|
@ -112,7 +112,7 @@ def test_box_executor_stdout_error():
|
||||||
|
|
||||||
def test_cont_executor():
|
def test_cont_executor():
|
||||||
rootcol = py.test.collect.Directory(rootdir)
|
rootcol = py.test.collect.Directory(rootdir)
|
||||||
item = rootcol.getitembynames(funcprintfail_spec)
|
item = rootcol._getitembynames(funcprintfail_spec)
|
||||||
ex = AsyncExecutor(item, config=config)
|
ex = AsyncExecutor(item, config=config)
|
||||||
cont, pid = ex.execute()
|
cont, pid = ex.execute()
|
||||||
assert pid
|
assert pid
|
||||||
|
@ -154,13 +154,13 @@ def test_apigen_executor():
|
||||||
"""))
|
"""))
|
||||||
rootcol = py.test.collect.Directory(tmpdir)
|
rootcol = py.test.collect.Directory(tmpdir)
|
||||||
tracer = Tracer()
|
tracer = Tracer()
|
||||||
item = rootcol.getitembynames("test_one.py/test_1")
|
item = rootcol._getitembynames("test_one.py/test_1")
|
||||||
ex = ApigenExecutor(item, config=config)
|
ex = ApigenExecutor(item, config=config)
|
||||||
out1 = ex.execute(tracer)
|
out1 = ex.execute(tracer)
|
||||||
item = rootcol.getitembynames("test_one.py/TestX/()/test_one")
|
item = rootcol._getitembynames("test_one.py/TestX/()/test_one")
|
||||||
ex = ApigenExecutor(item, config=config)
|
ex = ApigenExecutor(item, config=config)
|
||||||
out2 = ex.execute(tracer)
|
out2 = ex.execute(tracer)
|
||||||
item = rootcol.getitembynames("test_one.py/TestX/()/test_raise")
|
item = rootcol._getitembynames("test_one.py/TestX/()/test_raise")
|
||||||
ex = ApigenExecutor(item, config=config)
|
ex = ApigenExecutor(item, config=config)
|
||||||
out3 = ex.execute(tracer)
|
out3 = ex.execute(tracer)
|
||||||
assert tracer.starts == 3
|
assert tracer.starts == 3
|
||||||
|
|
|
@ -96,7 +96,7 @@ def test_slave_setup():
|
||||||
gw = py.execnet.PopenGateway()
|
gw = py.execnet.PopenGateway()
|
||||||
config = py.test.config._reparse([])
|
config = py.test.config._reparse([])
|
||||||
channel = setup_slave(gw, pkgdir, config)
|
channel = setup_slave(gw, pkgdir, config)
|
||||||
spec = rootcol.getitembynames(funcpass_spec)._get_collector_trail()
|
spec = rootcol._getitembynames(funcpass_spec)._get_collector_trail()
|
||||||
channel.send(spec)
|
channel.send(spec)
|
||||||
output = ReprOutcome(channel.receive())
|
output = ReprOutcome(channel.receive())
|
||||||
assert output.passed
|
assert output.passed
|
||||||
|
@ -124,8 +124,8 @@ def test_slave_running():
|
||||||
return mn
|
return mn
|
||||||
|
|
||||||
master_nodes = [open_gw(), open_gw(), open_gw()]
|
master_nodes = [open_gw(), open_gw(), open_gw()]
|
||||||
funcpass_item = rootcol.getitembynames(funcpass_spec)
|
funcpass_item = rootcol._getitembynames(funcpass_spec)
|
||||||
funcfail_item = rootcol.getitembynames(funcfail_spec)
|
funcfail_item = rootcol._getitembynames(funcfail_spec)
|
||||||
itemgenerator = iter([funcfail_item] +
|
itemgenerator = iter([funcfail_item] +
|
||||||
[funcpass_item] * 5 + [funcfail_item] * 5)
|
[funcpass_item] * 5 + [funcfail_item] * 5)
|
||||||
shouldstop = lambda : False
|
shouldstop = lambda : False
|
||||||
|
@ -153,7 +153,7 @@ def test_slave_running_interrupted():
|
||||||
|
|
||||||
mn, gw, channel = open_gw()
|
mn, gw, channel = open_gw()
|
||||||
rootcol = py.test.collect.Directory(pkgdir)
|
rootcol = py.test.collect.Directory(pkgdir)
|
||||||
funchang_item = rootcol.getitembynames(funchang_spec)
|
funchang_item = rootcol._getitembynames(funchang_spec)
|
||||||
mn.send(funchang_item)
|
mn.send(funchang_item)
|
||||||
mn.send(StopIteration)
|
mn.send(StopIteration)
|
||||||
# XXX: We have to wait here a bit to make sure that it really did happen
|
# XXX: We have to wait here a bit to make sure that it really did happen
|
||||||
|
|
|
@ -64,7 +64,7 @@ class AbstractTestReporter(object):
|
||||||
config = py.test.config._reparse(["some_sub"])
|
config = py.test.config._reparse(["some_sub"])
|
||||||
# we just go...
|
# we just go...
|
||||||
rootcol = py.test.collect.Directory(self.pkgdir.dirpath())
|
rootcol = py.test.collect.Directory(self.pkgdir.dirpath())
|
||||||
item = rootcol.getitembynames(funcpass_spec)
|
item = rootcol._getitembynames(funcpass_spec)
|
||||||
outcomes = self.prepare_outcomes()
|
outcomes = self.prepare_outcomes()
|
||||||
|
|
||||||
def boxfun(config, item, outcomes):
|
def boxfun(config, item, outcomes):
|
||||||
|
@ -84,8 +84,8 @@ class AbstractTestReporter(object):
|
||||||
config = py.test.config._reparse(["some_sub"])
|
config = py.test.config._reparse(["some_sub"])
|
||||||
# we just go...
|
# we just go...
|
||||||
rootcol = py.test.collect.Directory(self.pkgdir.dirpath())
|
rootcol = py.test.collect.Directory(self.pkgdir.dirpath())
|
||||||
funcitem = rootcol.getitembynames(funcpass_spec)
|
funcitem = rootcol._getitembynames(funcpass_spec)
|
||||||
moditem = rootcol.getitembynames(mod_spec)
|
moditem = rootcol._getitembynames(mod_spec)
|
||||||
outcomes = self.prepare_outcomes()
|
outcomes = self.prepare_outcomes()
|
||||||
|
|
||||||
def boxfun(pkgdir, config, item, funcitem, outcomes):
|
def boxfun(pkgdir, config, item, funcitem, outcomes):
|
||||||
|
|
|
@ -196,10 +196,10 @@ class TestRSessionRemote:
|
||||||
import ItemTestPassing, ItemTestFailing, ItemTestSkipping
|
import ItemTestPassing, ItemTestFailing, ItemTestSkipping
|
||||||
|
|
||||||
rootcol = py.test.collect.Directory(pkgdir.dirpath())
|
rootcol = py.test.collect.Directory(pkgdir.dirpath())
|
||||||
itempass = rootcol.getitembynames(funcpass_spec)
|
itempass = rootcol._getitembynames(funcpass_spec)
|
||||||
itemfail = rootcol.getitembynames(funcfail_spec)
|
itemfail = rootcol._getitembynames(funcfail_spec)
|
||||||
itemskip = rootcol.getitembynames(funcskip_spec)
|
itemskip = rootcol._getitembynames(funcskip_spec)
|
||||||
itemprint = rootcol.getitembynames(funcprint_spec)
|
itemprint = rootcol._getitembynames(funcprint_spec)
|
||||||
|
|
||||||
# actually run some tests
|
# actually run some tests
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
|
@ -240,7 +240,7 @@ class TestRSessionRemote:
|
||||||
nodes = hm.init_hosts(allevents.append)
|
nodes = hm.init_hosts(allevents.append)
|
||||||
|
|
||||||
rootcol = py.test.collect.Directory(pkgdir.dirpath())
|
rootcol = py.test.collect.Directory(pkgdir.dirpath())
|
||||||
itempass = rootcol.getitembynames(funcoptioncustom_spec)
|
itempass = rootcol._getitembynames(funcoptioncustom_spec)
|
||||||
|
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
node.send(itempass)
|
node.send(itempass)
|
||||||
|
|
|
@ -61,7 +61,7 @@ def gettestnode():
|
||||||
|
|
||||||
def test_slave_run_passing():
|
def test_slave_run_passing():
|
||||||
node = gettestnode()
|
node = gettestnode()
|
||||||
item = rootcol.getitembynames(funcpass_spec)
|
item = rootcol._getitembynames(funcpass_spec)
|
||||||
outcome = node.execute(item._get_collector_trail())
|
outcome = node.execute(item._get_collector_trail())
|
||||||
assert outcome.passed
|
assert outcome.passed
|
||||||
assert not outcome.setupfailure
|
assert not outcome.setupfailure
|
||||||
|
@ -73,7 +73,7 @@ def test_slave_run_passing():
|
||||||
|
|
||||||
def test_slave_run_failing():
|
def test_slave_run_failing():
|
||||||
node = gettestnode()
|
node = gettestnode()
|
||||||
item = rootcol.getitembynames(funcfail_spec)
|
item = rootcol._getitembynames(funcfail_spec)
|
||||||
outcome = node.execute(item._get_collector_trail())
|
outcome = node.execute(item._get_collector_trail())
|
||||||
assert not outcome.passed
|
assert not outcome.passed
|
||||||
assert not outcome.setupfailure
|
assert not outcome.setupfailure
|
||||||
|
@ -88,7 +88,7 @@ def test_slave_run_failing():
|
||||||
|
|
||||||
def test_slave_run_skipping():
|
def test_slave_run_skipping():
|
||||||
node = gettestnode()
|
node = gettestnode()
|
||||||
item = rootcol.getitembynames(funcskip_spec)
|
item = rootcol._getitembynames(funcskip_spec)
|
||||||
outcome = node.execute(item._get_collector_trail())
|
outcome = node.execute(item._get_collector_trail())
|
||||||
assert not outcome.passed
|
assert not outcome.passed
|
||||||
assert outcome.skipped
|
assert outcome.skipped
|
||||||
|
@ -100,7 +100,7 @@ def test_slave_run_skipping():
|
||||||
|
|
||||||
def test_slave_run_failing_wrapped():
|
def test_slave_run_failing_wrapped():
|
||||||
node = gettestnode()
|
node = gettestnode()
|
||||||
item = rootcol.getitembynames(funcfail_spec)
|
item = rootcol._getitembynames(funcfail_spec)
|
||||||
repr_outcome = node.run(item._get_collector_trail())
|
repr_outcome = node.run(item._get_collector_trail())
|
||||||
outcome = ReprOutcome(repr_outcome)
|
outcome = ReprOutcome(repr_outcome)
|
||||||
assert not outcome.passed
|
assert not outcome.passed
|
||||||
|
@ -109,8 +109,8 @@ def test_slave_run_failing_wrapped():
|
||||||
|
|
||||||
def test_slave_main_simple():
|
def test_slave_main_simple():
|
||||||
res = []
|
res = []
|
||||||
failitem = rootcol.getitembynames(funcfail_spec)
|
failitem = rootcol._getitembynames(funcfail_spec)
|
||||||
passitem = rootcol.getitembynames(funcpass_spec)
|
passitem = rootcol._getitembynames(funcpass_spec)
|
||||||
q = [None,
|
q = [None,
|
||||||
passitem._get_collector_trail(),
|
passitem._get_collector_trail(),
|
||||||
failitem._get_collector_trail()
|
failitem._get_collector_trail()
|
||||||
|
@ -124,7 +124,7 @@ def test_slave_main_simple():
|
||||||
|
|
||||||
def test_slave_run_different_stuff():
|
def test_slave_run_different_stuff():
|
||||||
node = gettestnode()
|
node = gettestnode()
|
||||||
node.run(rootcol.getitembynames("py doc log.txt".split()).
|
node.run(rootcol._getitembynames("py doc log.txt".split()).
|
||||||
_get_collector_trail())
|
_get_collector_trail())
|
||||||
|
|
||||||
def test_slave_setup_exit():
|
def test_slave_setup_exit():
|
||||||
|
|
|
@ -102,7 +102,7 @@ class Session(object):
|
||||||
if self.config.option.collectonly and isinstance(colitem, py.test.Item):
|
if self.config.option.collectonly and isinstance(colitem, py.test.Item):
|
||||||
return
|
return
|
||||||
if isinstance(colitem, py.test.Item):
|
if isinstance(colitem, py.test.Item):
|
||||||
colitem.skipbykeyword(self.config.option.keyword)
|
colitem._skipbykeyword(self.config.option.keyword)
|
||||||
res = colitem.run()
|
res = colitem.run()
|
||||||
if res is None:
|
if res is None:
|
||||||
return Passed()
|
return Passed()
|
||||||
|
|
|
@ -77,9 +77,9 @@ class TerminalSession(Session):
|
||||||
def start_Item(self, colitem):
|
def start_Item(self, colitem):
|
||||||
if self.config.option.verbose >= 1:
|
if self.config.option.verbose >= 1:
|
||||||
if isinstance(colitem, py.test.Item):
|
if isinstance(colitem, py.test.Item):
|
||||||
realpath, lineno = colitem.getpathlineno()
|
realpath, lineno = colitem._getpathlineno()
|
||||||
location = "%s:%d" % (realpath.basename, lineno+1)
|
location = "%s:%d" % (realpath.basename, lineno+1)
|
||||||
self.out.write("%-20s %s " % (location, colitem.getmodpath()))
|
self.out.write("%-20s %s " % (location, colitem._getmodpath()))
|
||||||
|
|
||||||
def finish(self, colitem, outcome):
|
def finish(self, colitem, outcome):
|
||||||
end = now()
|
end = now()
|
||||||
|
@ -265,7 +265,7 @@ class TerminalSession(Session):
|
||||||
#print "repr_failures sees traceback"
|
#print "repr_failures sees traceback"
|
||||||
#py.std.pprint.pprint(traceback)
|
#py.std.pprint.pprint(traceback)
|
||||||
if item and not self.config.option.fulltrace:
|
if item and not self.config.option.fulltrace:
|
||||||
path, firstlineno = item.getpathlineno()
|
path, firstlineno = item._getpathlineno()
|
||||||
ntraceback = traceback.cut(path=path, firstlineno=firstlineno)
|
ntraceback = traceback.cut(path=path, firstlineno=firstlineno)
|
||||||
if ntraceback == traceback:
|
if ntraceback == traceback:
|
||||||
ntraceback = ntraceback.cut(path=path)
|
ntraceback = ntraceback.cut(path=path)
|
||||||
|
@ -278,7 +278,7 @@ class TerminalSession(Session):
|
||||||
|
|
||||||
def repr_out_err(self, colitem):
|
def repr_out_err(self, colitem):
|
||||||
for parent in colitem.listchain():
|
for parent in colitem.listchain():
|
||||||
for name, obj in zip(['out', 'err'], parent.getouterr()):
|
for name, obj in zip(['out', 'err'], parent._getouterr()):
|
||||||
if obj:
|
if obj:
|
||||||
self.out.sep("- ", "%s: recorded std%s" % (parent.name, name))
|
self.out.sep("- ", "%s: recorded std%s" % (parent.name, name))
|
||||||
self.out.line(obj)
|
self.out.line(obj)
|
||||||
|
|
|
@ -19,9 +19,9 @@ def test_collect_listnames_and_back():
|
||||||
col3 = col2.join('filetest.py')
|
col3 = col2.join('filetest.py')
|
||||||
l = col3.listnames()
|
l = col3.listnames()
|
||||||
assert len(l) == 3
|
assert len(l) == 3
|
||||||
x = col1.getitembynames(l[1:])
|
x = col1._getitembynames(l[1:])
|
||||||
assert x.name == "filetest.py"
|
assert x.name == "filetest.py"
|
||||||
x = col1.getitembynames("/".join(l[1:]))
|
x = col1._getitembynames("/".join(l[1:]))
|
||||||
assert x.name == "filetest.py"
|
assert x.name == "filetest.py"
|
||||||
l2 = x.listnames()
|
l2 = x.listnames()
|
||||||
assert len(l2) == 3
|
assert len(l2) == 3
|
||||||
|
|
|
@ -272,7 +272,7 @@ class TestConfigColitems:
|
||||||
col = colitems[0]
|
col = colitems[0]
|
||||||
assert isinstance(col, py.test.collect.Directory)
|
assert isinstance(col, py.test.collect.Directory)
|
||||||
for col in col.listchain():
|
for col in col.listchain():
|
||||||
assert col.config is config
|
assert col._config is config
|
||||||
|
|
||||||
def test_getcolitems_twodirs(self):
|
def test_getcolitems_twodirs(self):
|
||||||
config = py.test.config._reparse([self.tmpdir, self.tmpdir])
|
config = py.test.config._reparse([self.tmpdir, self.tmpdir])
|
||||||
|
@ -292,7 +292,7 @@ class TestConfigColitems:
|
||||||
assert col2.name == 'a'
|
assert col2.name == 'a'
|
||||||
for col in colitems:
|
for col in colitems:
|
||||||
for subcol in col.listchain():
|
for subcol in col.listchain():
|
||||||
assert col.config is config
|
assert col._config is config
|
||||||
|
|
||||||
def test__getcol_global_file(self):
|
def test__getcol_global_file(self):
|
||||||
x = self.tmpdir.ensure("x.py")
|
x = self.tmpdir.ensure("x.py")
|
||||||
|
@ -303,7 +303,7 @@ class TestConfigColitems:
|
||||||
assert col.parent.name == self.tmpdir.basename
|
assert col.parent.name == self.tmpdir.basename
|
||||||
assert col.parent.parent is None
|
assert col.parent.parent is None
|
||||||
for col in col.listchain():
|
for col in col.listchain():
|
||||||
assert col.config is config
|
assert col._config is config
|
||||||
|
|
||||||
def test__getcol_global_dir(self):
|
def test__getcol_global_dir(self):
|
||||||
x = self.tmpdir.ensure("a", dir=1)
|
x = self.tmpdir.ensure("a", dir=1)
|
||||||
|
@ -313,7 +313,7 @@ class TestConfigColitems:
|
||||||
print col.listchain()
|
print col.listchain()
|
||||||
assert col.name == 'a'
|
assert col.name == 'a'
|
||||||
assert col.parent is None
|
assert col.parent is None
|
||||||
assert col.config is config
|
assert col._config is config
|
||||||
|
|
||||||
def test__getcol_pkgfile(self):
|
def test__getcol_pkgfile(self):
|
||||||
x = self.tmpdir.ensure("x.py")
|
x = self.tmpdir.ensure("x.py")
|
||||||
|
@ -325,7 +325,7 @@ class TestConfigColitems:
|
||||||
assert col.parent.name == x.dirpath().basename
|
assert col.parent.name == x.dirpath().basename
|
||||||
assert col.parent.parent is None
|
assert col.parent.parent is None
|
||||||
for col in col.listchain():
|
for col in col.listchain():
|
||||||
assert col.config is config
|
assert col._config is config
|
||||||
|
|
||||||
def test_get_collector_trail_and_back(self):
|
def test_get_collector_trail_and_back(self):
|
||||||
a = self.tmpdir.ensure("a", dir=1)
|
a = self.tmpdir.ensure("a", dir=1)
|
||||||
|
|
|
@ -76,9 +76,9 @@ class TestKeywordSelection:
|
||||||
conftest = o.join('conftest.py').write(py.code.Source("""
|
conftest = o.join('conftest.py').write(py.code.Source("""
|
||||||
import py
|
import py
|
||||||
class Class(py.test.collect.Class):
|
class Class(py.test.collect.Class):
|
||||||
def haskeyword(self, keyword):
|
def _haskeyword(self, keyword):
|
||||||
return keyword == 'xxx' or \
|
return keyword == 'xxx' or \
|
||||||
super(Class, self).haskeyword(keyword)
|
super(Class, self)._haskeyword(keyword)
|
||||||
"""))
|
"""))
|
||||||
for keyword in ('xxx', 'xxx test_2', 'TestClass', 'xxx -test_1',
|
for keyword in ('xxx', 'xxx test_2', 'TestClass', 'xxx -test_1',
|
||||||
'TestClass test_2', 'xxx TestClass test_2',):
|
'TestClass test_2', 'xxx TestClass test_2',):
|
||||||
|
@ -206,7 +206,7 @@ class TestTerminalSession:
|
||||||
assert int(err.strip()) == 23
|
assert int(err.strip()) == 23
|
||||||
|
|
||||||
assert isinstance(item.parent, py.test.collect.Module)
|
assert isinstance(item.parent, py.test.collect.Module)
|
||||||
out, err = item.parent.getouterr()
|
out, err = item.parent._getouterr()
|
||||||
assert out.find('module level output') != -1
|
assert out.find('module level output') != -1
|
||||||
allout = self.file.getvalue()
|
allout = self.file.getvalue()
|
||||||
print "allout:", allout
|
print "allout:", allout
|
||||||
|
|
Loading…
Reference in New Issue