1
0
mirror of https://github.com/django/django.git synced 2024-12-22 09:05:43 +00:00

Fixed #2771 -- Tweaked Django's doctest module so that it also works with

Python 2.5. Thanks, ymasuda.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@3819 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2006-09-25 02:33:28 +00:00
parent b4e5a96ccc
commit 5b490bba93
2 changed files with 6 additions and 2 deletions

View File

@ -154,6 +154,7 @@ answer newbie questions, and generally made Django that much better:
Gary Wilson <gary.wilson@gmail.com>
wojtek
ye7cakf02@sneakemail.com
ymasuda@ethercube.com
Cheng Zhang
A big THANK YOU goes to:

View File

@ -1319,13 +1319,16 @@ class DocTestRunner:
__LINECACHE_FILENAME_RE = re.compile(r'<doctest '
r'(?P<name>[\w\.]+)'
r'\[(?P<examplenum>\d+)\]>$')
def __patched_linecache_getlines(self, filename):
def __patched_linecache_getlines(self, filename, module_globals=None):
m = self.__LINECACHE_FILENAME_RE.match(filename)
if m and m.group('name') == self.test.name:
example = self.test.examples[int(m.group('examplenum'))]
return example.source.splitlines(True)
else:
if sys.version_info < (2, 5, 0):
return self.save_linecache_getlines(filename)
else:
return self.save_linecache_getlines(filename, module_globals)
def run(self, test, compileflags=None, out=None, clear_globs=True):
"""