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

Feature request: Option to omit tracebacks #191

Closed
leifwalsh opened this issue Jul 22, 2018 · 3 comments
Closed

Feature request: Option to omit tracebacks #191

leifwalsh opened this issue Jul 22, 2018 · 3 comments

Comments

@leifwalsh
Copy link

In twosigma/marbles#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?

@CleanCut
Copy link
Owner

CleanCut commented Oct 5, 2018

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).

@thejunglejane
Copy link

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?

@thejunglejane
Copy link

Here's a screenshot to show colors
screen shot 2018-10-09 at 4 59 45 pm

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

No branches or pull requests

3 participants