Closed jaywonchung closed 1 month ago
That's where
pytest.approx
comes in:def test_discount(): discount = Discount(0.1) assert discount.percentage == pytest.approx(0.1) # Now passes
This is indeed the right way of comparing floats, thanks for patching it up!
As I was going through the course, I gathered some typo fixes and nitpicks.
Other than text tweaks, one non-trivial change I made is to the Python test file of
02_classes/07_outro
. When comparing two floating point numbers, small precision differences can lead to unwanted assertion fails like:I got this when I used
f32
for the floats instead off64
. But I think tests ought to pass whenf32
is used.That's where
pytest.approx
comes in:It's all up to the author -- Please feel free to accept and reject individual changes as you see fit. Thanks as always for the wonderful course.