question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a helper to test traces

See original GitHub issue

We 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:closed
  • Created 3 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
thepabloaguilarcommented, Jul 25, 2020

I’m implementing and I’ve decided to change a bit the API. It will be like pytest.raises:

def test_something(returns) -> None:
    with returns.has_trace(Success, function_foo):
        function_bar()
1reaction
sobolevncommented, Jul 21, 2020

LGTM! 👍

Thanks a lot!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found