derwiki-adroll / mock

Automatically exported from code.google.com/p/mock
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

mock patching truncates tracebacks #99

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Running the following test w/ nose:

    def test_mock_open(self):
        assert 1 == 2

I get the traceback:

Traceback (most recent call last):
  File "/home/<snip>/nose/case.py", line 187, in runTest
    self.test(*self.arg)
  File "/home/<snip>/tests/test_deps.py", line 68, in test_mock_open
    assert 1 == 2
AssertionError

But, if I patch it:

    @mock.patch('__builtin__.open')
    def test_mock_open(self, m_open):
        assert 1 == 2

Then my traceback is missing the last frame:

Traceback (most recent call last):
  File "/home/<snip>/nose/case.py", line 187, in runTest
    self.test(*self.arg)
AssertionError

This can make troubleshooting your tests VERY annoying if you have similar 
assertion messages in a test b/c you don't know which test is the one that is 
failing.

Original issue reported on code.google.com by rsyr...@gmail.com on 24 Jun 2011 at 4:28

GoogleCodeExporter commented 9 years ago
This is fixed on trunk and will be in 0.8

Original comment by fuzzyman on 2 Jul 2011 at 12:43