diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-04-18 21:15:06 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-04-18 21:15:06 -0400 |
commit | 826c1f45355d441b1da33f1ce45b2f933244a545 (patch) | |
tree | 3c968022eadcc3706fecaba27ff4e8108a2492c6 /test | |
parent | b2dfda7020ecce0e895d471fa305f5f7c64a983c (diff) | |
download | python-coveragepy-git-826c1f45355d441b1da33f1ce45b2f933244a545.tar.gz |
More annotate tests, but something is amiss.
Diffstat (limited to 'test')
-rw-r--r-- | test/farm/annotate/annotate_dir.py | 8 | ||||
-rw-r--r-- | test/farm/annotate/gold_anno_dir/a.py,cover | 5 | ||||
-rw-r--r-- | test/farm/annotate/gold_anno_dir/b.py,cover | 2 | ||||
-rw-r--r-- | test/farm/annotate/gold_anno_dir/multi.py,cover | 5 | ||||
-rw-r--r-- | test/test_farm.py | 16 |
5 files changed, 32 insertions, 4 deletions
diff --git a/test/farm/annotate/annotate_dir.py b/test/farm/annotate/annotate_dir.py new file mode 100644 index 00000000..23dfff30 --- /dev/null +++ b/test/farm/annotate/annotate_dir.py @@ -0,0 +1,8 @@ +copy("src", "run") +run(""" + coverage -x multi.py + coverage -a -d out_anno_dir + """, rundir="run") +compare("run/out_anno_dir", "gold_anno_dir", "*,cover", left_extra=True) +clean("out_anno_dir") +clean("run") diff --git a/test/farm/annotate/gold_anno_dir/a.py,cover b/test/farm/annotate/gold_anno_dir/a.py,cover new file mode 100644 index 00000000..0c858f41 --- /dev/null +++ b/test/farm/annotate/gold_anno_dir/a.py,cover @@ -0,0 +1,5 @@ +> 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.py,cover b/test/farm/annotate/gold_anno_dir/b.py,cover new file mode 100644 index 00000000..0bd04dac --- /dev/null +++ b/test/farm/annotate/gold_anno_dir/b.py,cover @@ -0,0 +1,2 @@ +> 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 new file mode 100644 index 00000000..fc5b0b79 --- /dev/null +++ b/test/farm/annotate/gold_anno_dir/multi.py,cover @@ -0,0 +1,5 @@ +> import a.a
+> import b.b
+
+> a.a.a(1)
+> b.b.b(2)
diff --git a/test/test_farm.py b/test/test_farm.py index 88f7d878..f6f646f6 100644 --- a/test/test_farm.py +++ b/test/test_farm.py @@ -130,7 +130,9 @@ class FarmTestCase(object): finally: self.cd(cwd) - def compare(self, dir1, dir2, filepattern=None): + def compare(self, dir1, dir2, filepattern=None, left_extra=False, + right_extra=False + ): """Compare files matching `filepattern` in `dir1` and `dir2`. `dir2` is interpreted as a prefix, with Python version numbers appended @@ -138,6 +140,10 @@ class FarmTestCase(object): "foo_v241", "foo_v24", "foo_v2", or "foo", depending on which directory is found first. + `left_extra` true means the left directory can have extra files in it + without triggering an assertion. `right_extra` means the right + directory can. + An assertion will be raised if the directories don't match in some way. """ @@ -159,8 +165,10 @@ class FarmTestCase(object): 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) + if not left_extra: + assert not left_only, "Files in %s only: %s" % (dir1, left_only) + if not right_extra: + assert not right_only, "Files in %s only: %s" % (dir2, right_only) def clean(self, cleandir): """Clean `cleandir` by removing it and all its children completely.""" @@ -173,7 +181,7 @@ def main(): # Run the test for real. case = FarmTestCase(sys.argv[2]) case() - if op == 'out': + elif op == 'out': # Run the test, but don't clean up, so we can examine the output. case = FarmTestCase(sys.argv[2], dont_clean=True) case() |