summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/config.py4
-rw-r--r--lab/cmd-opts.txt10
-rw-r--r--test/test_config.py31
3 files changed, 41 insertions, 4 deletions
diff --git a/coverage/config.py b/coverage/config.py
index 0955347..89fd789 100644
--- a/coverage/config.py
+++ b/coverage/config.py
@@ -51,9 +51,9 @@ class CoverageConfig(object):
self.cover_pylib = cp.getboolean('run', 'cover_pylib')
if cp.has_option('run', 'branch'):
self.branch = cp.getboolean('run', 'branch')
- if cp.has_option('report', 'exclude'):
+ if cp.has_option('report', 'exclude_lines'):
# Exclude is a list of lines, leave out the blank ones.
- exclude_list = cp.get('report', 'exclude')
+ exclude_list = cp.get('report', 'exclude_lines')
self.exclude_list = filter(None, exclude_list.split('\n'))
if cp.has_option('run', 'data_file'):
self.data_file = cp.get('run', 'data_file')
diff --git a/lab/cmd-opts.txt b/lab/cmd-opts.txt
index de35ecd..fed7b0f 100644
--- a/lab/cmd-opts.txt
+++ b/lab/cmd-opts.txt
@@ -45,6 +45,14 @@ commands:
-p --parallel bool
--timid bool [run].timid
+
+ --include=directory [run].include
+ --include=filename
+ --include=module
+ --exclude=directory [run].exclude
+
+
+
xml
-i --ignore-errors bool
--omit list of string
@@ -57,7 +65,7 @@ commands:
Other config:
- [report].exclude list of string
+ [report].exclude_lines list of string
[run].data_file string
diff --git a/test/test_config.py b/test/test_config.py
index 4272e8a..926de18 100644
--- a/test/test_config.py
+++ b/test/test_config.py
@@ -8,7 +8,7 @@ from coveragetest import CoverageTest
class ConfigTest(CoverageTest):
- """Tests of the config file support."""
+ """Tests of the different sources of configuration settings."""
def test_default_config(self):
# Just constructing a coverage() object gets the right defaults.
@@ -87,3 +87,32 @@ class ConfigTest(CoverageTest):
# But the constructor args override the env var.
cov = coverage.coverage(data_file="fromarg.dat")
self.assertEqual(cov.config.data_file, "fromarg.dat")
+
+
+class ConfigFileTest(CoverageTest):
+ """Tests of the config file settings in particular."""
+
+ def test_config_file_settings(self):
+ self.make_file(".coveragerc", """\
+ # This is a settings file for coverage.py
+ [run]
+ timid = yes
+ data_file = something_or_other.dat
+ branch = 0
+ cover_pylib = TRUE
+
+ [report]
+ ; these settings affect reporting.
+ exclude_lines =
+ if 0:
+ pragma:?\s+no cover
+ another_tab
+ """)
+ cov = coverage.coverage()
+ self.assertFalse(cov.config.branch)
+ self.assertTrue(cov.config.timid)
+ self.assertTrue(cov.config.cover_pylib)
+ self.assertEqual(cov.config.data_file, "something_or_other.dat")
+ self.assertEqual(cov.get_exclude_list(),
+ ["if 0:", "pragma:?\s+no cover", "another_tab"]
+ )