In doctests, _ *must* be special-cased and removed from the user's
namespace because otherwise Python won't set it. But we were doing
this special-casing unconditionally, making it impossible to write
unittests that checked the _ variable after cell execution.
This commit makes the special-casing of _ apply only in the doctest
execution (where it's needed) and leaves normal unittests alone.
The actual bug fix was a trivial one-line change, made here. The rest
of the commits in this series improve our testing machinery and clean
up related code.
The actual fix was just calling the run_source instead of the run_code
method, which should only be called with compiled code objects.