diff -r dc0811953034 Lib/doctest.py --- a/Lib/doctest.py Fri Mar 25 12:50:54 2016 +0100 +++ b/Lib/doctest.py Fri Mar 25 12:57:11 2016 +0100 @@ -397,6 +397,10 @@ def _module_relative_path(module, path): basedir = os.path.split(sys.argv[0])[0] else: basedir = os.curdir + elif hasattr(module, '__path__') and len(module.__path__) == 1: + # Heuristic for package: if the package is only made of one directory, + # use this directory + basedir = list(module.__path__)[0] else: # A module w/o __file__ (this includes builtins) raise ValueError("Can't resolve paths relative to the module "