bjoluc / pytest-reraise Goto Github PK
View Code? Open in Web Editor NEWMake multi-threaded pytest test cases fail when they should
License: MIT License
Make multi-threaded pytest test cases fail when they should
License: MIT License
The following example from the README isn't very useful since once the AssertionError
is raised in run()
, the rest isn't executed.
def test_assert(reraise):
def run():
with reraise:
assert False
t = Thread(target=run)
t.start()
t.join()
# Return the captured exception:
assert type(reraise.exception) is AssertionError
Instead I have to perform
import pytest
from threading import Thread
@pytest.mark.xfail(strict=True, raises=ValueError)
def test_assert(reraise):
def run():
with reraise:
raise ValueError
t = Thread(target=run)
t.start()
t.join()
# This won't be evaluated
assert type(reraise.exception) is 5
I feel I'm missing something.
It's great that the exception is raised to the main thread, but you cannot easily check what type it is without using @pytest.mark.xfail(strict=True, raises=ValueError)
It appears that reraise is discarding the traceback in the __exit__
. Is this intentional?
Hi
I'm getting this when trying to use the "raise.wrap()" that you mentioned:
AttributeError: module 'pytest_reraise.reraise' has no attribute 'wrap'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.