#test-isolation

[ follow ]
fromNedbatchelder
17 hours ago
Python

Testing: exceptions and caches

Use parameterized tests to unify success and exception cases, and clear or reset lru_cache between tests to avoid cached state leaking across tests.
Python
fromNedbatchelder
2 months ago

Why your mock breaks later

Patch mocks where the object is used, not where it's defined, to avoid unintended, global effects on other libraries and test infrastructure.
[ Load more ]