diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2009-11-28 17:30:59 -0500 |
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-11-28 17:30:59 -0500 |
| commit | 49ede2bdf54a12e4eaa9472785cc5544040c077a (patch) | |
| tree | 47a85e29d5b3232c777173df0fc494987c66516f /test/test_config.py | |
| parent | c975721a9cea8716849b1f01a6007d3c3dd3a5fa (diff) | |
| download | python-coveragepy-git-49ede2bdf54a12e4eaa9472785cc5544040c077a.tar.gz | |
Test the config file support.
--HG--
branch : config
Diffstat (limited to 'test/test_config.py')
| -rw-r--r-- | test/test_config.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/test_config.py b/test/test_config.py new file mode 100644 index 00000000..4206fa98 --- /dev/null +++ b/test/test_config.py @@ -0,0 +1,63 @@ +"""Test the config file handling for coverage.py""" + +import os, sys +import coverage + +sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k +from coveragetest import CoverageTest + + +class ConfigTest(CoverageTest): + """Tests of the config file support.""" + + def test_default_config(self): + # Just constructing a coverage() object gets the right defaults. + cov = coverage.coverage() + self.assertFalse(cov.config.timid) + self.assertFalse(cov.config.branch) + + def test_arguments(self): + # Arguments to the constructor are applied to the configuation. + cov = coverage.coverage(timid=True) + self.assert_(cov.config.timid) + self.assertFalse(cov.config.branch) + + def test_config_file(self): + # A .coveragerc file will be read into the configuration. + self.make_file(".coveragerc", """\ + [run] + timid = True + """) + cov = coverage.coverage() + self.assert_(cov.config.timid) + self.assertFalse(cov.config.branch) + + def test_named_config_file(self): + # You can name the config file what you like. + self.make_file("my_cov.ini", """\ + [run] + timid = True + """) + cov = coverage.coverage(config_file="my_cov.ini") + self.assert_(cov.config.timid) + self.assertFalse(cov.config.branch) + + def test_ignored_config_file(self): + # You can disable reading the .coveragerc file. + self.make_file(".coveragerc", """\ + [run] + timid = True + """) + cov = coverage.coverage(config_file=False) + self.assertFalse(cov.config.timid) + self.assertFalse(cov.config.branch) + + def test_config_file_then_args(self): + # The arguments override the .coveragerc file. + self.make_file(".coveragerc", """\ + [run] + timid = True + """) + cov = coverage.coverage(timid=False) + self.assertFalse(cov.config.timid) + self.assertFalse(cov.config.branch) |
