+ 1
assertions
HI everyone, I am not quite sure, after a lesson on assertions, still what they are used for and why they are used. I am not sure how they work with other statements e.g. print(0) assert "h" != "w" print(1) assert False print(2) assert True print(3) as used in the lesson. I understand that they are used to catch errors. but after that am not sure what they do with that. Can someone answer all these questions I have, please, as well as talk through this example code? Many thanks!
2 odpowiedzi
+ 1
assert check if the statement is True. If its true it returns nothing, else it returns AssertionError
https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/ref_keyword_assert.asp
but to build solid code testing, Unit Testing module should be used
https://www.datacamp.com/community/tutorials/unit-testing-python
+ 1
Ah, thank you!