[svn r63017] rename colitem._config to colitem.config - it's an official attribute
--HG-- branch : trunk
This commit is contained in:
parent
9a47f06a59
commit
d626a63934
|
@ -24,7 +24,7 @@ from py.__.misc.warn import APIWARN
|
|||
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 ReprMetaInfo(object):
|
||||
|
@ -70,8 +70,8 @@ class Node(object):
|
|||
self.name = name
|
||||
self.parent = parent
|
||||
if config is None:
|
||||
config = getattr(parent, '_config')
|
||||
self._config = config
|
||||
config = parent.config
|
||||
self.config = config
|
||||
self.fspath = getattr(parent, 'fspath', None)
|
||||
|
||||
|
||||
|
@ -88,7 +88,7 @@ class Node(object):
|
|||
#self.__init__(name=name, parent=parent)
|
||||
|
||||
def __repr__(self):
|
||||
if getattr(self._config.option, 'debug', False):
|
||||
if getattr(self.config.option, 'debug', False):
|
||||
return "<%s %r %0x>" %(self.__class__.__name__,
|
||||
getattr(self, 'name', None), id(self))
|
||||
else:
|
||||
|
@ -265,7 +265,7 @@ class Node(object):
|
|||
starting from a different topdir).
|
||||
"""
|
||||
chain = self.listchain()
|
||||
topdir = self._config.topdir
|
||||
topdir = self.config.topdir
|
||||
relpath = chain[0].fspath.relto(topdir)
|
||||
if not relpath:
|
||||
if chain[0].fspath == topdir:
|
||||
|
@ -287,12 +287,12 @@ class Node(object):
|
|||
# XXX temporary hack: getrepr() should not take a 'style' argument
|
||||
# at all; it should record all data in all cases, and the style
|
||||
# should be parametrized in toterminal().
|
||||
if self._config.option.tbstyle == "short":
|
||||
if self.config.option.tbstyle == "short":
|
||||
style = "short"
|
||||
else:
|
||||
style = "long"
|
||||
repr = excinfo.getrepr(funcargs=True,
|
||||
showlocals=self._config.option.showlocals,
|
||||
showlocals=self.config.option.showlocals,
|
||||
style=style)
|
||||
for secname, content in zip(["out", "err"], outerr):
|
||||
if content:
|
||||
|
@ -382,7 +382,7 @@ class FSCollector(Collector):
|
|||
def __getstate__(self):
|
||||
if self.parent is None:
|
||||
# the root node needs to pickle more context info
|
||||
topdir = self._config.topdir
|
||||
topdir = self.config.topdir
|
||||
relpath = self.fspath.relto(topdir)
|
||||
if not relpath:
|
||||
if self.fspath == topdir:
|
||||
|
@ -390,7 +390,7 @@ class FSCollector(Collector):
|
|||
else:
|
||||
raise ValueError("%r not relative to topdir %s"
|
||||
%(self.fspath, topdir))
|
||||
return (self.name, self._config, relpath)
|
||||
return (self.name, self.config, relpath)
|
||||
else:
|
||||
return (self.name, self.parent)
|
||||
|
||||
|
@ -444,23 +444,23 @@ class Directory(FSCollector):
|
|||
return res
|
||||
|
||||
def consider_file(self, path):
|
||||
return self._config.pytestplugins.call_each(
|
||||
return self.config.pytestplugins.call_each(
|
||||
'pytest_collect_file', path=path, parent=self)
|
||||
|
||||
def consider_dir(self, path, usefilters=None):
|
||||
if usefilters is not None:
|
||||
APIWARN("0.99", "usefilters argument not needed")
|
||||
res = self._config.pytestplugins.call_firstresult(
|
||||
res = self.config.pytestplugins.call_firstresult(
|
||||
'pytest_collect_recurse', path=path, parent=self)
|
||||
if res is None or res:
|
||||
return self._config.pytestplugins.call_each(
|
||||
return self.config.pytestplugins.call_each(
|
||||
'pytest_collect_directory', path=path, parent=self)
|
||||
|
||||
from py.__.test.runner import basic_run_report, forked_run_report
|
||||
class Item(Node):
|
||||
""" a basic test item. """
|
||||
def _getrunner(self):
|
||||
if self._config.option.boxed:
|
||||
if self.config.option.boxed:
|
||||
return forked_run_report
|
||||
return basic_run_report
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class TestDSession:
|
|||
def test_add_remove_host(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
rep = run(item)
|
||||
session = DSession(item._config)
|
||||
session = DSession(item.config)
|
||||
host = GatewaySpec("localhost")
|
||||
host.node = MockNode()
|
||||
assert not session.host2pending
|
||||
|
@ -53,7 +53,7 @@ class TestDSession:
|
|||
def test_senditems_removeitems(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
rep = run(item)
|
||||
session = DSession(item._config)
|
||||
session = DSession(item.config)
|
||||
host = GatewaySpec("localhost")
|
||||
host.node = MockNode()
|
||||
session.addhost(host)
|
||||
|
@ -69,7 +69,7 @@ class TestDSession:
|
|||
def test_func():
|
||||
pass
|
||||
""")
|
||||
session = DSession(modcol._config)
|
||||
session = DSession(modcol.config)
|
||||
session.triggertesting([modcol])
|
||||
name, args, kwargs = session.queue.get(block=False)
|
||||
assert name == 'collectionreport'
|
||||
|
@ -78,7 +78,7 @@ class TestDSession:
|
|||
|
||||
def test_triggertesting_item(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
session = DSession(item._config)
|
||||
session = DSession(item.config)
|
||||
host1 = GatewaySpec("localhost")
|
||||
host1.node = MockNode()
|
||||
host2 = GatewaySpec("localhost")
|
||||
|
@ -99,7 +99,7 @@ class TestDSession:
|
|||
|
||||
def test_keyboardinterrupt(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
session = DSession(item._config)
|
||||
session = DSession(item.config)
|
||||
def raise_(timeout=None): raise KeyboardInterrupt()
|
||||
session.queue.get = raise_
|
||||
exitstatus = session.loop([])
|
||||
|
@ -107,7 +107,7 @@ class TestDSession:
|
|||
|
||||
def test_internalerror(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
session = DSession(item._config)
|
||||
session = DSession(item.config)
|
||||
def raise_(): raise ValueError()
|
||||
session.queue.get = raise_
|
||||
exitstatus = session.loop([])
|
||||
|
@ -115,7 +115,7 @@ class TestDSession:
|
|||
|
||||
def test_rescheduleevent(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
session = DSession(item._config)
|
||||
session = DSession(item.config)
|
||||
host1 = GatewaySpec("localhost")
|
||||
host1.node = MockNode()
|
||||
session.addhost(host1)
|
||||
|
@ -139,7 +139,7 @@ class TestDSession:
|
|||
def test_no_hosts_remaining_for_tests(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
# setup a session with one host
|
||||
session = DSession(item._config)
|
||||
session = DSession(item.config)
|
||||
host1 = GatewaySpec("localhost")
|
||||
host1.node = MockNode()
|
||||
session.addhost(host1)
|
||||
|
@ -164,7 +164,7 @@ class TestDSession:
|
|||
item1, item2 = modcol.collect()
|
||||
|
||||
# setup a session with two hosts
|
||||
session = DSession(item1._config)
|
||||
session = DSession(item1.config)
|
||||
host1 = GatewaySpec("localhost")
|
||||
host1.node = MockNode()
|
||||
session.addhost(host1)
|
||||
|
@ -191,7 +191,7 @@ class TestDSession:
|
|||
def test_hostup_adds_to_available(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
# setup a session with two hosts
|
||||
session = DSession(item._config)
|
||||
session = DSession(item.config)
|
||||
host1 = GatewaySpec("localhost")
|
||||
hostup = makehostup(host1)
|
||||
session.queueevent("hostup", hostup)
|
||||
|
@ -203,7 +203,7 @@ class TestDSession:
|
|||
|
||||
def test_event_propagation(self, testdir, EventRecorder):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
session = DSession(item._config)
|
||||
session = DSession(item.config)
|
||||
|
||||
evrec = EventRecorder(session.bus)
|
||||
session.queueevent("NOPevent", 42)
|
||||
|
@ -211,7 +211,7 @@ class TestDSession:
|
|||
assert evrec.getfirstnamed('NOPevent')
|
||||
|
||||
def runthrough(self, item):
|
||||
session = DSession(item._config)
|
||||
session = DSession(item.config)
|
||||
host1 = GatewaySpec("localhost")
|
||||
host1.node = MockNode()
|
||||
session.addhost(host1)
|
||||
|
@ -247,8 +247,8 @@ class TestDSession:
|
|||
def test_pass():
|
||||
pass
|
||||
""")
|
||||
modcol._config.option.exitfirst = True
|
||||
session = DSession(modcol._config)
|
||||
modcol.config.option.exitfirst = True
|
||||
session = DSession(modcol.config)
|
||||
host1 = GatewaySpec("localhost")
|
||||
host1.node = MockNode()
|
||||
session.addhost(host1)
|
||||
|
@ -270,7 +270,7 @@ class TestDSession:
|
|||
|
||||
def test_shuttingdown_filters_events(self, testdir, EventRecorder):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
session = DSession(item._config)
|
||||
session = DSession(item.config)
|
||||
host = GatewaySpec("localhost")
|
||||
session.addhost(host)
|
||||
loopstate = LoopState([])
|
||||
|
@ -291,9 +291,9 @@ class TestDSession:
|
|||
def test_pass():
|
||||
pass
|
||||
""")
|
||||
session = DSession(modcol._config)
|
||||
session = DSession(modcol.config)
|
||||
|
||||
modcol._config.option.keyword = "nothing"
|
||||
modcol.config.option.keyword = "nothing"
|
||||
dsel = session.filteritems([modcol])
|
||||
assert dsel == [modcol]
|
||||
items = modcol.collect()
|
||||
|
@ -305,7 +305,7 @@ class TestDSession:
|
|||
assert event.name == "deselected"
|
||||
assert event.args[0].items == items
|
||||
|
||||
modcol._config.option.keyword = "test_fail"
|
||||
modcol.config.option.keyword = "test_fail"
|
||||
remaining = session.filteritems(items)
|
||||
assert remaining == [items[0]]
|
||||
|
||||
|
@ -315,7 +315,7 @@ class TestDSession:
|
|||
|
||||
def test_hostdown_shutdown_after_completion(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
session = DSession(item._config)
|
||||
session = DSession(item.config)
|
||||
|
||||
host = GatewaySpec("localhost")
|
||||
host.node = MockNode()
|
||||
|
@ -338,7 +338,7 @@ class TestDSession:
|
|||
def test_pass():
|
||||
pass
|
||||
""")
|
||||
session = DSession(modcol._config)
|
||||
session = DSession(modcol.config)
|
||||
host = GatewaySpec("localhost")
|
||||
host.node = MockNode()
|
||||
session.addhost(host)
|
||||
|
|
|
@ -82,7 +82,7 @@ class TestMasterSlaveConnection:
|
|||
import os
|
||||
os.kill(os.getpid(), 15)
|
||||
""")
|
||||
node = mysetup.makenode(item._config)
|
||||
node = mysetup.makenode(item.config)
|
||||
node.send(item)
|
||||
ev, = mysetup.geteventargs("hostdown")
|
||||
assert ev.host == mysetup.host
|
||||
|
@ -100,7 +100,7 @@ class TestMasterSlaveConnection:
|
|||
|
||||
def test_send_on_closed_channel(self, testdir, mysetup):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
node = mysetup.makenode(item._config)
|
||||
node = mysetup.makenode(item.config)
|
||||
node.channel.close()
|
||||
py.test.raises(IOError, "node.send(item)")
|
||||
#ev = self.geteventargs(event.InternalException)
|
||||
|
@ -108,7 +108,7 @@ class TestMasterSlaveConnection:
|
|||
|
||||
def test_send_one(self, testdir, mysetup):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
node = mysetup.makenode(item._config)
|
||||
node = mysetup.makenode(item.config)
|
||||
node.send(item)
|
||||
ev, = mysetup.geteventargs("itemtestreport")
|
||||
assert ev.passed
|
||||
|
@ -126,7 +126,7 @@ class TestMasterSlaveConnection:
|
|||
import py
|
||||
py.test.skip("x")
|
||||
""")
|
||||
node = mysetup.makenode(items[0]._config)
|
||||
node = mysetup.makenode(items[0].config)
|
||||
for item in items:
|
||||
node.send(item)
|
||||
for outcome in "passed failed skipped".split():
|
||||
|
|
|
@ -4,14 +4,14 @@ from py.__.test.looponfail.remote import LooponfailingSession, LoopState, Remote
|
|||
class TestRemoteControl:
|
||||
def test_nofailures(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass\n")
|
||||
control = RemoteControl(item._config)
|
||||
control = RemoteControl(item.config)
|
||||
control.setup()
|
||||
failures = control.runsession()
|
||||
assert not failures
|
||||
|
||||
def test_failures_somewhere(self, testdir):
|
||||
item = testdir.getitem("def test_func(): assert 0\n")
|
||||
control = RemoteControl(item._config)
|
||||
control = RemoteControl(item.config)
|
||||
control.setup()
|
||||
failures = control.runsession()
|
||||
assert failures
|
||||
|
@ -26,7 +26,7 @@ class TestRemoteControl:
|
|||
def test_func():
|
||||
assert 0
|
||||
""")
|
||||
control = RemoteControl(modcol._config)
|
||||
control = RemoteControl(modcol.config)
|
||||
control.setup()
|
||||
failures = control.runsession()
|
||||
assert failures
|
||||
|
@ -54,7 +54,7 @@ class TestLooponFailing:
|
|||
def test_two():
|
||||
assert 1
|
||||
""")
|
||||
session = LooponfailingSession(modcol._config)
|
||||
session = LooponfailingSession(modcol.config)
|
||||
loopstate = LoopState()
|
||||
session.remotecontrol.setup()
|
||||
session.loop_once(loopstate)
|
||||
|
@ -76,7 +76,7 @@ class TestLooponFailing:
|
|||
def test_one():
|
||||
assert 0
|
||||
""")
|
||||
session = LooponfailingSession(modcol._config)
|
||||
session = LooponfailingSession(modcol.config)
|
||||
loopstate = LoopState()
|
||||
session.remotecontrol.setup()
|
||||
loopstate.colitems = []
|
||||
|
@ -103,7 +103,7 @@ class TestLooponFailing:
|
|||
def test_two():
|
||||
assert 0
|
||||
""")
|
||||
session = LooponfailingSession(modcol._config)
|
||||
session = LooponfailingSession(modcol.config)
|
||||
loopstate = LoopState()
|
||||
session.remotecontrol.setup()
|
||||
loopstate.colitems = []
|
||||
|
|
|
@ -11,14 +11,14 @@ class DefaultPlugin:
|
|||
ext = path.ext
|
||||
pb = path.purebasename
|
||||
if pb.startswith("test_") or pb.endswith("_test") or \
|
||||
path in parent._config.args:
|
||||
path in parent.config.args:
|
||||
if ext == ".py":
|
||||
return parent.Module(path, parent=parent)
|
||||
|
||||
def pytest_collect_directory(self, path, parent):
|
||||
if not parent.recfilter(path):
|
||||
# check if cmdline specified this dir or a subdir
|
||||
for arg in parent._config.args:
|
||||
for arg in parent.config.args:
|
||||
if path == arg or arg.relto(path):
|
||||
break
|
||||
else:
|
||||
|
@ -26,7 +26,7 @@ class DefaultPlugin:
|
|||
# not use parent.Directory here as we want
|
||||
# dir/conftest.py to be able to
|
||||
# define Directory(dir) already
|
||||
Directory = parent._config.getvalue('Directory', path)
|
||||
Directory = parent.config.getvalue('Directory', path)
|
||||
return Directory(path, parent=parent)
|
||||
|
||||
def pytest_addoption(self, parser):
|
||||
|
|
|
@ -8,7 +8,7 @@ class DoctestPlugin:
|
|||
|
||||
def pytest_collect_file(self, path, parent):
|
||||
if path.ext == ".py":
|
||||
if parent._config.getvalue("doctestmodules"):
|
||||
if parent.config.getvalue("doctestmodules"):
|
||||
return DoctestModule(path, parent)
|
||||
if path.check(fnmatch="test_*.txt"):
|
||||
return DoctestTextfile(path, parent)
|
||||
|
|
|
@ -26,7 +26,7 @@ class Support(object):
|
|||
class PluginTester(Support):
|
||||
def testdir(self):
|
||||
# XXX import differently, eg.
|
||||
# FSTester = self.pyfuncitem._config.pytestplugins.getpluginattr("pytester", "FSTester")
|
||||
# FSTester = self.pyfuncitem.config.pytestplugins.getpluginattr("pytester", "FSTester")
|
||||
from pytest_pytester import TmpTestdir
|
||||
crunner = TmpTestdir(self.pyfuncitem)
|
||||
#
|
||||
|
|
|
@ -36,7 +36,7 @@ class TmpTestdir:
|
|||
def __init__(self, pyfuncitem):
|
||||
self.pyfuncitem = pyfuncitem
|
||||
# XXX remove duplication with tmpdir plugin
|
||||
basetmp = pyfuncitem._config.ensuretemp("testdir")
|
||||
basetmp = pyfuncitem.config.ensuretemp("testdir")
|
||||
name = pyfuncitem.name
|
||||
for i in range(100):
|
||||
try:
|
||||
|
@ -166,7 +166,7 @@ class TmpTestdir:
|
|||
|
||||
def getitems(self, source):
|
||||
modcol = self.getmodulecol(source)
|
||||
return list(modcol._config.initsession().genitems([modcol]))
|
||||
return list(modcol.config.initsession().genitems([modcol]))
|
||||
#assert item is not None, "%r item not found in module:\n%s" %(funcname, source)
|
||||
#return item
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ class ReSTSyntaxTest(py.test.collect.Item):
|
|||
return (text, apigen_relpath + 'source/%s' % (relpath,))
|
||||
|
||||
def _checkskip(self, lpath, htmlpath=None):
|
||||
if not self._config.getvalue("forcegen"):
|
||||
if not self.config.getvalue("forcegen"):
|
||||
lpath = py.path.local(lpath)
|
||||
if htmlpath is not None:
|
||||
htmlpath = py.path.local(htmlpath)
|
||||
|
@ -140,7 +140,7 @@ class ReSTSyntaxTest(py.test.collect.Item):
|
|||
class DoctestText(py.test.collect.Item):
|
||||
def runtest(self):
|
||||
content = self._normalize_linesep()
|
||||
newcontent = self._config.pytestplugins.call_firstresult(
|
||||
newcontent = self.config.pytestplugins.call_firstresult(
|
||||
'pytest_doctest_prepare_content', content=content)
|
||||
if newcontent is not None:
|
||||
content = newcontent
|
||||
|
@ -192,7 +192,7 @@ class LinkCheckerMaker(py.test.collect.Collector):
|
|||
def genlinkchecks(self):
|
||||
path = self.fspath
|
||||
# generating functions + args as single tests
|
||||
timeout = self._config.getvalue("urlcheck_timeout")
|
||||
timeout = self.config.getvalue("urlcheck_timeout")
|
||||
for lineno, line in py.builtin.enumerate(path.readlines()):
|
||||
line = line.strip()
|
||||
if line.startswith('.. _'):
|
||||
|
@ -206,7 +206,7 @@ class LinkCheckerMaker(py.test.collect.Collector):
|
|||
tryfn = l[1].strip()
|
||||
name = "%s:%d" %(tryfn, lineno)
|
||||
if tryfn.startswith('http:') or tryfn.startswith('https'):
|
||||
if self._config.getvalue("urlcheck"):
|
||||
if self.config.getvalue("urlcheck"):
|
||||
yield CheckLink(name, parent=self,
|
||||
args=(tryfn, path, lineno, timeout), callobj=urlcheck)
|
||||
elif tryfn.startswith('webcal:'):
|
||||
|
|
|
@ -322,7 +322,7 @@ class TestTerminal:
|
|||
def test_hostup(self, testdir, linecomp):
|
||||
from py.__.execnet.gwmanage import GatewaySpec
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
rep = TerminalReporter(item._config, linecomp.stringio)
|
||||
rep = TerminalReporter(item.config, linecomp.stringio)
|
||||
rep.pyevent_hostup(makehostup())
|
||||
linecomp.assert_contains_lines([
|
||||
"*localhost %s %s - Python %s" %(sys.platform,
|
||||
|
@ -339,7 +339,7 @@ class TestTerminal:
|
|||
def test_func():
|
||||
assert 0
|
||||
""")
|
||||
rep = TerminalReporter(modcol._config, file=linecomp.stringio)
|
||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||
rep.config.bus.register(rep)
|
||||
rep.config.bus.notify("testrunstart", event.TestrunStart())
|
||||
|
||||
|
@ -366,7 +366,7 @@ class TestTerminal:
|
|||
def test_func():
|
||||
assert 0
|
||||
""", configargs=("-v",))
|
||||
rep = TerminalReporter(modcol._config, file=linecomp.stringio)
|
||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||
rep.config.bus.register(rep)
|
||||
rep.config.bus.notify("testrunstart", event.TestrunStart())
|
||||
items = modcol.collect()
|
||||
|
@ -390,7 +390,7 @@ class TestTerminal:
|
|||
|
||||
def test_collect_fail(self, testdir, linecomp):
|
||||
modcol = testdir.getmodulecol("import xyz")
|
||||
rep = TerminalReporter(modcol._config, file=linecomp.stringio)
|
||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||
rep.config.bus.register(rep)
|
||||
rep.config.bus.notify("testrunstart", event.TestrunStart())
|
||||
l = list(testdir.genitems([modcol]))
|
||||
|
@ -406,7 +406,7 @@ class TestTerminal:
|
|||
|
||||
def test_internalerror(self, testdir, linecomp):
|
||||
modcol = testdir.getmodulecol("def test_one(): pass")
|
||||
rep = TerminalReporter(modcol._config, file=linecomp.stringio)
|
||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||
excinfo = py.test.raises(ValueError, "raise ValueError('hello')")
|
||||
rep.pyevent_internalerror(event.InternalException(excinfo))
|
||||
linecomp.assert_contains_lines([
|
||||
|
@ -420,7 +420,7 @@ class TestTerminal:
|
|||
pass
|
||||
""", configargs=("-v",))
|
||||
host1 = GatewaySpec("localhost")
|
||||
rep = TerminalReporter(modcol._config, file=linecomp.stringio)
|
||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||
rep.pyevent_hostgatewayready(event.HostGatewayReady(host1, None))
|
||||
linecomp.assert_contains_lines([
|
||||
"*HostGatewayReady*"
|
||||
|
@ -433,7 +433,7 @@ class TestTerminal:
|
|||
def test_writeline(self, testdir, linecomp):
|
||||
modcol = testdir.getmodulecol("def test_one(): pass")
|
||||
stringio = py.std.cStringIO.StringIO()
|
||||
rep = TerminalReporter(modcol._config, file=linecomp.stringio)
|
||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||
rep.write_fspath_result(py.path.local("xy.py"), '.')
|
||||
rep.write_line("hello world")
|
||||
lines = linecomp.stringio.getvalue().split('\n')
|
||||
|
@ -448,14 +448,14 @@ class TestTerminal:
|
|||
def test_fail2():
|
||||
raise ValueError()
|
||||
""")
|
||||
rep = TerminalReporter(modcol._config, file=linecomp.stringio)
|
||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||
reports = [basic_run_report(x) for x in modcol.collect()]
|
||||
rep.pyevent_looponfailinginfo(event.LooponfailingInfo(reports, [modcol._config.topdir]))
|
||||
rep.pyevent_looponfailinginfo(event.LooponfailingInfo(reports, [modcol.config.topdir]))
|
||||
linecomp.assert_contains_lines([
|
||||
"*test_looponfailingreport.py:2: assert 0",
|
||||
"*test_looponfailingreport.py:4: ValueError*",
|
||||
"*waiting*",
|
||||
"*%s*" % (modcol._config.topdir),
|
||||
"*%s*" % (modcol.config.topdir),
|
||||
])
|
||||
|
||||
def test_tb_option(self, testdir, linecomp):
|
||||
|
@ -470,7 +470,7 @@ class TestTerminal:
|
|||
print 6*7
|
||||
g() # --calling--
|
||||
""", configargs=("--tb=%s" % tbopt,))
|
||||
rep = TerminalReporter(modcol._config, file=linecomp.stringio)
|
||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||
rep.config.bus.register(rep)
|
||||
rep.config.bus.notify("testrunstart", event.TestrunStart())
|
||||
rep.config.bus.notify("testrunstart", event.TestrunStart())
|
||||
|
@ -497,8 +497,8 @@ class TestTerminal:
|
|||
def test_foobar():
|
||||
pass
|
||||
""")
|
||||
rep = TerminalReporter(modcol._config, file=linecomp.stringio)
|
||||
modcol._config.bus.register(rep)
|
||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||
modcol.config.bus.register(rep)
|
||||
l = list(testdir.genitems([modcol]))
|
||||
assert len(l) == 1
|
||||
rep.config.bus.notify("itemstart", event.ItemStart(l[0]))
|
||||
|
@ -515,9 +515,9 @@ class TestTerminal:
|
|||
def test_interrupt_me():
|
||||
raise KeyboardInterrupt # simulating the user
|
||||
""", configargs=("--showskipsummary",) + ("-v",)*verbose)
|
||||
rep = TerminalReporter(modcol._config, file=linecomp.stringio)
|
||||
modcol._config.bus.register(rep)
|
||||
bus = modcol._config.bus
|
||||
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
|
||||
modcol.config.bus.register(rep)
|
||||
bus = modcol.config.bus
|
||||
bus.notify("testrunstart", event.TestrunStart())
|
||||
try:
|
||||
for item in testdir.genitems([modcol]):
|
||||
|
@ -576,8 +576,8 @@ class TestCollectonly:
|
|||
def test_func():
|
||||
pass
|
||||
""")
|
||||
rep = CollectonlyReporter(modcol._config, out=linecomp.stringio)
|
||||
modcol._config.bus.register(rep)
|
||||
rep = CollectonlyReporter(modcol.config, out=linecomp.stringio)
|
||||
modcol.config.bus.register(rep)
|
||||
indent = rep.indent
|
||||
rep.config.bus.notify("collectionstart", event.CollectionStart(modcol))
|
||||
linecomp.assert_contains_lines([
|
||||
|
@ -597,8 +597,8 @@ class TestCollectonly:
|
|||
import py
|
||||
py.test.skip("nomod")
|
||||
""")
|
||||
rep = CollectonlyReporter(modcol._config, out=linecomp.stringio)
|
||||
modcol._config.bus.register(rep)
|
||||
rep = CollectonlyReporter(modcol.config, out=linecomp.stringio)
|
||||
modcol.config.bus.register(rep)
|
||||
cols = list(testdir.genitems([modcol]))
|
||||
assert len(cols) == 0
|
||||
linecomp.assert_contains_lines("""
|
||||
|
@ -610,8 +610,8 @@ class TestCollectonly:
|
|||
modcol = testdir.getmodulecol(configargs=['--collectonly'], source="""
|
||||
raise ValueError(0)
|
||||
""")
|
||||
rep = CollectonlyReporter(modcol._config, out=linecomp.stringio)
|
||||
modcol._config.bus.register(rep)
|
||||
rep = CollectonlyReporter(modcol.config, out=linecomp.stringio)
|
||||
modcol.config.bus.register(rep)
|
||||
cols = list(testdir.genitems([modcol]))
|
||||
assert len(cols) == 0
|
||||
linecomp.assert_contains_lines("""
|
||||
|
|
|
@ -15,7 +15,7 @@ class TmpdirPlugin:
|
|||
|
||||
def pytest_pyfuncarg_tmpdir(self, pyfuncitem):
|
||||
name = pyfuncitem.name
|
||||
return pyfuncitem._config.mktemp(name, numbered=True)
|
||||
return pyfuncitem.config.mktemp(name, numbered=True)
|
||||
|
||||
# ===============================================================================
|
||||
#
|
||||
|
|
|
@ -140,7 +140,7 @@ class PyCollectorMixin(PyobjMixin, py.test.collect.Collector):
|
|||
return self.join(name)
|
||||
|
||||
def makeitem(self, name, obj):
|
||||
res = self._config.pytestplugins.call_firstresult(
|
||||
res = self.config.pytestplugins.call_firstresult(
|
||||
"pytest_pymodule_makeitem", modcol=self, name=name, obj=obj)
|
||||
if res:
|
||||
return res
|
||||
|
@ -172,25 +172,25 @@ class Module(py.test.collect.File, PyCollectorMixin):
|
|||
# we assume we are only called once per module
|
||||
mod = self.fspath.pyimport()
|
||||
#print "imported test module", mod
|
||||
self._config.pytestplugins.consider_module(mod)
|
||||
self.config.pytestplugins.consider_module(mod)
|
||||
return mod
|
||||
|
||||
def setup(self):
|
||||
if not self._config.option.nomagic:
|
||||
if not self.config.option.nomagic:
|
||||
#print "*" * 20, "INVOKE assertion", self
|
||||
py.magic.invoke(assertion=1)
|
||||
mod = self.obj
|
||||
self._config.pytestplugins.register(mod)
|
||||
self.config.pytestplugins.register(mod)
|
||||
if hasattr(mod, 'setup_module'):
|
||||
self.obj.setup_module(mod)
|
||||
|
||||
def teardown(self):
|
||||
if hasattr(self.obj, 'teardown_module'):
|
||||
self.obj.teardown_module(self.obj)
|
||||
if not self._config.option.nomagic:
|
||||
if not self.config.option.nomagic:
|
||||
#print "*" * 20, "revoke assertion", self
|
||||
py.magic.revoke(assertion=1)
|
||||
self._config.pytestplugins.unregister(self.obj)
|
||||
self.config.pytestplugins.unregister(self.obj)
|
||||
|
||||
class Class(PyCollectorMixin, py.test.collect.Collector):
|
||||
|
||||
|
@ -268,7 +268,7 @@ class FunctionMixin(PyobjMixin):
|
|||
teardown_func_or_meth(self.obj)
|
||||
|
||||
def _prunetraceback(self, traceback):
|
||||
if not self._config.option.fulltrace:
|
||||
if not self.config.option.fulltrace:
|
||||
code = py.code.Code(self.obj)
|
||||
path, firstlineno = code.path, code.firstlineno
|
||||
ntraceback = traceback.cut(path=path, firstlineno=firstlineno)
|
||||
|
@ -289,7 +289,7 @@ class Generator(FunctionMixin, PyCollectorMixin, py.test.collect.Collector):
|
|||
# test generators are collectors yet participate in
|
||||
# the test-item setup and teardown protocol.
|
||||
# otherwise we could avoid global setupstate
|
||||
self._config._setupstate.prepare(self)
|
||||
self.config._setupstate.prepare(self)
|
||||
l = []
|
||||
for i, x in py.builtin.enumerate(self.obj()):
|
||||
name, call, args = self.getcallargs(x)
|
||||
|
@ -348,7 +348,7 @@ class Function(FunctionMixin, py.test.collect.Item):
|
|||
""" execute the given test function. """
|
||||
if not self._deprecated_testexecution():
|
||||
kw = self.lookup_allargs()
|
||||
ret = self._config.pytestplugins.call_firstresult(
|
||||
ret = self.config.pytestplugins.call_firstresult(
|
||||
"pytest_pyfunc_call", pyfuncitem=self, args=self._args, kwargs=kw)
|
||||
|
||||
def lookup_allargs(self):
|
||||
|
@ -374,13 +374,13 @@ class Function(FunctionMixin, py.test.collect.Item):
|
|||
return kwargs
|
||||
|
||||
def lookup_onearg(self, argname):
|
||||
value = self._config.pytestplugins.call_firstresult(
|
||||
value = self.config.pytestplugins.call_firstresult(
|
||||
"pytest_pyfuncarg_" + argname, pyfuncitem=self)
|
||||
if value is not None:
|
||||
return value
|
||||
else:
|
||||
metainfo = self.repr_metainfo()
|
||||
#self._config.bus.notify("pyfuncarg_lookuperror", argname)
|
||||
#self.config.bus.notify("pyfuncarg_lookuperror", argname)
|
||||
raise LookupError("funcargument %r not found for: %s" %(argname,metainfo.verboseline()))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
|
|
@ -19,7 +19,7 @@ class RobustRun(object):
|
|||
"""
|
||||
def __init__(self, colitem, pdb=None):
|
||||
self.colitem = colitem
|
||||
self.getcapture = colitem._config._getcapture
|
||||
self.getcapture = colitem.config._getcapture
|
||||
self.pdb = pdb
|
||||
|
||||
def __repr__(self):
|
||||
|
@ -50,16 +50,16 @@ class RobustRun(object):
|
|||
|
||||
class ItemRunner(RobustRun):
|
||||
def setup(self):
|
||||
self.colitem._config._setupstate.prepare(self.colitem)
|
||||
self.colitem.config._setupstate.prepare(self.colitem)
|
||||
def teardown(self):
|
||||
self.colitem._config._setupstate.teardown_exact(self.colitem)
|
||||
self.colitem.config._setupstate.teardown_exact(self.colitem)
|
||||
def execute(self):
|
||||
#self.colitem.config.pytestplugins.pre_execute(self.colitem)
|
||||
self.colitem.runtest()
|
||||
#self.colitem.config.pytestplugins.post_execute(self.colitem)
|
||||
|
||||
def makereport(self, res, when, excinfo, outerr):
|
||||
testrep = self.colitem._config.pytestplugins.call_firstresult(
|
||||
testrep = self.colitem.config.pytestplugins.call_firstresult(
|
||||
"pytest_item_makereport", item=self.colitem,
|
||||
excinfo=excinfo, when=when, outerr=outerr)
|
||||
if self.pdb and testrep.failed:
|
||||
|
@ -96,7 +96,7 @@ def forked_run_report(item, pdb=None):
|
|||
EXITSTATUS_TESTEXIT = 4
|
||||
|
||||
ipickle = ImmutablePickler(uneven=0)
|
||||
ipickle.selfmemoize(item._config)
|
||||
ipickle.selfmemoize(item.config)
|
||||
def runforked():
|
||||
try:
|
||||
testrep = basic_run_report(item)
|
||||
|
|
|
@ -46,7 +46,7 @@ class Session(object):
|
|||
if isinstance(next, (tuple, list)):
|
||||
colitems[:] = list(next) + colitems
|
||||
continue
|
||||
assert self.bus is next._config.bus
|
||||
assert self.bus is next.config.bus
|
||||
notify = self.bus.notify
|
||||
if isinstance(next, Item):
|
||||
remaining = self.filteritems([next])
|
||||
|
|
|
@ -67,10 +67,10 @@ class TestCollector:
|
|||
|
||||
def test_listnames_and__getitembynames(self, testdir):
|
||||
modcol = testdir.getmodulecol("pass", withinit=True)
|
||||
print modcol._config.pytestplugins.getplugins()
|
||||
print modcol.config.pytestplugins.getplugins()
|
||||
names = modcol.listnames()
|
||||
print names
|
||||
dircol = modcol._config.getfsnode(modcol._config.topdir)
|
||||
dircol = modcol.config.getfsnode(modcol.config.topdir)
|
||||
x = dircol._getitembynames(names)
|
||||
assert modcol.name == x.name
|
||||
|
||||
|
@ -203,7 +203,7 @@ class TestCustomConftests:
|
|||
def pytest_addoption(self, parser):
|
||||
parser.addoption("--XX", action="store_true", default=False)
|
||||
def pytest_collect_recurse(self, path, parent):
|
||||
return parent._config.getvalue("XX")
|
||||
return parent.config.getvalue("XX")
|
||||
""")
|
||||
testdir.mkdir("hello")
|
||||
evrec = testdir.inline_run(testdir.tmpdir)
|
||||
|
|
|
@ -180,7 +180,7 @@ class TestConfigApi_getcolitems:
|
|||
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, tmpdir):
|
||||
config = py.test.config._reparse([tmpdir, tmpdir])
|
||||
|
@ -200,7 +200,7 @@ class TestConfigApi_getcolitems:
|
|||
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, tmpdir):
|
||||
x = tmpdir.ensure("x.py")
|
||||
|
@ -211,7 +211,7 @@ class TestConfigApi_getcolitems:
|
|||
assert col.parent.name == 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, tmpdir):
|
||||
x = tmpdir.ensure("a", dir=1)
|
||||
|
@ -221,7 +221,7 @@ class TestConfigApi_getcolitems:
|
|||
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, tmpdir):
|
||||
x = tmpdir.ensure("x.py")
|
||||
|
@ -233,7 +233,7 @@ class TestConfigApi_getcolitems:
|
|||
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
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -158,9 +158,9 @@ class TestConfigPickling:
|
|||
newcol = unpickler.load()
|
||||
newcol2 = unpickler.load()
|
||||
newcol3 = unpickler.load()
|
||||
assert newcol2._config is newcol._config
|
||||
assert newcol2.config is newcol.config
|
||||
assert newcol2.parent == newcol
|
||||
assert newcol2._config.topdir == topdir
|
||||
assert newcol2.config.topdir == topdir
|
||||
assert newcol.fspath == topdir
|
||||
assert newcol2.fspath.basename == dir1.basename
|
||||
assert newcol2.fspath.relto(topdir)
|
||||
|
|
|
@ -50,9 +50,9 @@ class TestModule:
|
|||
def test_module_participates_as_plugin(self, testdir):
|
||||
modcol = testdir.getmodulecol("")
|
||||
modcol.setup()
|
||||
assert modcol._config.pytestplugins.isregistered(modcol.obj)
|
||||
assert modcol.config.pytestplugins.isregistered(modcol.obj)
|
||||
modcol.teardown()
|
||||
assert not modcol._config.pytestplugins.isregistered(modcol.obj)
|
||||
assert not modcol.config.pytestplugins.isregistered(modcol.obj)
|
||||
|
||||
def test_module_considers_pytestplugins_at_import(self, testdir):
|
||||
modcol = testdir.getmodulecol("pytest_plugins='xasdlkj',")
|
||||
|
@ -237,7 +237,7 @@ class TestFunction:
|
|||
class Provider:
|
||||
def pytest_pyfuncarg_some(self, pyfuncitem):
|
||||
return pyfuncitem.name
|
||||
item._config.pytestplugins.register(Provider())
|
||||
item.config.pytestplugins.register(Provider())
|
||||
kw = item.lookup_allargs()
|
||||
assert len(kw) == 1
|
||||
|
||||
|
@ -246,7 +246,7 @@ class TestFunction:
|
|||
class Provider:
|
||||
def pytest_pyfuncarg_other(self, pyfuncitem):
|
||||
return pyfuncitem.name
|
||||
item._config.pytestplugins.register(Provider())
|
||||
item.config.pytestplugins.register(Provider())
|
||||
kw = item.lookup_allargs()
|
||||
assert len(kw) == 1
|
||||
name, value = kw.popitem()
|
||||
|
@ -260,7 +260,7 @@ class TestFunction:
|
|||
return pyfuncitem.name
|
||||
def pytest_pyfuncarg_other(self, pyfuncitem):
|
||||
return 42
|
||||
item._config.pytestplugins.register(Provider())
|
||||
item.config.pytestplugins.register(Provider())
|
||||
kw = item.lookup_allargs()
|
||||
assert len(kw) == 2
|
||||
assert kw['some'] == "test_func"
|
||||
|
@ -273,7 +273,7 @@ class TestFunction:
|
|||
def pytest_pyfuncarg_some(self, pyfuncitem):
|
||||
pyfuncitem.addfinalizer(lambda: l.append(42))
|
||||
return 3
|
||||
item._config.pytestplugins.register(Provider())
|
||||
item.config.pytestplugins.register(Provider())
|
||||
kw = item.lookup_allargs()
|
||||
assert len(kw) == 1
|
||||
assert kw['some'] == 3
|
||||
|
@ -295,13 +295,13 @@ class TestFunction:
|
|||
""")
|
||||
item1, item2 = testdir.genitems([modcol])
|
||||
modcol.setup()
|
||||
assert modcol._config.pytestplugins.isregistered(modcol.obj)
|
||||
assert modcol.config.pytestplugins.isregistered(modcol.obj)
|
||||
kwargs = item1.lookup_allargs()
|
||||
assert kwargs['something'] == "test_method"
|
||||
kwargs = item2.lookup_allargs()
|
||||
assert kwargs['something'] == "test_func"
|
||||
modcol.teardown()
|
||||
assert not modcol._config.pytestplugins.isregistered(modcol.obj)
|
||||
assert not modcol.config.pytestplugins.isregistered(modcol.obj)
|
||||
|
||||
class TestSorting:
|
||||
def test_check_equality_and_cmp_basic(self, testdir):
|
||||
|
|
|
@ -267,7 +267,7 @@ class TestPytestPluginInteractions:
|
|||
return x+0
|
||||
""")
|
||||
l = []
|
||||
call = modcol._config.pytestplugins.setupcall(modcol, "pytest_method", 1)
|
||||
call = modcol.config.pytestplugins.setupcall(modcol, "pytest_method", 1)
|
||||
assert len(call.methods) == 3
|
||||
results = call.execute()
|
||||
assert results == [1,2,2]
|
||||
|
|
Loading…
Reference in New Issue