#pytest

[ follow ]
fromNedbatchelder
5 days ago

Testing: exceptions and caches

Kacper Borucki blogged about parameterizing exception testing, and linked to pytest docs and a StackOverflow answer with similar approaches. The common way to test exceptions is to use pytest.raises as a context manager, and have separate tests for the cases that succeed and those that fail. Instead, this approach lets you unify them. I tweaked it to this, which I think reads nicely: One parameterized test that covers both good and bad outcomes. Nice.
#python
fromPythontest
5 months ago

pytest fixtures nuts and bolts - revisited | PythonTest

The new series on pytest fixtures splits the original content into individual concepts, ensuring each is clear and focused, which improves understanding and usability.
#testing
[ Load more ]