Closed leifwalsh closed 5 years ago
Sorry for the delay, I missed the notification for this issue somehow!
This is actually pretty simple to implement. I added an -e
/ --no-tracebacks
option just for you. It's included in version 2.13.0 (just released).
Thanks @CleanCut! I just tested this out on one of the example marbles tests and here's what I see when I toggle -e
.
Without -e
:
$ python -m green docs/examples/getting_started.py
F
Failure in docs.examples.getting_started.ResponseTestCase.test_create_resource
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 615, in run
testMethod()
File "/Users/jane/Development/marbles/docs/examples/getting_started.py", line 42, in test_create_resource
201
File "/Users/jane/Development/marbles/marbles/core/marbles/core/marbles.py", line 547, in wrapper
return attr(*args, msg=annotation, **kwargs)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 839, in assertEqual
assertion_func(first, second, msg=msg)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 832, in _baseAssertEqual
raise self.failureException(msg)
marbles.core.marbles.ContextualAssertionError: 409 != 201
Source (/Users/jane/Development/marbles/docs/examples/getting_started.py):
39 res = requests.put(endpoint, data=data)
> 40 self.assertEqual(
41 res.status_code,
42 201
43 )
Locals:
endpoint = 'http://example.com/api/v1/resource'
data = {'id': 1, 'name': 'Little Bobby Tables'}
res = <docs.examples.getting_started.Response object at 0x103fabeb8>
Ran 1 test in 0.125s
FAILED (failures=1)
With -e
:
$ python -m green -e docs/examples/getting_started.py
F
Failure in docs.examples.getting_started.ResponseTestCase.test_create_resource
Ran 1 test in 0.124s
FAILED (failures=1)
It looks like it does exclude the stacktrace but also a lot of the other failure message content. What we'd like to see when we pass -e
is this:
F
marbles.core.marbles.ContextualAssertionError: 409 != 201
Source (/Users/jane/Development/marbles/docs/examples/getting_started.py):
39 res = requests.put(endpoint, data=data)
> 40 self.assertEqual(
41 res.status_code,
42 201
43 )
Locals:
endpoint = 'http://example.com/api/v1/resource'
data = {'id': 1, 'name': 'Little Bobby Tables'}
res = <docs.examples.getting_started.Response object at 0x103fabeb8>
Ran 1 test in 0.125s
FAILED (failures=1)
So, everything except the stacktrace between the lines "F" and "marbles.core.marbles.ContextualAssertionError: 409 != 201". Is that possible?
Here's a screenshot to show colors
In https://github.com/twosigma/marbles/issues/62 we are discussing the prospect of using green to run marbles tests. It works, but one of the things about marbles is that we suppress printing of the traceback, because the message comes with all the information you'd get out of that.
Could we add an option to green to make it suppress printing those?