exception stack depth not restricted to relevant modules

Bug #788974 reported by Luke Diamand
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
testtools
Fix Released
Wishlist
Jonathan Lange

Bug Description

Hi!

I'm just playing around with testtools trying to understand what I need to do to use them.

One thing I noticed is that when a test fails, I get the complete interpreter stack in the exception:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/testtools/runtest.py", line 169, in _run_user
    return fn(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/testtools/testcase.py", line 499, in _run_test_method
    return self._get_test_method()()
  File "./test-tt.py", line 17, in test_foo
    self.assertEqual(1,0)
  File "/usr/lib/python2.7/dist-packages/testtools/testcase.py", line 268, in assertEqual
    self.assertThat(observed, matcher)
  File "/usr/lib/python2.7/dist-packages/testtools/testcase.py", line 345, in assertThat
    % (matchee, matcher, mismatch.describe()))
AssertionError: Match failed. Matchee: "0"
Matcher: Equals(1)
Difference: 1 != 0

But most of that information is irrelevant, and I don't want to be trawling through it trying to work out what's going on.

In "unittest", it gets truncated to just the relevant parts:

Traceback (most recent call last):
  File "./test.py", line 15, in test_foo
    self.assertEqual(1,0)
AssertionError: 1 != 0

It looks like unittest has some code to strip out the junk, in the shape of functions _is_relevant_tb_levels() and _count_relevant_tb_levels().

I started looking to see where this could be fixed but couldn't see quite the cleanest way.

Related branches

Revision history for this message
Robert Collins (lifeless) wrote :

I thought we had a dupe of this but I can't find it.

It would be good to hide irrelevant frames, though that definition gets tricky when you consider we develop testtools with testtools.

Changed in testtools:
status: New → Triaged
importance: Undecided → Wishlist
Revision history for this message
Jonathan Lange (jml) wrote :

Bug 660852 isn't a dupe, but it's close. I think we can hide those frames without causing too many problems for testtools own development.

Jonathan Lange (jml)
Changed in testtools:
assignee: nobody → Jonathan Lange (jml)
status: Triaged → In Progress
Jonathan Lange (jml)
tags: added: over-verbosity
Jonathan Lange (jml)
Changed in testtools:
status: In Progress → Fix Committed
milestone: none → next
Jonathan Lange (jml)
Changed in testtools:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.