diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-11-28 20:24:23 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-11-28 20:24:23 -0500 |
commit | c72bfe70f9f8ac6d573689798b364bd664b93444 (patch) | |
tree | d356597357f024c6e252c8fc47137b74e42b8bc2 /test | |
parent | 49ede2bdf54a12e4eaa9472785cc5544040c077a (diff) | |
download | python-coveragepy-git-c72bfe70f9f8ac6d573689798b364bd664b93444.tar.gz |
Add data_file to the .coveragerc file.
--HG--
branch : config
Diffstat (limited to 'test')
-rw-r--r-- | test/test_api.py | 20 | ||||
-rw-r--r-- | test/test_config.py | 18 | ||||
-rw-r--r-- | test/test_farm.py | 2 |
3 files changed, 36 insertions, 4 deletions
diff --git a/test/test_api.py b/test/test_api.py index 270c7235..8470a661 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -243,6 +243,26 @@ class ApiTest(CoverageTest): self.assertSameElements(os.listdir("."), ["datatest3.py", "datatest3.pyc", "cov.data.14"]) + def testDatafileFromRcFile(self): + # You can specify the data file name in the .coveragerc file + self.make_file("datatest4.py", """\ + fooey = 17 + """) + self.make_file(".coveragerc", """\ + [run] + data_file = mydata.dat + """) + + self.assertSameElements(os.listdir("."), + ["datatest4.py", ".coveragerc"]) + cov = coverage.coverage() + cov.start() + self.import_module("datatest4") + cov.stop() + cov.save() + self.assertSameElements(os.listdir("."), + ["datatest4.py", "datatest4.pyc", ".coveragerc", "mydata.dat"]) + def testEmptyReporting(self): # Used to be you'd get an exception reporting on nothing... cov = coverage.coverage() diff --git a/test/test_config.py b/test/test_config.py index 4206fa98..06d43d31 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -15,49 +15,61 @@ class ConfigTest(CoverageTest): cov = coverage.coverage() self.assertFalse(cov.config.timid) self.assertFalse(cov.config.branch) + self.assertEqual(cov.config.data_file, ".coverage") def test_arguments(self): # Arguments to the constructor are applied to the configuation. - cov = coverage.coverage(timid=True) + cov = coverage.coverage(timid=True, data_file="fooey.dat") self.assert_(cov.config.timid) self.assertFalse(cov.config.branch) + self.assertEqual(cov.config.data_file, "fooey.dat") def test_config_file(self): # A .coveragerc file will be read into the configuration. self.make_file(".coveragerc", """\ + # This is just a bogus .rc file for testing. [run] - timid = True + timid = True + data_file = .hello_kitty.data """) cov = coverage.coverage() self.assert_(cov.config.timid) self.assertFalse(cov.config.branch) + self.assertEqual(cov.config.data_file, ".hello_kitty.data") def test_named_config_file(self): # You can name the config file what you like. self.make_file("my_cov.ini", """\ [run] timid = True + ; I wouldn't really use this as a data file... + data_file = delete.me """) cov = coverage.coverage(config_file="my_cov.ini") self.assert_(cov.config.timid) self.assertFalse(cov.config.branch) + self.assertEqual(cov.config.data_file, "delete.me") def test_ignored_config_file(self): # You can disable reading the .coveragerc file. self.make_file(".coveragerc", """\ [run] timid = True + data_file = delete.me """) cov = coverage.coverage(config_file=False) self.assertFalse(cov.config.timid) self.assertFalse(cov.config.branch) + self.assertEqual(cov.config.data_file, ".coverage") def test_config_file_then_args(self): # The arguments override the .coveragerc file. self.make_file(".coveragerc", """\ [run] timid = True + data_file = weirdo.file """) - cov = coverage.coverage(timid=False) + cov = coverage.coverage(timid=False, data_file=".mycov") self.assertFalse(cov.config.timid) self.assertFalse(cov.config.branch) + self.assertEqual(cov.config.data_file, ".mycov") diff --git a/test/test_farm.py b/test/test_farm.py index 859ba416..a36ae122 100644 --- a/test/test_farm.py +++ b/test/test_farm.py @@ -3,7 +3,7 @@ import difflib, filecmp, fnmatch, glob, os, re, shutil, sys sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k -from backtest import run_command, execfile # pylint: disable-msg=W0622 +from backtest import run_command, execfile # pylint: disable-msg=W0622 def test_farm(clean_only=False): |