diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-06-23 22:08:19 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-06-23 22:08:19 -0400 |
commit | f76a9dfc839619d0fc5198ed26b11e358d9aace9 (patch) | |
tree | 322fd3b2bd133d2b6898a06f842bf8e65bd5e077 | |
parent | bdf2224e27903dd78cd294f0b97fc01adf5000bd (diff) | |
download | python-coveragepy-f76a9dfc839619d0fc5198ed26b11e358d9aace9.tar.gz |
Comparing files needs to be agnostic to line endings, or testing on Linux won't work. Now gold files are newline-only, and the comparison function ignores line endings.
-rw-r--r-- | test/farm/annotate/gold/white.py,cover | 66 | ||||
-rw-r--r-- | test/farm/annotate/gold_anno_dir/a_a.py,cover | 10 | ||||
-rw-r--r-- | test/farm/annotate/gold_anno_dir/b_b.py,cover | 4 | ||||
-rw-r--r-- | test/farm/annotate/gold_anno_dir/multi.py,cover | 10 | ||||
-rw-r--r-- | test/farm/annotate/gold_multi/a/a.py,cover | 10 | ||||
-rw-r--r-- | test/farm/annotate/gold_multi/b/b.py,cover | 4 | ||||
-rw-r--r-- | test/farm/annotate/gold_multi/multi.py,cover | 10 | ||||
-rw-r--r-- | test/farm/annotate/gold_v24/white.py,cover | 66 | ||||
-rw-r--r-- | test/farm/run/src/xxx | 16 | ||||
-rw-r--r-- | test/test_farm.py | 11 |
10 files changed, 108 insertions, 99 deletions
diff --git a/test/farm/annotate/gold/white.py,cover b/test/farm/annotate/gold/white.py,cover index 0287ea9..36b0b99 100644 --- a/test/farm/annotate/gold/white.py,cover +++ b/test/farm/annotate/gold/white.py,cover @@ -1,33 +1,33 @@ - # 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 0: #pragma: no cover
-- pass
-> if x == 1:
-! a = 1
-> else:
-> a = 2
-
-> h(2)
+ # 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 0: #pragma: no cover +- pass +> if x == 1: +! a = 1 +> else: +> a = 2 + +> h(2) diff --git a/test/farm/annotate/gold_anno_dir/a_a.py,cover b/test/farm/annotate/gold_anno_dir/a_a.py,cover index 0c858f4..fb3f543 100644 --- a/test/farm/annotate/gold_anno_dir/a_a.py,cover +++ b/test/farm/annotate/gold_anno_dir/a_a.py,cover @@ -1,5 +1,5 @@ -> def a(x):
-> if x == 1:
-> print "x is 1"
-! else:
-! print "x is not 1"
+> def a(x): +> if x == 1: +> print "x is 1" +! else: +! print "x is not 1" diff --git a/test/farm/annotate/gold_anno_dir/b_b.py,cover b/test/farm/annotate/gold_anno_dir/b_b.py,cover index 0bd04da..a3f5dae 100644 --- a/test/farm/annotate/gold_anno_dir/b_b.py,cover +++ b/test/farm/annotate/gold_anno_dir/b_b.py,cover @@ -1,2 +1,2 @@ -> def b(x):
-> print "x is %s" % x
+> def b(x): +> print "x is %s" % x diff --git a/test/farm/annotate/gold_anno_dir/multi.py,cover b/test/farm/annotate/gold_anno_dir/multi.py,cover index fc5b0b7..2a5c59c 100644 --- a/test/farm/annotate/gold_anno_dir/multi.py,cover +++ b/test/farm/annotate/gold_anno_dir/multi.py,cover @@ -1,5 +1,5 @@ -> import a.a
-> import b.b
-
-> a.a.a(1)
-> b.b.b(2)
+> import a.a +> import b.b + +> a.a.a(1) +> b.b.b(2) diff --git a/test/farm/annotate/gold_multi/a/a.py,cover b/test/farm/annotate/gold_multi/a/a.py,cover index 0c858f4..fb3f543 100644 --- a/test/farm/annotate/gold_multi/a/a.py,cover +++ b/test/farm/annotate/gold_multi/a/a.py,cover @@ -1,5 +1,5 @@ -> def a(x):
-> if x == 1:
-> print "x is 1"
-! else:
-! print "x is not 1"
+> def a(x): +> if x == 1: +> print "x is 1" +! else: +! print "x is not 1" diff --git a/test/farm/annotate/gold_multi/b/b.py,cover b/test/farm/annotate/gold_multi/b/b.py,cover index 0bd04da..a3f5dae 100644 --- a/test/farm/annotate/gold_multi/b/b.py,cover +++ b/test/farm/annotate/gold_multi/b/b.py,cover @@ -1,2 +1,2 @@ -> def b(x):
-> print "x is %s" % x
+> def b(x): +> print "x is %s" % x diff --git a/test/farm/annotate/gold_multi/multi.py,cover b/test/farm/annotate/gold_multi/multi.py,cover index fc5b0b7..2a5c59c 100644 --- a/test/farm/annotate/gold_multi/multi.py,cover +++ b/test/farm/annotate/gold_multi/multi.py,cover @@ -1,5 +1,5 @@ -> import a.a
-> import b.b
-
-> a.a.a(1)
-> b.b.b(2)
+> import a.a +> import b.b + +> a.a.a(1) +> b.b.b(2) diff --git a/test/farm/annotate/gold_v24/white.py,cover b/test/farm/annotate/gold_v24/white.py,cover index 3eca578..bbd8d42 100644 --- a/test/farm/annotate/gold_v24/white.py,cover +++ b/test/farm/annotate/gold_v24/white.py,cover @@ -1,33 +1,33 @@ - # 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 0: #pragma: no cover
-- pass
-> if x == 1:
-! a = 1
-> else:
-> a = 2
-
-> h(2)
+ # 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 0: #pragma: no cover +- pass +> if x == 1: +! a = 1 +> else: +> a = 2 + +> h(2) diff --git a/test/farm/run/src/xxx b/test/farm/run/src/xxx index 6b7eb9e..78f7d66 100644 --- a/test/farm/run/src/xxx +++ b/test/farm/run/src/xxx @@ -1,8 +1,8 @@ -# This is a python file though it doesn't look like it, like a main script.
-a = b = c = d = 0
-a = 3
-b = 4
-if not b:
- c = 6
-d = 7
-print "xxx:", a, b, c, d
+# This is a python file though it doesn't look like it, like a main script. +a = b = c = d = 0 +a = 3 +b = 4 +if not b: + c = 6 +d = 7 +print "xxx:", a, b, c, d diff --git a/test/test_farm.py b/test/test_farm.py index 9ca494f..d33dcdc 100644 --- a/test/test_farm.py +++ b/test/test_farm.py @@ -223,7 +223,16 @@ class FarmTestCase(object): wrong_size.append(f) assert not wrong_size, "File sizes differ: %s" % wrong_size else: - assert not diff_files, "Files differ: %s" % diff_files + # filecmp only compares in binary mode, but we want text mode. So + # look through the list of different files, and compare them + # ourselves. + text_diff = [] + for f in diff_files: + left = open(os.path.join(dir1, f), "r").read() + right = open(os.path.join(dir2, f), "r").read() + if left != right: + text_diff.append(f) + assert not text_diff, "Files differ: %s" % text_diff if not left_extra: assert not left_only, "Files in %s only: %s" % (dir1, left_only) |