From 5b490bba93d03edc58f0903d5ebb75f7b0f44784 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 25 Sep 2006 02:33:28 +0000 Subject: [PATCH] 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 --- AUTHORS | 1 + django/test/doctest.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 215f396b2a..3c2542cb0d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -154,6 +154,7 @@ answer newbie questions, and generally made Django that much better: Gary Wilson wojtek ye7cakf02@sneakemail.com + ymasuda@ethercube.com Cheng Zhang A big THANK YOU goes to: diff --git a/django/test/doctest.py b/django/test/doctest.py index d600d15e52..3b364f0a75 100644 --- a/django/test/doctest.py +++ b/django/test/doctest.py @@ -1319,13 +1319,16 @@ class DocTestRunner: __LINECACHE_FILENAME_RE = re.compile(r'[\w\.]+)' r'\[(?P\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: - return self.save_linecache_getlines(filename) + 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): """