I've got a fairly basic doctestable file:

```
class Foo():
    """
    >>> 3+2
    5
    """

if __name__ in ("__main__", "__console__"):
    import doctest
    doctest.testmod(verbose=True)

```

which works as expected when run directly through python.

However, in iPython, I get

```
1 items had no tests:
    __main__
0 tests in 1 items.
0 passed and 0 failed.
Test passed.

```

Since this is part of a Django project and will need access to all of the appropriate variables and such that manage.py sets up, I can also run it through a modified command, which uses code.InteractiveConsole, one result of which is `__name__` gets set to '`__console__`'.

With the code above, I get the same result as with iPython. I tried changing the last line to this:

```
 this = __import__(__name__)
 doctest.testmod(this, verbose=True)

```

and I get an ImportError on `__console__`, which makes sense, I guess. This has no effect on either python or ipython.

So, I'd like to be able to run doctests successfully through all three of these methods, especially the InteractiveConsole one, since I expect to be needing Django pony magic fairly soon.

Just for clarification, this is what I'm expecting:

```
Trying:
    3+2
Expecting:
    5
ok
1 items had no tests:
    __main__
1 items passed all tests:
   1 tests in __main__.Foo
1 tests in 2 items.
1 passed and 0 failed.
Test passed.

```