blob: 4206fa9884267b636b79cac638f7797cbfa3cfe3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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)
|