Thanks for the suggestions.
Attached is a revised version of the patch.
- I believe I've fixed all tab/space issues in this version of the patch, though I may have missed some (http://www.python.org/dev/tools/ doesn't recommend an automated way of checking this).
- I've rewritten the selftests as you suggested, using re and eval
- I've rewritten the new selftests to use assertIn, assertNotIn
The existing tests don't use assertIn/assertNotIn; I'm working on a patch for that, but I'll file that as a separate bug.