TheDigitalCatOnline / blog_source

Source code of the blog
16 stars 6 forks source link

TDD in Python with pytest - Part 1 (incorrect output) #9

Closed labdmitriy closed 1 year ago

labdmitriy commented 1 year ago

Hi Leonardo,

Probably the output in this section should be different for testing results of the methods test_add_two_numbers and test_add_three_numbers, but now they are the same:

______________________________ test_add_two_numbers ________________________________

    def test_add_two_numbers():
        calculator = SimpleCalculator()

>       result = calculator.add(4, 5)
E       TypeError: add() missing 1 required positional argument: 'c'

tests/test_main.py:10: TypeError
_____________________________ test_add_three_numbers _______________________________

    def test_add_two_numbers():
        calculator = SimpleCalculator()

>       result = calculator.add(4, 5)
E       TypeError: add() missing 1 required positional argument: 'c'

tests/test_main.py:10: TypeError

In fact test_add_two_numbers has the error in the result, and you correctly describe it in the following sentence:

The first test now fails because the new add method requires three arguments and we are passing only two. The second tests fails because the method add returns 9 and not 15 as expected by the test.

Thank you.

lgiordani commented 1 year ago

Ouch! Thanks for spotting it, I will review the text :facepalm: I probably pasted the same output twice

lgiordani commented 1 year ago

This has been fixed. Thanks for the issue!