When developing any new software package in the group or contributing to existing open-source software packages, it is absolutely essential to write and regularly use unit tests (i.e. tests that evaluate the behavior and output of your various functions and classes). Simply put, this is the only way to know if your code is working as intended and if changes break your code in unexpected ways. You do not need to write unit tests at the very start of a project, although it can be good practice. That said, you must write unit tests before the end of a project.
While it may seem annoying at first to develop unit tests, they will save you an immense amount of pain in the long-term. We use pytest for our unit tests. The Turing Way Guide for Reproducible Research has a "Code Testing" section that is very useful. In general, if you are developing code to be used by others, these tests should run automatically on GitHub via a continuous integration setup. There is also a "Continuous Integration" section in the Turing Way guide.