How to turn a doctest.txt into isolated tests for better maintaince

If you are fixing bugs in addons that have long doctests in .txt format, debugging can slower than it needs to be as these tests tend to not be isolated and you can't run just parts of the test.

I came up with a straightforward way to convert a doctest for better isolation.