summaryrefslogtreecommitdiff
path: root/test/test_api.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-05-11 17:43:05 -0400
committerNed Batchelder <ned@nedbatchelder.com>2009-05-11 17:43:05 -0400
commit626da09f52409b59f2a0e19667db14230d587536 (patch)
tree3c3f43fce6727666be3b340f6ffd7c1b6c566877 /test/test_api.py
parent001ce91c5d1dc346214997d9f5502460eefb021a (diff)
downloadpython-coveragepy-626da09f52409b59f2a0e19667db14230d587536.tar.gz
Re-think the api to set the data file name and suffix.
Diffstat (limited to 'test/test_api.py')
-rw-r--r--test/test_api.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/test_api.py b/test/test_api.py
index f16c35d..f4c48f4 100644
--- a/test/test_api.py
+++ b/test/test_api.py
@@ -195,3 +195,48 @@ class ApiTest(CoverageTest):
self.assertEqual(cov.exclude_re, "(foo)|(bar)")
cov.clear_exclude()
self.assertEqual(cov.get_exclude_list(), [])
+
+ def testDatafileDefault(self):
+ # Default data file behavior: it's .coverage
+ self.makeFile("datatest1.py", """\
+ fooey = 17
+ """)
+
+ self.assert_equal_sets(os.listdir("."), ["datatest1.py"])
+ cov = coverage.coverage()
+ cov.start()
+ self.importModule("datatest1")
+ cov.stop()
+ cov.save()
+ self.assert_equal_sets(os.listdir("."),
+ ["datatest1.py", "datatest1.pyc", ".coverage"])
+
+ def testDatafileSpecified(self):
+ # You can specify the data file name.
+ self.makeFile("datatest2.py", """\
+ fooey = 17
+ """)
+
+ self.assert_equal_sets(os.listdir("."), ["datatest2.py"])
+ cov = coverage.coverage(datafile="cov.data")
+ cov.start()
+ self.importModule("datatest2")
+ cov.stop()
+ cov.save()
+ self.assert_equal_sets(os.listdir("."),
+ ["datatest2.py", "datatest2.pyc", "cov.data"])
+
+ def testDatafileSpecified(self):
+ # You can specify the data file name and suffix.
+ self.makeFile("datatest3.py", """\
+ fooey = 17
+ """)
+
+ self.assert_equal_sets(os.listdir("."), ["datatest3.py"])
+ cov = coverage.coverage(data_file="cov.data", data_suffix=".14")
+ cov.start()
+ self.importModule("datatest3")
+ cov.stop()
+ cov.save()
+ self.assert_equal_sets(os.listdir("."),
+ ["datatest3.py", "datatest3.pyc", "cov.data.14"])