How to do assert almost equal with py.test for floats without resorting to something like: assert x - 0.00001 <= y <= x + 0.00001 More specifically it will...
  • May 24, 2022
  • 0 Comments
I’m trying to use TDD (test-driven development) with pytest. pytest will not print to the console when I use print. I am using pytest my_tests.py to run it. The...
  • May 9, 2022
  • 0 Comments
I recently discovered pytest. It seems great. However, I feel the documentation could be better. I’m trying to understand what conftest.py files are meant to be used for. In...
  • May 7, 2022
  • 0 Comments
Code: # coding=utf-8 import pytest def whatever(): return 9/0 def test_whatever(): try: whatever() except ZeroDivisionError as exc: pytest.fail(exc, pytrace=True) Output: ================================ test session starts ================================= platform linux2 -- Python...
  • May 3, 2022
  • 0 Comments