TheDigitalCatOnline / blog_source

Source code of the blog
16 stars 6 forks source link

TDD in Python with pytest (simple calculator questions) #11

Closed labdmitriy closed 9 months ago

labdmitriy commented 1 year ago

Hi Leonardo,

Thanks a lot for your blog series!

Could you please provide some information about simple calculator's requirements and its testing using TDD:

Thank you.

lgiordani commented 1 year ago

Dmitry, thanks a lot for all the questions and the error corrections you sent. Rest assured I will tackle them as soon as possible. As for your questions:

  1. That's an interesting point that I haven't considered. I think we actually should check that everything works with float, but it's not a mistake (in my opinion) to consider float as a superset of integer and just get away with that. In practice, since this is a beginner's guide, I think it might be better to add later a couple of tests that check floats and to reason that these can supersede the integer ones. I will think about it, thanks for the input!
  2. Yes, I think pytest.approx() is the best way to deal with that problem. Clearly, if one is testing a scientific application requirements might be more stringent, but overall the representation is always an approximation.

I will try to update the series keeping in mind these questions. I'll leave this open as a reminder until I have something written to discuss. Thanks!

labdmitriy commented 1 year ago

Hi Leonardo,

Thank you for your answer!

lgiordani commented 1 year ago

@labdmitriy I addressed type-checking in this new section of the second post https://www.thedigitalcatonline.com/blog/2020/09/11/tdd-in-python-with-pytest-part-2/#the-problem-of-types. Please let me know it it makes sense or if there are still open questions. It's always useful to discuss such topics!