/home/johnny/projects/merlinux/py/dist/pytemp/sub5/test_other.py:3
/home/johnny/projects/merlinux/py/dist/py/path/common.py:433
def custom_import_hook(name, glob=None, loc=None, fromlist=None):
__tracebackhide__ = False
__file__ = glob and glob.get('__file__')
if isinstance(__file__, PathStr):
# try to perform a relative import
# for cooperation with py.magic.autopath, first look in the pkgdir
modules = None
if hasattr(__file__.__path__, 'pkgdir'):
modules = relativeimport(__file__.__path__.pkgdir, name)
if not modules:
modules = relativeimport(__file__.__path__, name)
if modules:
if fromlist:
submodule = modules[-1] # innermost submodule
# try to import submodules named in the 'fromlist' if the
# 'submodule' is a package
p = submodule.__file__.__path__
if p.check(basename='__init__.py'):
for name in fromlist:
relativeimport(p, name, parent=submodule)
# failures are fine
return submodule
else:
return modules[0] # outermost package
# fall-back
__tracebackhide__ = True
-> return old_import_hook(name, glob, loc, fromlist)
/home/johnny/projects/merlinux/py/dist/py/path/local/local.py:406
def pyimport(self, modname=None, ensuresyspath=True):
""" return path as an imported python module.
if modname is None, look for the containing package
and construct an according module name.
The module will be put/looked up in sys.modules.
"""
if not self.check():
raise py.error.ENOENT(self)
#print "trying to import", self
pkgpath = None
if modname is None:
#try:
# return self._module
#except AttributeError:
# pass
pkgpath = self.pypkgpath()
if pkgpath is not None:
if ensuresyspath:
self._prependsyspath(pkgpath.dirpath())
pkg = __import__(pkgpath.basename, None, None, [])
if hasattr(pkg, '__package__'):
modname = pkg.__package__.getimportname(self)
assert modname is not None, "package %s doesn't know %s" % (
pkg.__name__, self)
else:
names = self.new(ext='').relto(pkgpath.dirpath())
names = names.split(self.sep)
modname = ".".join(names)
else:
# no package scope, still make it possible
if ensuresyspath:
self._prependsyspath(self.dirpath())
modname = self.purebasename
-> mod = __import__(modname, None, None, ['__doc__'])
#self._module = mod
return mod
else:
try:
return sys.modules[modname]
except KeyError:
# we have a custom modname, do a pseudo-import
mod = py.std.new.module(modname)
mod.__file__ = str(self)
sys.modules[modname] = mod
try:
execfile(str(self), mod.__dict__)
except:
del sys.modules[modname]
raise
return mod
/home/johnny/projects/merlinux/py/dist/py/test/collect.py:386
def obj(self):
try:
return self._obj
except AttributeError:
failure = getattr(self, '_stickyfailure', None)
if failure is not None:
raise failure[0], failure[1], failure[2]
try:
-> self._obj = obj = self.fspath.pyimport()
except KeyboardInterrupt:
raise
except:
self._stickyfailure = py.std.sys.exc_info()
raise
return obj
/home/johnny/projects/merlinux/py/dist/py/test/collect.py:348
def run(self):
-> if getattr(self.obj, 'disabled', 0):
return []
return FSCollector.run(self)
/home/johnny/projects/merlinux/py/dist/py/test/collect.py:224
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. Mostly fixed, need to introduce skipped-by-keyword
"""
if yieldtype is None:
yieldtype = py.test.Item
if isinstance(self, yieldtype):
try:
self.skipbykeyword(keyword)
yield self
except py.test.Item.Skipped:
if reporterror is not None:
excinfo = py.code.ExceptionInfo()
reporterror((excinfo, self))
else:
if not isinstance(self, py.test.Item):
try:
if reporterror is not None:
reporterror((None, self))
-> for x in self.run():
for y in self.join(x).tryiter(yieldtype, reporterror, keyword):
yield y
except KeyboardInterrupt:
raise
except:
if reporterror is not None:
excinfo = py.code.ExceptionInfo()
reporterror((excinfo, self))
/home/johnny/projects/merlinux/py/dist/py/test/collect.py:225
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. Mostly fixed, need to introduce skipped-by-keyword
"""
if yieldtype is None:
yieldtype = py.test.Item
if isinstance(self, yieldtype):
try:
self.skipbykeyword(keyword)
yield self
except py.test.Item.Skipped:
if reporterror is not None:
excinfo = py.code.ExceptionInfo()
reporterror((excinfo, self))
else:
if not isinstance(self, py.test.Item):
try:
if reporterror is not None:
reporterror((None, self))
for x in self.run():
-> for y in self.join(x).tryiter(yieldtype, reporterror, keyword):
yield y
except KeyboardInterrupt:
raise
except:
if reporterror is not None:
excinfo = py.code.ExceptionInfo()
reporterror((excinfo, self))
/home/johnny/projects/merlinux/py/dist/py/test/rsession/rsession.py:263
def itemgen():
for x in colitems:
-> for y in x.tryiter(reporterror = lambda x: self.reporterror(reporter, x), keyword = keyword):
yield y
/home/johnny/projects/merlinux/py/dist/py/test/rsession/local.py:70
def local_loop(session, reporter, itemgenerator, shouldstop, config, runner=None):
assert runner is not None
#if runner is None:
# if session.config.option.apigen:
# runner = apigen_runner
# else:
# runner = box_runner
while 1:
try:
-> item = itemgenerator.next()
if shouldstop():
return
outcome = runner(item, session, reporter)
reporter(report.ReceivedItemOutcome(None, item, outcome))
except StopIteration:
break
/home/johnny/projects/merlinux/py/dist/py/test/rsession/rsession.py:270
def main(self, args, reporter=None, runner=None, shouldstop=None):
# check out if used options makes any sense
if not args:
args = [py.path.local()]
sshhosts = ['localhost'] # this is just an info to reporter
if not self.config.option.nomagic:
py.magic.invoke(assertion=1)
session_options.bind_config(self.config)
reporter, checkfun, startserverflag = self.init_reporter(reporter,
sshhosts, LocalReporter, args[0])
if shouldstop:
checkfun = shouldstop
reporter(report.TestStarted(sshhosts))
pkgdir = self.getpkgdir(args[0])
colitems = self.make_colitems(args, baseon=pkgdir.dirpath())
reporter(report.RsyncFinished())
if runner is None and self.config.option.apigen:
from py.__.apigen.tracer.tracer import Tracer
# XXX
module = py
#module = __import__(str(pkgdir.join('__init__.py')))
try:
self.docstorage = self.config.getinitialvalue('ApiGen').get_doc_storage()
except (ValueError, AttributeError):
raise NotImplementedError("Need to provide conftest "
"way of generating DocStorage")
self.tracer = Tracer(self.docstorage)
runner = apigen_runner
#elif runner is None and (self.config.option.usepdb or self.config.option.nocapture):
# runner = plain_runner
#elif runner is None:
# runner = box_runner
elif runner is None:
runner = RunnerPolicy[session_options.runner_policy]
keyword = self.config.option.keyword
def itemgen():
for x in colitems:
for y in x.tryiter(reporterror = lambda x: self.reporterror(reporter, x), keyword = keyword):
yield y
itemgenerator = itemgen()
#assert 0, "\n".join([",".join(x.listnames()) for x in
# list(itemgenerator)])
# XXX: We have to decide which runner to use at this point
-> local_loop(self, reporter, itemgenerator, checkfun, self.config, runner=runner)
reporter(report.TestFinished())
if startserverflag:
from py.__.test.rsession.web import kill_server
kill_server()
#py.test.Function.state.teardown_all()
if not self.config.option.nomagic:
py.magic.revoke(assertion=1)
if self.config.option.apigen:
try:
self.config.getinitialvalue('ApiGen').write_docs(self.docstorage)
except ValueError:
raise NotImplementedError("Cannot create docs - didn't "
"provided way of doing that in conftest")
/home/johnny/projects/merlinux/py/dist/py/test/rsession/testing/test_lsession.py:221
def test_module_raising(self):
tmpdir = tmp
tmpdir.ensure("sub5", "__init__.py")
tmpdir.ensure("sub5", "test_some.py").write(py.code.Source("""
1/0
"""))
tmpdir.ensure("sub5", "test_other.py").write(py.code.Source("""
import py
py.test.skip("reason")
"""))
args = [str(tmpdir.join("sub5"))]
config, args = py.test.Config.parse(args)
lsession = LSession(config)
allevents = []
-> lsession.main(args, reporter=allevents.append, runner=box_runner)
testevents = [x for x in allevents
if isinstance(x, report.ReceivedItemOutcome)]
assert len(testevents) == 0
failedtryiter = [x for x in allevents
if isinstance(x, report.FailedTryiter)]
assert len(failedtryiter) == 1
skippedtryiter = [x for x in allevents
if isinstance(x, report.SkippedTryiter)]
assert len(skippedtryiter) == 1
/home/johnny/projects/merlinux/py/dist/py/test/item.py:79
def execute(self, target, *args):
""" default implementation for calling a test target is to
simply call it.
"""
-> target(*args)
/home/johnny/projects/merlinux/py/dist/py/test/item.py:73
def run(self):
self.state.prepare(self)
-> self.execute(self.obj, *self.args)
/home/johnny/projects/merlinux/py/dist/py/test/rsession/executor.py:22
def execute(self):
try:
-> self.item.run()
outcome = Outcome()
except py.test.Item.Skipped, e:
outcome = Outcome(skipped=str(e))
except (KeyboardInterrupt, SystemExit):
raise
except:
excinfo = py.code.ExceptionInfo()
if isinstance(self.item, py.test.Function):
fun = self.item.obj # hope this is stable
code = py.code.Code(fun)
excinfo.traceback = excinfo.traceback.cut(
path=code.path, firstlineno=code.firstlineno)
outcome = Outcome(excinfo=excinfo, setupfailure=False)
if self.usepdb:
if self.reporter is not None:
self.reporter(report.ImmediateFailure(self.item,
ReprOutcome(outcome.make_repr())))
import pdb
pdb.post_mortem(excinfo._excinfo[2])
# XXX hmm, we probably will not like to continue from that point
# or we do?
raise SystemExit()
outcome.stdout = ""
outcome.stderr = ""
return outcome
/home/johnny/projects/merlinux/py/dist/py/test/rsession/local.py:31
def plain_runner(item, session, reporter):
# box executor is doing stdout/err catching for us, let's do it here
startcapture(session)
r = RunExecutor(item, usepdb=session.config.option.usepdb, reporter=reporter)
-> outcome = r.execute()
outcome = ReprOutcome(outcome.make_repr())
outcome.stdout, outcome.stderr = finishcapture(session)
return outcome
/home/johnny/projects/merlinux/py/dist/py/test/rsession/local.py:47
def apigen_runner(item, session, reporter):
r = RunExecutor(item, reporter=reporter)
session.tracer.start_tracing()
-> retval = plain_runner(item, session, reporter)
session.tracer.end_tracing()
return retval