Skip to content

Commit

Permalink
Merge pull request #5931 from xrmx/fix5059
Browse files Browse the repository at this point in the history
Remove last use of SafeConfigParser
  • Loading branch information
pradyunsg authored May 7, 2019
2 parents a163ae5 + f6e525a commit 422d989
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
Empty file added news/5059.trivial
Empty file.
2 changes: 1 addition & 1 deletion src/pip/_internal/vcs/mercurial.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def fetch_new(cls, dest, url, rev_options):

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)
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/test_vcs_mercurial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
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'

0 comments on commit 422d989

Please sign in to comment.