Files
courses/py3interm/EXAMPLES/pytests/test_special_assertions.py
2025-05-20 11:57:43 -04:00

18 lines
355 B
Python

#!/usr/bin/env python
import pytest
import math
FILE_NAME = 'IDONOTEXIST.txt'
def test_missing_filename():
with pytest.raises(FileNotFoundError): # <1>
open(FILE_NAME) # <2>
def test_list():
print()
assert (.1 + .2) == pytest.approx(.3) # <3>
def test_approximate_pi():
assert 22 / 7 == pytest.approx(math.pi, .001) # <4>