remove last user of SafeConfigParser

Fixes #5059
This commit is contained in:
Riccardo Magliocchetti 2018-10-27 12:23:01 +02:00
parent ebfa66361e
commit 376abc0655
3 changed files with 29 additions and 1 deletions

0
news/5059.trivial Normal file
View File

View File

@ -45,7 +45,7 @@ class Mercurial(VersionControl):
def switch(self, dest, url, rev_options):
repo_config = os.path.join(dest, self.dirname, 'hgrc')
config = configparser.SafeConfigParser()
config = configparser.RawConfigParser()
try:
config.read(repo_config)
config.set('paths', 'default', url)

View File

@ -0,0 +1,28 @@
"""
Contains functional tests of the Mercurial class.
"""
import os
from pip._vendor.six.moves import configparser
from pip._internal.vcs.mercurial import Mercurial
from tests.lib import need_mercurial
@need_mercurial
def test_mercurial_switch_updates_config_file_when_found(tmpdir):
hg = Mercurial()
options = hg.make_rev_options()
hg_dir = os.path.join(tmpdir, '.hg')
os.mkdir(hg_dir)
config = configparser.RawConfigParser()
config.add_section('paths')
config.set('paths', 'default', 'old_url')
hgrc_path = os.path.join(hg_dir, 'hgrc')
with open(hgrc_path, 'w') as f:
config.write(f)
hg.switch(tmpdir, 'new_url', options)
config.read(hgrc_path)
default_path = config.get('paths', 'default')
assert default_path == 'new_url'