Add a helper to test traces
See original GitHub issueWe should add a new method to pytest
plugin. We need to test traces.
Here’s the usecase we are trying to cover. Imagine, there are multiple places where Failure
can happen with the same result. For example:
def first() -> ResultE[int]:
return Failure(KeyError('a'))
def second() -> ResultE[int]:
return Failure(KeyError('a'))
And we need to test that the reason why our app failed is first()
call, not second()
Matching by value is not good enough here, since values are identical. But, we can use traces!
def test_failure(returns):
assert returns.has_trace(my_function(), 'some trace object with `first()` call')
And it will pass for Failure
created by first()
and fail for Failure
created by second()
Related to #409 CC @thepabloaguilar
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
add t.Helper to make file:line results more useful · Issue #4899 ...
When you break a test and it panics instead of failing, you get a stack trace. I prefer the concision of the failures....
Read more >tracing_test - Rust - Docs.rs
Helper functions and macros that allow for easier testing of crates that use tracing . The focus is on testing the logging, not...
Read more >helper testing using ActionView::TestCase - technicalpickles
I want to add a helper for displaying a navigation tab. It will just go to index of a controller you specify. The...
Read more >How to allow testing helper method to throw exception without ...
I see a signature in testNG taking an actual exception: http://testng.org/javadoc/org/testng/Assert.html#fail(java.lang.String,%20java.lang.
Read more >A Guide to Testing Rails Applications - Ruby on Rails Guides
Helpers Available for Integration Tests; Integration Testing Examples ... Rails adds a test method that takes a test name and a block. It...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m implementing and I’ve decided to change a bit the API. It will be like
pytest.raises
:LGTM! 👍
Thanks a lot!