[svn r37879] s/tryiter/_tryiter/

--HG--
branch : trunk
This commit is contained in:
fijal 2007-02-03 19:44:34 +01:00
parent 1dca2498fb
commit e88a6c5fc3
12 changed files with 34 additions and 34 deletions

View File

@ -192,7 +192,7 @@ class Collector(object):
return True
return False
def tryiter(self, yieldtype=None, reporterror=None, keyword=None):
def _tryiter(self, yieldtype=None, reporterror=None, keyword=None):
""" yield stop item instances from flattening the collector.
XXX deprecated: this way of iteration is not safe in all
cases.
@ -213,7 +213,7 @@ class Collector(object):
if reporterror is not None:
reporterror((None, self))
for x in self.run():
for y in self.join(x).tryiter(yieldtype,
for y in self.join(x)._tryiter(yieldtype,
reporterror, keyword):
yield y
except KeyboardInterrupt:
@ -226,7 +226,7 @@ class Collector(object):
def _getsortvalue(self):
return self.name
captured_out = captured_err = None
_captured_out = _captured_err = None
def startcapture(self):
return None # by default collectors don't capture output
@ -234,7 +234,7 @@ class Collector(object):
return None # by default collectors don't capture output
def _getouterr(self):
return self.captured_out, self.captured_err
return self._captured_out, self._captured_err
def _get_collector_trail(self):
""" Shortcut
@ -369,7 +369,7 @@ class Module(FSCollector, PyCollectorMixin):
if hasattr(self, '_capture'):
capture = self._capture
del self._capture
self.captured_out, self.captured_err = capture.reset()
self._captured_out, self._captured_err = capture.reset()
def __repr__(self):
return "<%s %r>" % (self.__class__.__name__, self.name)
@ -436,7 +436,7 @@ class Class(PyCollectorMixin, Collector):
except IOError:
pass
# 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()
class Instance(PyCollectorMixin, Collector):

View File

@ -39,7 +39,7 @@ class Item(py.test.collect.Collector):
if hasattr(self, '_capture'):
capture = self._capture
del self._capture
self.captured_out, self.captured_err = capture.reset()
self._captured_out, self._captured_err = capture.reset()
class Function(Item):

View File

@ -36,7 +36,7 @@ class MasterNode(object):
def itemgen(colitems, reporter, keyword, reporterror):
for x in colitems:
for y in x.tryiter(reporterror = lambda x: reporterror(reporter, x), keyword = keyword):
for y in x._tryiter(reporterror = lambda x: reporterror(reporter, x), keyword = keyword):
yield y
def randomgen(items, done_dict):

View File

@ -288,7 +288,7 @@ class LocalReporter(AbstractReporter):
# XXX This is a terrible hack, I don't like it
# and will rewrite it at some point
#self.count = 0
lgt = len(list(item.tryiter()))
lgt = len(list(item._tryiter()))
#self.lgt = lgt
# print names relative to current workdir
name = "/".join(item.listnames())

View File

@ -66,7 +66,7 @@ class RestReporter(AbstractReporter):
def report_ItemStart(self, event):
item = event.item
if isinstance(item, py.test.collect.Module):
lgt = len(list(item.tryiter()))
lgt = len(list(item._tryiter()))
lns = item.listnames()[1:]
name = "/".join(lns)
link = self.get_linkwriter().get_link(self.get_rootpath(item),

View File

@ -123,7 +123,7 @@ class AbstractTestReporter(object):
rootcol = py.test.collect.Directory(tmpdir)
hosts = [HostInfo('localhost')]
r = self.reporter(config, hosts)
list(rootcol.tryiter(reporterror=lambda x : AbstractSession.reporterror(r.report, x)))
list(rootcol._tryiter(reporterror=lambda x : AbstractSession.reporterror(r.report, x)))
cap = py.io.StdCaptureFD()
boxfun()
@ -144,7 +144,7 @@ class AbstractTestReporter(object):
r = self.reporter(config, [host])
r.report(report.TestStarted([host]))
r.report(report.RsyncFinished())
list(rootcol.tryiter(reporterror=lambda x : AbstractSession.reporterror(r.report, x)))
list(rootcol._tryiter(reporterror=lambda x : AbstractSession.reporterror(r.report, x)))
r.report(report.TestFinished())
cap = py.io.StdCaptureFD()

View File

@ -78,7 +78,7 @@ Running tests on hosts\: localhost, foo.com
def __init__(self, parent):
self.parent = parent
self.fspath = py.path.local('.')
def tryiter(self):
def _tryiter(self):
return ['test_foo', 'test_bar']
def listnames(self):
return ['package', 'foo', 'bar.py']

View File

@ -68,7 +68,7 @@ def test_example_tryiter():
pass
"""))
rootcol = py.test.collect.Directory(tmpdir)
data = list(rootcol.tryiter(reporterror=events.append))
data = list(rootcol._tryiter(reporterror=events.append))
assert len(events) == 2
assert str(events[1][0].value) == "Reason"

View File

@ -62,7 +62,7 @@ def add_item(event):
'itemname': itemname}
#if itemtype == 'Module':
try:
d['length'] = str(len(list(event.item.tryiter())))
d['length'] = str(len(list(event.item._tryiter())))
except:
d['length'] = "?"
return d

View File

@ -64,8 +64,8 @@ class TerminalSession(Session):
and not self.config.option.collectonly):
try:
sum = 0
for sub in subitems:
sum += len(list(colitem.join(sub).tryiter()))
for sub in subitems:
sum += len(list(colitem.join(sub)._tryiter()))
except (SystemExit, KeyboardInterrupt):
raise
except:

View File

@ -40,7 +40,7 @@ def test_found_certain_testfiles():
tmp.ensure('found_test.py')
colitem = py.test.collect.Directory(tmp)
items = list(colitem.tryiter(py.test.collect.Module))
items = list(colitem._tryiter(py.test.collect.Module))
assert len(items) == 2
items = [item.name for item in items]
assert 'test_found.py' in items
@ -57,7 +57,7 @@ def test_ignored_certain_directories():
tmp.ensure('test_found.py')
colitem = py.test.collect.Directory(tmp)
items = list(colitem.tryiter(py.test.collect.Module))
items = list(colitem._tryiter(py.test.collect.Module))
assert len(items) == 2
for item in items:
assert item.name == 'test_found.py'
@ -196,7 +196,7 @@ def test_custom_python_collection_from_conftest():
config = py.test.config._reparse([x])
#print "checking that %s returns custom items" % (x,)
col = config._getcollector(x)
assert len(list(col.tryiter(py.test.Item))) == 2
assert len(list(col._tryiter(py.test.Item))) == 2
#assert items[1].__class__.__name__ == 'MyFunction'
# test that running a session works from the directories
@ -243,7 +243,7 @@ def test_custom_NONpython_collection_from_conftest():
print "checking that %s returns custom items" % (x,)
config = py.test.config._reparse([x])
col = config._getcollector(x)
assert len(list(col.tryiter(py.test.Item))) == 1
assert len(list(col._tryiter(py.test.Item))) == 1
#assert items[1].__class__.__name__ == 'MyFunction'
# test that running a session works from the directories
@ -319,13 +319,13 @@ def test_documentation_virtual_collector_interaction():
try:
conf.option.forcegen = 1
col = py.test.collect.Directory(rootdir)
x = list(col.tryiter(yieldtype=py.test.Function))
x = list(col._tryiter(yieldtype=py.test.Function))
finally:
conf.option.forcegen = old
def test_tryiter_ignores_skips():
tmp = py.test.ensuretemp("tryiterskip")
def test__tryiter_ignores_skips():
tmp = py.test.ensuretemp("_tryiterskip")
tmp.ensure("subdir", "conftest.py").write(py.code.Source("""
import py
class Directory(py.test.collect.Directory):
@ -334,7 +334,7 @@ def test_tryiter_ignores_skips():
"""))
col = py.test.collect.Directory(tmp)
try:
list(col.tryiter())
list(col._tryiter())
except KeyboardInterrupt:
raise
except:
@ -342,14 +342,14 @@ def test_tryiter_ignores_skips():
py.test.fail("should not have raised: %s" %(exc,))
def test_tryiter_ignores_failing_collectors():
tmp = py.test.ensuretemp("tryiterfailing")
def test__tryiter_ignores_failing_collectors():
tmp = py.test.ensuretemp("_tryiterfailing")
tmp.ensure("subdir", "conftest.py").write(py.code.Source("""
bla bla bla
"""))
col = py.test.collect.Directory(tmp)
try:
list(col.tryiter())
list(col._tryiter())
except KeyboardInterrupt:
raise
except:
@ -357,7 +357,7 @@ def test_tryiter_ignores_failing_collectors():
py.test.fail("should not have raised: %s" %(exc,))
l = []
list(col.tryiter(reporterror=l.append))
list(col._tryiter(reporterror=l.append))
assert len(l) == 2
excinfo, item = l[-1]
assert isinstance(excinfo, py.code.ExceptionInfo)
@ -368,7 +368,7 @@ def test_tryiter_handles_keyboardinterrupt():
raise KeyboardInterrupt()
"""))
col = py.test.collect.Directory(tmp)
py.test.raises(KeyboardInterrupt, list, col.tryiter())
py.test.raises(KeyboardInterrupt, list, col._tryiter())
def test_check_random_inequality():
tmp = py.test.ensuretemp("ineq")
@ -376,7 +376,7 @@ def test_check_random_inequality():
pass
"""))
col = py.test.collect.Directory(tmp)
fn = col.tryiter().next()
fn = col._tryiter().next()
assert fn != 3
assert fn != col
assert fn != [1,2,3]
@ -399,7 +399,7 @@ def test_check_generator_collect_problems():
tmp.ensure("__init__.py")
col = py.test.collect.Module(tmp.join("test_one.py"))
errors = []
l = list(col.tryiter(reporterror=errors.append))
l = list(col._tryiter(reporterror=errors.append))
assert len(errors) == 2
def test_check_collect_hashes():
@ -420,7 +420,7 @@ def test_check_collect_hashes():
"""))
tmp.ensure("__init__.py")
col = py.test.collect.Directory(tmp)
l = list(col.tryiter())
l = list(col._tryiter())
assert len(l) == 4
for numi, i in enumerate(l):
for numj, j in enumerate(l):

View File

@ -37,7 +37,7 @@ def test_collect_doctest_files_with_test_prefix():
#print "checking that %s returns custom items" % (x,)
config = py.test.config._reparse([x])
col = config._getcollector(x)
items = list(col.tryiter(py.test.Item))
items = list(col._tryiter(py.test.Item))
assert len(items) == 1
assert isinstance(items[0], DoctestText)