Add a test for environment config file

This commit is contained in:
Pradyun S. Gedam 2017-05-15 19:17:36 +05:30
parent ac2e6e5610
commit 94d752e399
1 changed files with 16 additions and 0 deletions

View File

@ -2,6 +2,8 @@
"""
import os
import tempfile
import textwrap
from mock import MagicMock
from pip.locations import venv_config_file, new_config_file, site_config_files
@ -27,6 +29,20 @@ class TestConfigurationLoading(ConfigurationPatchingMixin):
self.configuration.load()
assert self.configuration.get_value("test.hello") == "3"
def test_environment_config_loading(self):
contents = textwrap.dedent("""\
[test]
hello = 4
""")
_, config_file = tempfile.mkstemp('-pip.cfg', 'test-')
os.environ["PIP_CONFIG_FILE"] = config_file
with open(config_file, "w") as f:
f.write(contents)
self.configuration.load()
assert self.configuration.get_value("test.hello") == "4"
class TestConfigurationPrecedence(ConfigurationPatchingMixin):
# Tests for methods to that determine the order of precedence of