Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul exception reporting. #129

Merged
merged 1 commit into from Mar 9, 2015
Merged

Conversation

rbtcollins
Copy link
Member

unittest2 recently added the ability to show local variables in
tracebacks as #111
requested for us. Reusing that requires some refactoring of our code,
in particular where we were reimplementing bits of the traceback
module. Now we can just hard-depend on traceback2 and linecache2 which
are brought in by unittest2 1.0.0.

Change-Id: Ieb3268029d26b48ed4fcd25ed644bd339f6aa3fb

* ``testtools.run`` now accepts ``--locals`` to show local variables
in tracebacks, which can be a significant aid in debugging. In doing
so we've removed the code reimplementing linecache and traceback as
the traceback2 and linecache2 modules can now be used instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call out the new dependency on traceback2 as a separate bullet point (although, thank heaven that deps aren't quite as much of a pain these days).

Also, nitpick, AIUI, it's not they can be used instead, but rather that we are using them. Is that right?

@jml
Copy link
Member

jml commented Mar 9, 2015

The pypy3 tests fail:

======================================================================
FAIL: testtools.tests.test_testresult.TestTextTestResult.test_stopTestRun_current_time
----------------------------------------------------------------------
Traceback (most recent call last):
  File "testtools/tests/test_testresult.py", line 1388, in test_stopTestRun_current_time
    DocTestMatches("... in 0.001s\n...", doctest.ELLIPSIS))
  File "testtools/testcase.py", line 435, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: Expected:
    ... in 0.001s
    ...
Got:
    <BLANKLINE>
    Ran 1 test in 0.000s
    OK

@rbtcollins
Copy link
Member Author

The test failure is not related to this code - note the 0.0000s vs 0.0001s.

unittest2 recently added the ability to show local variables in
tracebacks as testing-cabal#111
requested for us. Reusing that requires some refactoring of our code,
in particular where we were reimplementing bits of the traceback
module. Now we can just hard-depend on traceback2 and linecache2 which
are brought in by unittest2 1.0.0.

Change-Id: Ieb3268029d26b48ed4fcd25ed644bd339f6aa3fb
buffer=self.buffer,
stdout=self.stdout,
tb_locals=self.tb_locals)
except TypeError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh - this nested try / except is starting to look silly. I guess for now it's OK though. Let's hope we don't find a test runner that accepts 'tb_locals' but not 'verbosity :D

@thomir
Copy link
Member

thomir commented Mar 9, 2015

LGTM - can't wait to have locals printed in testtools :D

Cheers,

@rbtcollins
Copy link
Member Author

I'm going to merge this now as it has Thomi's +1 and Jono had no API concerns in his feedback (and I addressed all the please-do-X stuff).

@rbtcollins rbtcollins merged commit 55278e0 into testing-cabal:master Mar 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants