From 8873519fdbeb3a78bd908be2fb0b7458f5b69247 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 12 Apr 2009 12:19:21 -0400 Subject: Python 2.4 reported lines a little differently, so we need to be able to have different gold files for that version. --- test/farm/annotate/gold_v24/white.py,cover | 31 ++++++++++++++++++++++++++++++ test/test_farm.py | 18 +++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 test/farm/annotate/gold_v24/white.py,cover (limited to 'test') diff --git a/test/farm/annotate/gold_v24/white.py,cover b/test/farm/annotate/gold_v24/white.py,cover new file mode 100644 index 0000000..952222c --- /dev/null +++ b/test/farm/annotate/gold_v24/white.py,cover @@ -0,0 +1,31 @@ + # A test case sent to me by Steve White + +> def f(self): +! if self==1: +! pass +! elif self.m('fred'): +! pass +! elif (g==1) and (b==2): +! pass +! elif self.m('fred')==True: +! pass +! elif ((g==1) and (b==2))==True: +! pass +> else: +! pass + +> def g(x): +> if x == 1: +> a = 1 +! else: +! a = 2 + +> g(1) + +> def h(x): +> if x == 1: +! a = 1 +> else: +> a = 2 + +> h(2) diff --git a/test/test_farm.py b/test/test_farm.py index e1a8c17..9c91e30 100644 --- a/test/test_farm.py +++ b/test/test_farm.py @@ -134,13 +134,31 @@ class FarmTestCase(object): def compare(self, dir1, dir2, filepattern=None): """Compare files matching `filepattern` in `dir1` and `dir2`. + `dir2` is interpreted as a prefix, with Python version numbers appended + to find the actual directory to compare with. "foo" will compare against + "foo_v241", "foo_v24", "foo_v2", or "foo", depending on which directory + is found first. + An assertion will be raised if the directories don't match in some way. """ + # Search for a dir2 with a version suffix. + version_suff = ''.join(map(str, sys.version_info[:3])) + while version_suff: + trydir = dir2 + '_v' + version_suff + if os.path.exists(trydir): + dir2 = trydir + break + version_suff = version_suff[:-1] + + assert os.path.exists(dir1), "Left directory missing: %s" % dir1 + assert os.path.exists(dir2), "Right directory missing: %s" % dir2 + dc = filecmp.dircmp(dir1, dir2) diff_files = self.fnmatch_list(dc.diff_files, filepattern) left_only = self.fnmatch_list(dc.left_only, filepattern) right_only = self.fnmatch_list(dc.right_only, filepattern) + assert not diff_files, "Files differ: %s" % (diff_files) assert not left_only, "Files in %s only: %s" % (dir1, left_only) assert not right_only, "Files in %s only: %s" % (dir2, right_only) -- cgit v1.2.1