[svn r38747] hum, a last-minute namespace change: i missed

that fijal didn't move py.test.Item|Function to the py.test.collect namespace
at the time.  a pypy fix will follow shortly after i merged the dist.

--HG--
branch : trunk
This commit is contained in:
hpk 2007-02-13 20:21:53 +01:00
parent 1bddcfee3d
commit 3ab95e5672
16 changed files with 36 additions and 36 deletions

View File

@ -9,8 +9,8 @@ version = "0.9.0-beta"
initpkg(__name__, initpkg(__name__,
description = "py lib: agile development and test support library", description = "py lib: agile development and test support library",
revision = int('$LastChangedRevision: 38598 $'.split(':')[1][:-1]), revision = int('$LastChangedRevision: 38747 $'.split(':')[1][:-1]),
lastchangedate = '$LastChangedDate: 2007-02-12 17:57:45 +0100 (Mon, 12 Feb 2007) $', lastchangedate = '$LastChangedDate: 2007-02-13 20:21:53 +0100 (Tue, 13 Feb 2007) $',
version = version, version = version,
url = "http://codespeak.net/py", url = "http://codespeak.net/py",
download_url = "http://codespeak.net/download/py/py-%s.tar.gz" %(version,), download_url = "http://codespeak.net/download/py/py-%s.tar.gz" %(version,),
@ -43,8 +43,8 @@ initpkg(__name__,
'test.collect.Class' : ('./test/collect.py', 'Class'), 'test.collect.Class' : ('./test/collect.py', 'Class'),
'test.collect.Instance' : ('./test/collect.py', 'Instance'), 'test.collect.Instance' : ('./test/collect.py', 'Instance'),
'test.collect.Generator' : ('./test/collect.py', 'Generator'), 'test.collect.Generator' : ('./test/collect.py', 'Generator'),
'test.Item' : ('./test/item.py', 'Item'), 'test.collect.Item' : ('./test/item.py', 'Item'),
'test.Function' : ('./test/item.py', 'Function'), 'test.collect.Function' : ('./test/item.py', 'Function'),
# thread related API (still in early design phase) # thread related API (still in early design phase)
'_thread.WorkerPool' : ('./thread/pool.py', 'WorkerPool'), '_thread.WorkerPool' : ('./thread/pool.py', 'WorkerPool'),

View File

@ -87,13 +87,13 @@ def _checkskip(lpath):
py.test.skip("html file is up to date, use --forcegen to regenerate") py.test.skip("html file is up to date, use --forcegen to regenerate")
#return [] # no need to rebuild #return [] # no need to rebuild
class ReSTSyntaxTest(py.test.Item): class ReSTSyntaxTest(py.test.collect.Item):
def run(self): def run(self):
mypath = self.fspath mypath = self.fspath
_checkskip(mypath) _checkskip(mypath)
restcheck(py.path.svnwc(mypath)) restcheck(py.path.svnwc(mypath))
class DoctestText(py.test.Item): class DoctestText(py.test.collect.Item):
def run(self): def run(self):
# XXX quite nasty... but it works (fixes win32 issues) # XXX quite nasty... but it works (fixes win32 issues)
s = self._normalize_linesep() s = self._normalize_linesep()
@ -141,7 +141,7 @@ class LinkCheckerMaker(py.test.collect.Collector):
if tryfn == name: if tryfn == name:
return CheckLink(name, parent=self, args=(tryfn, path, lineno), obj=call) return CheckLink(name, parent=self, args=(tryfn, path, lineno), obj=call)
class CheckLink(py.test.Function): class CheckLink(py.test.collect.Function):
def setup(self): def setup(self):
pass pass
def teardown(self): def teardown(self):

View File

@ -254,7 +254,7 @@ serve some immediate purposes like paramtrized tests.
The other extension possibility goes deeper into the machinery The other extension possibility goes deeper into the machinery
and allows you to specify a custom test ``Item`` class which and allows you to specify a custom test ``Item`` class which
is responsible for setting up and executing an underlying is responsible for setting up and executing an underlying
test. [XXX not working: You can integrate your custom ``py.test.Item`` subclass test. [XXX not working: You can integrate your custom ``py.test.collect.Item`` subclass
by binding an ``Item`` name to a test class.] Or you can by binding an ``Item`` name to a test class.] Or you can
extend the collection process for a whole directory tree extend the collection process for a whole directory tree
by putting Items in a ``conftest.py`` configuration file. by putting Items in a ``conftest.py`` configuration file.

View File

@ -198,7 +198,7 @@ class Collector(object):
cases. cases.
""" """
if yieldtype is None: if yieldtype is None:
yieldtype = py.test.Item yieldtype = py.test.collect.Item
if isinstance(self, yieldtype): if isinstance(self, yieldtype):
try: try:
self._skipbykeyword(keyword) self._skipbykeyword(keyword)
@ -208,7 +208,7 @@ class Collector(object):
excinfo = py.code.ExceptionInfo() excinfo = py.code.ExceptionInfo()
reporterror((excinfo, self)) reporterror((excinfo, self))
else: else:
if not isinstance(self, py.test.Item): if not isinstance(self, py.test.collect.Item):
try: try:
if reporterror is not None: if reporterror is not None:
reporterror((None, self)) reporterror((None, self))
@ -431,7 +431,7 @@ class Class(PyCollectorMixin, Collector):
except IOError: except IOError:
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.collect.Item)):
return x._getsortvalue() return x._getsortvalue()
class Instance(PyCollectorMixin, Collector): class Instance(PyCollectorMixin, Collector):

View File

@ -5,7 +5,7 @@ DoctestFile = py.test.collect.DoctestFile
Directory = py.test.collect.Directory Directory = py.test.collect.Directory
Class = py.test.collect.Class Class = py.test.collect.Class
Generator = py.test.collect.Generator Generator = py.test.collect.Generator
Function = py.test.Function Function = py.test.collect.Function
Instance = py.test.collect.Instance Instance = py.test.collect.Instance
conf_iocapture = "fd" # overridable from conftest.py conf_iocapture = "fd" # overridable from conftest.py

View File

@ -1,6 +1,6 @@
import py import py
class DoctestText(py.test.Item): class DoctestText(py.test.collect.Item):
def _setcontent(self, content): def _setcontent(self, content):
self._content = content self._content = content

View File

@ -40,7 +40,7 @@ class Presenter(object):
self.out.line(prefix + source[i]) self.out.line(prefix + source[i])
def repr_item_info(self, item): def repr_item_info(self, item):
""" This method represents py.test.Item info (path and module) """ This method represents py.test.collect.Item info (path and module)
""" """
root = item.fspath root = item.fspath
modpath = item._getmodpath() modpath = item._getmodpath()

View File

@ -44,7 +44,7 @@ class RunExecutor(object):
excinfo = e.excinfo excinfo = e.excinfo
else: else:
excinfo = py.code.ExceptionInfo() excinfo = py.code.ExceptionInfo()
if isinstance(self.item, py.test.Function): if isinstance(self.item, py.test.collect.Function):
fun = self.item.obj # hope this is stable fun = self.item.obj # hope this is stable
code = py.code.Code(fun) code = py.code.Code(fun)
excinfo.traceback = excinfo.traceback.cut( excinfo.traceback = excinfo.traceback.cut(
@ -82,7 +82,7 @@ class ApigenExecutor(RunExecutor):
""" We want to trace *only* function objects here. Unsure """ We want to trace *only* function objects here. Unsure
what to do with custom collectors at all what to do with custom collectors at all
""" """
if hasattr(self.item, 'obj') and type(self.item) is py.test.Function: if hasattr(self.item, 'obj') and type(self.item) is py.test.collect.Function:
self.item.execute = self.wrap_underlaying self.item.execute = self.wrap_underlaying
self.item.run() self.item.run()

View File

@ -11,7 +11,7 @@ def basic_report(msg_type, message):
# pass # pass
##def report_error(excinfo): ##def report_error(excinfo):
## if isinstance(excinfo, py.test.Item.Skipped): ## if isinstance(excinfo, py.test.collect.Item.Skipped):
## # we need to dispatch this info ## # we need to dispatch this info
## report(Skipped(excinfo)) ## report(Skipped(excinfo))
## else: ## else:

View File

@ -12,7 +12,7 @@ def setup_module(mod):
if py.std.sys.platform == "win32": if py.std.sys.platform == "win32":
py.test.skip("skipping executor tests (some require os.fork)") py.test.skip("skipping executor tests (some require os.fork)")
class Item(py.test.Item): class Item(py.test.collect.Item):
def __init__(self, name, config): def __init__(self, name, config):
super(Item, self).__init__(name) super(Item, self).__init__(name)
self._config = config self._config = config

View File

@ -49,7 +49,7 @@ class NonWorkingChannel(object):
def _getremoteerror(self): def _getremoteerror(self):
return "blah" return "blah"
class Item(py.test.Item): class Item(py.test.collect.Item):
def _get_collector_trail(self): def _get_collector_trail(self):
return (self.name,) return (self.name,)

View File

@ -20,7 +20,7 @@ class Session(object):
def footer(self, colitems): def footer(self, colitems):
""" teardown any resources after a test run. """ """ teardown any resources after a test run. """
py.test.Function._state.teardown_all() py.test.collect.Function._state.teardown_all()
if not self.config.option.nomagic: if not self.config.option.nomagic:
py.magic.revoke(assertion=1) py.magic.revoke(assertion=1)
@ -99,9 +99,9 @@ class Session(object):
colitem.finishcapture() colitem.finishcapture()
def run(self, colitem): def run(self, colitem):
if self.config.option.collectonly and isinstance(colitem, py.test.Item): if self.config.option.collectonly and isinstance(colitem, py.test.collect.Item):
return return
if isinstance(colitem, py.test.Item): if isinstance(colitem, py.test.collect.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:

View File

@ -75,7 +75,7 @@ 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.collect.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()))
@ -100,7 +100,7 @@ class TerminalSession(Session):
resultstring = self.repr_progress_module_result(colitem, outcome) resultstring = self.repr_progress_module_result(colitem, outcome)
if resultstring: if resultstring:
self.out.line(" - " + resultstring) self.out.line(" - " + resultstring)
if isinstance(colitem, py.test.Item): if isinstance(colitem, py.test.collect.Item):
if self.config.option.verbose >= 1: if self.config.option.verbose >= 1:
resultstring = self.repr_progress_long_result(colitem, outcome) resultstring = self.repr_progress_long_result(colitem, outcome)
resultstring += " (%.2f)" % (colitem.elapsedtime,) resultstring += " (%.2f)" % (colitem.elapsedtime,)

View File

@ -109,7 +109,7 @@ class Testsomeclass:
#class TestWithCustomItem: #class TestWithCustomItem:
# class Item(py.test.Item): # class Item(py.test.collect.Item):
# flag = [] # flag = []
# def execute(self, target, *args): # def execute(self, target, *args):
# self.flag.append(42) # self.flag.append(42)
@ -146,8 +146,8 @@ def test_generative_simple():
l2 = generator.run() l2 = generator.run()
assert len(l2) == 2 assert len(l2) == 2
l2 = generator.multijoin(l2) l2 = generator.multijoin(l2)
assert isinstance(l2[0], py.test.Function) assert isinstance(l2[0], py.test.collect.Function)
assert isinstance(l2[1], py.test.Function) assert isinstance(l2[1], py.test.collect.Function)
assert l2[0].name == '[0]' assert l2[0].name == '[0]'
assert l2[1].name == '[1]' assert l2[1].name == '[1]'
@ -162,8 +162,8 @@ def test_generative_simple():
l2 = generator.run() l2 = generator.run()
assert len(l2) == 2 assert len(l2) == 2
l2 = generator.multijoin(l2) l2 = generator.multijoin(l2)
assert isinstance(l2[0], py.test.Function) assert isinstance(l2[0], py.test.collect.Function)
assert isinstance(l2[1], py.test.Function) assert isinstance(l2[1], py.test.collect.Function)
assert l2[0].name == '[0]' assert l2[0].name == '[0]'
assert l2[1].name == '[1]' assert l2[1].name == '[1]'
@ -171,7 +171,7 @@ def test_custom_python_collection_from_conftest():
o = tmpdir.ensure('customconfigtest', dir=1) o = tmpdir.ensure('customconfigtest', dir=1)
o.ensure('conftest.py').write("""if 1: o.ensure('conftest.py').write("""if 1:
import py import py
class MyFunction(py.test.Function): class MyFunction(py.test.collect.Function):
pass pass
class Directory(py.test.collect.Directory): class Directory(py.test.collect.Directory):
def filefilter(self, fspath): def filefilter(self, fspath):
@ -200,7 +200,7 @@ def test_custom_python_collection_from_conftest():
config = py.test.config._reparse([x]) config = py.test.config._reparse([x])
#print "checking that %s returns custom items" % (x,) #print "checking that %s returns custom items" % (x,)
col = config._getcollector(x) col = config._getcollector(x)
assert len(list(col._tryiter(py.test.Item))) == 2 assert len(list(col._tryiter(py.test.collect.Item))) == 2
#assert items[1].__class__.__name__ == 'MyFunction' #assert items[1].__class__.__name__ == 'MyFunction'
# test that running a session works from the directories # test that running a session works from the directories
@ -227,7 +227,7 @@ def test_custom_NONpython_collection_from_conftest():
o = tmpdir.ensure('customconfigtest_nonpython', dir=1) o = tmpdir.ensure('customconfigtest_nonpython', dir=1)
o.ensure('conftest.py').write("""if 1: o.ensure('conftest.py').write("""if 1:
import py import py
class CustomItem(py.test.Item): class CustomItem(py.test.collect.Item):
def run(self): def run(self):
pass pass
@ -247,7 +247,7 @@ def test_custom_NONpython_collection_from_conftest():
print "checking that %s returns custom items" % (x,) print "checking that %s returns custom items" % (x,)
config = py.test.config._reparse([x]) config = py.test.config._reparse([x])
col = config._getcollector(x) col = config._getcollector(x)
assert len(list(col._tryiter(py.test.Item))) == 1 assert len(list(col._tryiter(py.test.collect.Item))) == 1
#assert items[1].__class__.__name__ == 'MyFunction' #assert items[1].__class__.__name__ == 'MyFunction'
# test that running a session works from the directories # test that running a session works from the directories
@ -337,7 +337,7 @@ def test_documentation_virtual_collector_interaction():
try: try:
conf.option.forcegen = 1 conf.option.forcegen = 1
col = py.test.collect.Directory(rootdir) col = py.test.collect.Directory(rootdir)
x = list(col._tryiter(yieldtype=py.test.Function)) x = list(col._tryiter(yieldtype=py.test.collect.Function))
finally: finally:
conf.option.forcegen = old conf.option.forcegen = old

View File

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

View File

@ -192,7 +192,7 @@ class TestTerminalSession:
""")) """))
conftest = o.join('conftest.py').write(py.code.Source(""" conftest = o.join('conftest.py').write(py.code.Source("""
import py import py
class Function(py.test.Function): class Function(py.test.collect.Function):
def startcapture(self): def startcapture(self):
self._mycapture = None self._mycapture = None