Recently, I have had to begin patching a project that I was using. Having found and downloaded the source code from its version control, I looked for the documentation. Not finding any, I started a Jupyter notebook to work out what the methods were and to make notes on the progress.
Although that let me quickly write some code to see what was happening and to alter it, it is not a long term testing solution. So I converted the code into Behaviour Driven Development (BDD) tests using Behave. It is a start to begin clarifying the expected output and to have some tests put into a test script. Slowly, but surely, I am working through the potential tests and their combinations.
The next step is to write some unit tests to start looking at the parts of the code that are not concerned with user noticeable behaviour. These include some of the exception handling. Having previously unittest and nose, I have been looking at pytest instead. Slowly but surely, shape is appearing but it is going to take some time to work through.
Testing does take time and is not immediately productive in the sense of producing new code. It is helping identify the spaces where the code is not working as expected. These expectations might be code not working as expected (a bug) or producing unintended side effects (unexpected feature but not a bug). Testing shows these but has already provided some insight into other questions to do with digital methods code.