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
commit5288a2e51bc938dfcce206bb8ecffa9ac0c96871 (patch)
tree8dba3834ffee5a2a9ae9294c7c0172fbfee1e08b /test/test_api.py
parent8fbe22896bff70a8c72116eb222cd317f6db36d0 (diff)
downloadpython-coveragepy-git-5288a2e51bc938dfcce206bb8ecffa9ac0c96871.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 f16c35dd..f4c48f4d 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"])