> Possibly that can be fixed with a '..testsetup' after the code? but I don't know if that actually works.

http://sphinx-doc.org/ext/doctest.html#directive-testcleanup