Your file naming is confusing the interpreter. You've named your file "/Users/name/Documents/doctest.py" which has the same name as the doctest module.
Change the name and try again (make sure you remove the old doctest.pyc as well).
Demo:
Your code breaks as expected:
msvalkon@Lunkwill:/tmp$ python doctest.py
Traceback (most recent call last):
File "doctest.py", line 8, in <module>
import doctest
File "/tmp/doctest.py", line 9, in <module>
doctest.testmod()
AttributeError: 'module' object has no attribute 'testmod'
After renaming and removing the .pyc
msvalkon@Lunkwill:/tmp$ mv doctest.py dtest.py
msvalkon@Lunkwill:/tmp$ rm doctest.pyc
msvalkon@Lunkwill:/tmp$ python dtest.py
Traceback (most recent call last):
File "dtest.py", line 9, in <module>
doctest.testmod()
File "/usr/lib/python2.7/doctest.py", line 1885, in testmod
for test in finder.find(m, name, globs=globs, extraglobs=extraglobs):
File "/usr/lib/python2.7/doctest.py", line 900, in find
self._find(tests, obj, name, module, source_lines, globs, {})
File "/usr/lib/python2.7/doctest.py", line 954, in _find
globs, seen)
File "/usr/lib/python2.7/doctest.py", line 942, in _find
test = self._get_test(obj, name, module, globs, source_lines)
File "/usr/lib/python2.7/doctest.py", line 1026, in _get_test
filename, lineno)
File "/usr/lib/python2.7/doctest.py", line 645, in get_doctest
return DocTest(self.get_examples(string, name), globs,
File "/usr/lib/python2.7/doctest.py", line 659, in get_examples
return [x for x in self.parse(string, name)
File "/usr/lib/python2.7/doctest.py", line 621, in parse
self._parse_example(m, name, lineno)
File "/usr/lib/python2.7/doctest.py", line 679, in _parse_example
self._check_prompt_blank(source_lines, indent, name, lineno)
File "/usr/lib/python2.7/doctest.py", line 766, in _check_prompt_blank
line[indent:indent+3], line))
ValueError: line 2 of the docstring for __main__.area_tri lacks blank after >>>: '>>>area_tri(10, 10)'
Notice that you are not following doctest rules but this is another problem.