summaryrefslogtreecommitdiff
path: root/test
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
parent8fbe22896bff70a8c72116eb222cd317f6db36d0 (diff)
downloadpython-coveragepy-git-5288a2e51bc938dfcce206bb8ecffa9ac0c96871.tar.gz
Re-think the api to set the data file name and suffix.
Diffstat (limited to 'test')
-rw-r--r--test/test_api.py45
-rw-r--r--test/test_data.py6
2 files changed, 47 insertions, 4 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"])
diff --git a/test/test_data.py b/test/test_data.py
index 7a2687fd..44c123fe 100644
--- a/test/test_data.py
+++ b/test/test_data.py
@@ -48,13 +48,11 @@ class DataTest(CoverageTest):
self.assert_summary(covdata2, SUMMARY_1)
def test_combining(self):
- covdata1 = CoverageData()
- covdata1.set_suffix('1')
+ covdata1 = CoverageData(suffix='1')
covdata1.add_line_data(DATA_1)
covdata1.write()
- covdata2 = CoverageData()
- covdata2.set_suffix('2')
+ covdata2 = CoverageData(suffix='2')
covdata2.add_line_data(DATA_2)
covdata2.write()