cdent / gabbi

Declarative HTTP Testing for Python and anything else
http://gabbi.readthedocs.org/
Other
148 stars 34 forks source link

Stack trace is useless #283

Closed avkonst closed 3 years ago

avkonst commented 3 years ago

While developing tests I have noticed that these stack dumps are annoying:

FAIL: gabbi-runner.input_auth
        Traceback (most recent call last):
          File "/usr/lib/python3/dist-packages/gabbi/case.py", line 94, in wrapper
            func(self)
          File "/usr/lib/python3/dist-packages/gabbi/case.py", line 143, in test_request
            self._run_test()
          File "/usr/lib/python3/dist-packages/gabbi/case.py", line 550, in _run_test
            self._assert_response()
          File "/usr/lib/python3/dist-packages/gabbi/case.py", line 188, in _assert_response
            self._test_status(self.test_data['status'], self.response['status'])
          File "/usr/lib/python3/dist-packages/gabbi/case.py", line 591, in _test_status
            self.assert_in_or_print_output(observed_status, statii)
          File "/usr/lib/python3/dist-packages/gabbi/case.py", line 654, in assert_in_or_print_output
            self.assertIn(expected, iterable)
          File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 417, in assertIn
            self.assertThat(haystack, Contains(needle), message)
          File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 498, in assertThat
            raise mismatch_error
        testtools.matchers._impl.MismatchError: '400' not in ['200']

What I am interested in is the last line really. Ideally it should follow right after the test name, which is marked as failed:

✗ gabbi-runner.input_auth

Currently I always need to scroll up though the useless stacktrace to find out the test name.

cdent commented 3 years ago

From #282 it looks like you are using an old version of gabbi. This situation is improved (when using gabbi-run) in newer versions:

FAIL: gabbi-runner.test_bad_body
    '400' not found in ['200'], response:
    {
      "errors": [
        {
          "id": "ds1/NPukzFqW80-000009:-1",
          "status": 400,
          "title": "Bad Request",
          "detail": "Request body has an error: header 'Content-Type' has unexpected value: \"ponies\""
        }
      ]
    }