[py-dev] py.test error?
holger krekel
holger at merlinux.de
Fri Aug 3 17:54:43 CEST 2007
Hi Anurag!
indeed your example points to a py lib problem, probably
during parsing or interpretation of the expression
of the assert statement. Could you maybe provide a (minimally)
failing test, reproducing the problem? That should make
it easier to fix the problem.
best & thanks,
holger
On Wed, Aug 01, 2007 at 05:30 -0700, anurag uniyal wrote:
> While running py.test on my unitests I got following error in py.test code?
> It occurred when I changed an assert statement so that it fails.
> I tried to replicate this in a small sample script but could not replicate it.
>
> Here is the complete output:
>
> ______ entrypoint: Test_CollectionPrefs().test_recursive_attribute_access ______
>
> def runtraced(self, colitem):
> if self.shouldclose():
> raise Exit, "received external close signal"
>
> outcome = None
> colitem.startcapture()
> try:
> self.start(colitem)
> try:
> try:
> if colitem._stickyfailure:
> raise colitem._stickyfailure
> > outcome = self.run(colitem)
>
> [/usr/lib/python2.4/site-packages/py/test/session.py:83]
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> def run(self, colitem):
> if self.config.option.collectonly and isinstance(colitem, py.test.collect.Item):
> return
> if isinstance(colitem, py.test.collect.Item):
> colitem._skipbykeyword(self.config.option.keyword)
> > res = colitem.run()
>
> [/usr/lib/python2.4/site-packages/py/test/session.py:106]
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> def run(self):
> """ setup and execute the underlying test function. """
> self._state.prepare(self)
> > self.execute(self.obj, *self._args)
>
> [/usr/lib/python2.4/site-packages/py/test/item.py:67]
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> def execute(self, target, *args):
> """ execute the given test function. """
> > target(*args)
>
> [/usr/lib/python2.4/site-packages/py/test/item.py:71]
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> def __init__(self, *args):
> BuiltinAssertionError.__init__(self, *args)
> if args:
> self.msg = str(args[0])
> else:
> f = sys._getframe(1)
> try:
> source = py.code.Frame(f).statement
> source = str(source.deindent()).strip()
> except py.error.ENOENT:
> source = None
> # this can also occur during reinterpretation, when the
> # co_filename is set to "<run>".
> if source:
> > self.msg = exprinfo.interpret(source, f, should_fail=True)
>
> [/usr/lib/python2.4/site-packages/py/magic/assertion.py:22]
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> def interpret(source, frame, should_fail=False):
> module = Interpretable(parse(source, 'exec').node)
> #print "got module", module
> if isinstance(frame, py.std.types.FrameType):
> frame = py.code.Frame(frame)
> try:
> module.run(frame)
> except Failure, e:
> > return getfailure(e)
>
> [/usr/lib/python2.4/site-packages/py/magic/exprinfo.py:424]
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> def getfailure(e):
> > explanation = e.node.nice_explanation()
>
> [/usr/lib/python2.4/site-packages/py/magic/exprinfo.py:450]
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> def nice_explanation(self):
> # uck! See CallFunc for where \n{ and \n} escape sequences are used
> raw_lines = (self.explanation or '').split('\n')
> # escape newlines not followed by { and }
> lines = [raw_lines[0]]
> for l in raw_lines[1:]:
> if l.startswith('{') or l.startswith('}'):
> lines.append(l)
> else:
> lines[-1] += '\\n' + l
>
> result = lines[:1]
> stack = [0]
> stackcnt = [0]
> for line in lines[1:]:
> if line.startswith('{'):
> if stackcnt[-1]:
> s = 'and '
> else:
> s = 'where '
> stack.append(len(result))
> stackcnt[-1] += 1
> stackcnt.append(0)
> result.append(' +' + ' '*(len(stack)-1) + s + line[1:])
> else:
> assert line.startswith('}')
> stack.pop()
> stackcnt.pop()
> E result[stack[-1]] += line[1:]
> > IndexError: list index out of range
>
> [/usr/lib/python2.4/site-packages/py/magic/exprinfo.py:78]
> _______________________________________________________________
>
>
>
>
>
> ____________________________________________________________________________________
> Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
> http://answers.yahoo.com/dir/?link=list&sid=396545469
> _______________________________________________
> py-dev mailing list
> py-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/py-dev
>
--
merlinux GmbH Steinbergstr. 42 31139 Hildesheim
http://merlinux.de tel +49 5121 20800 75 (fax 77)
More information about the Pytest-dev
mailing list