The function should be written defensively. That is, it should handle incorrect input and errors detected during execution via throwing exceptions with useful error messages, and there should be tests to confirm that the exceptions result in the expected behaviour of the function.
The unit test function should test 3 to 5 edge cases to ensure that the function returns what is expected to the user.
[ ] When writing your tests, build them around your function specifications and requirements.
[ ] After writing your unit tests, write the internal code for your Python functions.
[ ] Write function code and tests in close temporal proximity with each other. The process of writing function code and test cases will be iterative; there will be several rounds of writing tests → function improvement → writing more tests → function improvement → writing more tests → function improvement, etc.
[ ] Make sure that the tests cover all branches (e.g., if your function has an if statement, you should have tests where the if the statement is true, and where the if the statement is false.
[ ] As you develop your code and test cases, update your code documentation so that it makes sense with any of the changes you have made. Do not forget to also document your test functions.
[ ] Check whether the code passes the unit tests you have written using the pytest package.
[ ] The function should be written defensively. That is, it should handle incorrect input and errors detected during execution via throwing exceptions with useful error messages, and there should be tests to confirm that the exceptions result in the expected behaviour of the function. (Exception handling)
The function should be written defensively. That is, it should handle incorrect input and errors detected during execution via throwing exceptions with useful error messages, and there should be tests to confirm that the exceptions result in the expected behaviour of the function.
refer to https://github.com/UBC-MDS/PyGram/issues/9#issuecomment-788468291