Ticket #2884 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

nevow.test.test_newflat has some tests which fail if pyc files are not compiled in the usual way

Reported by: exarkun Assigned to: exarkun
Priority: high Milestone:
Component: Nevow Severity: normal
Keywords: Cc:
Estimated Completion (YYYY/MM/DD): Branch: branches/newflat-filenames-2884
Author: exarkun

Description

Two tests in this module assume that they can predict the filename which should appear in a traceback by looking at __file__. However, it seems that filenames in the traceback end up different sometimes - in particular, they end up with a relative path instead of an absolute one.

===============================================================================
[FAIL]: nevow.test.test_newflat.FlattenTests.test_flattenExceptionStack

Traceback (most recent call last):
  File "../../installdir/lib/python2.5/site-packages/nevow/test/test_newflat.py", line 931, in test_flattenExceptionStack
    'raise RuntimeError("foo")')])
twisted.trial.unittest.FailTest: not equal:
a = [('../../installdir/lib/python2.5/site-packages/nevow/test/test_newflat.py',
  918,
  'render',
  'broken()'),
 ('../../installdir/lib/python2.5/site-packages/nevow/test/test_newflat.py',
  911,
  'broken',
  'raise RuntimeError("foo")')]
b = [('/var/lib/buildbot/twisted-trunk/q-nevowinstall/build/installdir/lib/python2.5/site-packages/nevow/test/test_newflat.py',
  918,
  'render',
  'broken()'),
 ('/var/lib/buildbot/twisted-trunk/q-nevowinstall/build/installdir/lib/python2.5/site-packages/nevow/test/test_newflat.py',
  911,
  'broken',
  'raise RuntimeError("foo")')]

===============================================================================
[FAIL]: nevow.test.test_newflat.FlattenerErrorTests.test_traceback

Traceback (most recent call last):
  File "../../installdir/lib/python2.5/site-packages/nevow/test/test_newflat.py", line 1059, in test_traceback
    here, g.func_code.co_firstlineno + 1))
twisted.trial.unittest.FailTest: not equal:
a = 'Exception while flattening:\n  File "../../installdir/lib/python2.5/site-packages/nevow/test/test_newflat.py", line 1037, in f\n    g()\n  File "../../installdir/lib/python2.5/site-packages/nevow/test/test_newflat.py", line 1039, in g\n    raise RuntimeError("reason")\nRuntimeError: reason\n'
b = 'Exception while flattening:\n  File "/var/lib/buildbot/twisted-trunk/q-nevowinstall/build/installdir/lib/python2.5/site-packages/nevow/test/test_newflat.py", line 1037, in f\n    g()\n  File "/var/lib/buildbot/twisted-trunk/q-nevowinstall/build/installdir/lib/python2.5/site-packages/nevow/test/test_newflat.py", line 1039, in g\n    raise RuntimeError("reason")\nRuntimeError: reason\n'

-------------------------------------------------------------------------------

Change History

05/26/09 17:13:44 changed by exarkun

  • branch set to branches/newflat-filenames-2884.
  • branch_author set to exarkun.

(In [17365]) Branching to 'newflat-filenames-2884'

05/26/09 17:34:40 changed by exarkun

  • keywords set to review.
  • owner deleted.

Alright, this is dealt with in the branch. The fix is pretty lame. It just changes the tests to use co_filename instead of __file__, since the former is what the actual traceback formatting code (from the standard library) uses, and the two don't necessarily agree.

06/01/09 16:03:15 changed by exarkun

  • keywords deleted.
  • owner set to exarkun.

06/01/09 16:15:17 changed by exarkun

(In [17415]) expand the HERE comment even more

refs #2884

06/01/09 16:17:49 changed by exarkun

  • keywords set to review.
  • owner deleted.

06/01/09 16:21:46 changed by exarkun

(In [17416]) update line numbers too

refs #2884

06/01/09 17:06:46 changed by zooko

I accidentally posted my review of this patch on #2830. Here it is:

I looked at this patch:

http://divmod.org/trac/changeset?new=branches%2Fnewflat-filenames-2884%4017370&old=branches%2Fnewflat-filenames-2884%4017365

I would delete the word "Arbitrarily".

I don't understand the HERE construct. Oh, I get it, you want to delay evaluation so that it gets the .func_code from the current.. Uh. I don't really understand it. How about replacing HERE with a function which takes a module object and returns a string? Or adding documentation explaining why this lambda thing is good and what it does.

06/03/09 15:01:18 changed by mithrandi

  • keywords deleted.
  • owner set to exarkun.

Okay, it's not pretty, but that's pretty much Python's fault; I'd say this is good to merge.

06/03/09 15:05:20 changed by exarkun

  • status changed from new to closed.
  • resolution set to fixed.

(In [17428]) Merge newflat-filenames-2884

Author: exarkun Reviewer: zooko, mithrandi Fixes: #2884

Change the way two tests construct filenames for comparison against formatted traceback strings. Previously, these tests used __file__; however, this will not necessarily agree with the results produced by the traceback module.

jethro@divmod.org