/tmp/pytest-418/repmod/test_two.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/rsession/reporter.py:298
def show_item(self, item, count_elems = True):
if isinstance(item, py.test.collect.Module):
# 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()))
#self.lgt = lgt
# print names relative to current workdir
name = "/".join(item.listnames())
local = str(py.path.local())
d = str(self.pkgdir.dirpath().dirpath())
if local.startswith(d):
local = local[len(d) + 1:]
if name.startswith(local):
name = name[len(local) + 1:]
self.out.write("\n%s[%d] " % (name, lgt))
/home/johnny/projects/merlinux/py/dist/py/test/rsession/reporter.py:291
def report_ItemStart(self, event): -> self.show_item(event.item)
/home/johnny/projects/merlinux/py/dist/py/test/rsession/reporter.py:44
def report(self, what):
repfun = getattr(self, "report_" + what.__class__.__name__,
self.report_unknown)
try:
-> repfun(what)
except (KeyboardInterrupt, SystemExit):
raise
except:
print "Internal reporting problem"
excinfo = py.code.ExceptionInfo()
for i in excinfo.traceback:
print str(i)[2:-1]
print excinfo
/home/johnny/projects/merlinux/py/dist/py/test/rsession/rsession.py:148
def reporterror(reporter, data):
excinfo, item = data
if excinfo is None:
-> reporter(report.ItemStart(item))
elif excinfo.type is py.test.Item.Skipped:
reporter(report.SkippedTryiter(excinfo, item))
else:
reporter(report.FailedTryiter(excinfo, item))
/home/johnny/projects/merlinux/py/dist/py/test/rsession/testing/test_reporter.py:102
-> list(rootcol.tryiter(reporterror=lambda x : AbstractSession.reporterror(r.report, x)))
/home/johnny/projects/merlinux/py/dist/py/test/collect.py:223
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/testing/test_reporter.py:102
def boxfun():
config, args = py.test.Config.parse([str(tmpdir)])
rootcol = py.test.collect.Directory(tmpdir)
r = self.reporter(config, ["localhost"])
-> list(rootcol.tryiter(reporterror=lambda x : AbstractSession.reporterror(r.report, x)))
/home/johnny/projects/merlinux/py/dist/py/test/rsession/testing/test_reporter.py:109
def _test_full_module(self):
tmpdir = py.test.ensuretemp("repmod")
tmpdir.ensure("__init__.py")
tmpdir.ensure("test_one.py").write(py.code.Source("""
def test_x():
pass
"""))
tmpdir.ensure("test_two.py").write(py.code.Source("""
import py
py.test.skip("reason")
"""))
tmpdir.ensure("test_three.py").write(py.code.Source("""
sadsadsa
"""))
def boxfun():
config, args = py.test.Config.parse([str(tmpdir)])
rootcol = py.test.collect.Directory(tmpdir)
r = self.reporter(config, ["localhost"])
list(rootcol.tryiter(reporterror=lambda x : AbstractSession.reporterror(r.report, x)))
#b = Box(boxfun)
#b.run()
s = StringIO()
stdoutcopy = sys.stdout
sys.stdout = s
-> boxfun()
sys.stdout = stdoutcopy
return s.getvalue()
/home/johnny/projects/merlinux/py/dist/py/test/rsession/testing/test_reporter.py:147
def test_full_module(self): -> assert self._test_full_module() == """ repmod/test_one.py[1] repmod/test_three.py[0] - FAILED TO LOAD MODULE repmod/test_two.py[0] - skipped (reason)"""
/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