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