2018-10-27 12:23:01 +02:00
|
|
|
"""
|
|
|
|
Contains functional tests of the Mercurial class.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
from pip._vendor.six.moves import configparser
|
|
|
|
|
2019-08-21 12:22:57 +02:00
|
|
|
from pip._internal.utils.misc import hide_url
|
2018-10-27 12:23:01 +02:00
|
|
|
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)
|
2018-11-08 08:30:16 +01:00
|
|
|
|
2018-10-27 12:23:01 +02:00
|
|
|
config = configparser.RawConfigParser()
|
|
|
|
config.add_section('paths')
|
|
|
|
config.set('paths', 'default', 'old_url')
|
2018-11-08 08:30:16 +01:00
|
|
|
|
2018-10-27 12:23:01 +02:00
|
|
|
hgrc_path = os.path.join(hg_dir, 'hgrc')
|
|
|
|
with open(hgrc_path, 'w') as f:
|
|
|
|
config.write(f)
|
2019-08-21 12:22:57 +02:00
|
|
|
hg.switch(tmpdir, hide_url('new_url'), options)
|
2019-05-04 22:17:09 +02:00
|
|
|
|
2018-10-27 12:23:01 +02:00
|
|
|
config.read(hgrc_path)
|
2018-11-08 08:30:16 +01:00
|
|
|
|
2018-10-27 12:23:01 +02:00
|
|
|
default_path = config.get('paths', 'default')
|
|
|
|
assert default_path == 'new_url'
|