I’ve mostly been working on version 5.0 of my Extra Life Donation Tracker. Since I adopted the Semantic Versioning principle for the project, an API change means a major version change. I’ve been taking everything I’ve learned about Python programming from 2019 and 2020 and tried to make my code both more Pythonic and more sophisticated. I’m also trying to move towards 100% code coverage. That is to say, I’m looking to try and make sure every line of code is covered by a test. While 100% test coverage doesn’t guarantee perfect code (after all, the test itself could be flawed or I might not be considering corner cases), striving for it usually has a few benefits:
- by thinking about how you will test the code, you have to think about how the code works. This sometimes reveals errors.
- thinking about what you will test sometimes leads you to consider corner cases you hadn’t considered were there
- well-written tests help when dealing with bug fixes, new features, and refactors by helping to prevent/reduce introduction of new bugs
Getting to 100% coverage has been pretty hard and I’m currently struggling with how to force my code to cause errors that will allow me to make sure I’m catching errors correctly. I expect getting to 100% coverage will take the rest of today and probably go into next week. After that, I’ll be adding MyPy coverage (trying to make sure I’ve got type annotations throughout the code), using the “rich” module to generate better user output on the commandline, some tidying up, and then providing some new output for team-focused streamers.