Esempio n. 1
0
def test_get_repository_root(script):
    version_pkg_path = _create_test_package(script, vcs="hg")
    tests_path = version_pkg_path.joinpath("tests")
    tests_path.mkdir()

    root1 = Mercurial.get_repository_root(version_pkg_path)
    assert os.path.normcase(root1) == os.path.normcase(version_pkg_path)

    root2 = Mercurial.get_repository_root(version_pkg_path.joinpath("tests"))
    assert os.path.normcase(root2) == os.path.normcase(version_pkg_path)
Esempio n. 2
0
def test_get_repository_root(script: PipTestEnvironment) -> None:
    version_pkg_path = _create_test_package(script, vcs="hg")
    tests_path = version_pkg_path.joinpath("tests")
    tests_path.mkdir()

    root1 = Mercurial.get_repository_root(version_pkg_path)
    assert root1 is not None
    assert os.path.normcase(root1) == os.path.normcase(version_pkg_path)

    root2 = Mercurial.get_repository_root(version_pkg_path.joinpath("tests"))
    assert root2 is not None
    assert os.path.normcase(root2) == os.path.normcase(version_pkg_path)
Esempio n. 3
0
def test_mercurial_switch_updates_config_file_when_found(tmpdir: Path) -> None:
    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(os.fspath(tmpdir), hide_url("new_url"), options)

    config.read(hgrc_path)

    default_path = config.get("paths", "default")
    assert default_path == "new_url"
Esempio n. 4
0
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, hide_url('new_url'), options)

    config.read(hgrc_path)

    default_path = config.get('paths', 'default')
    assert default_path == 'new_url'
Esempio n. 5
0
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'
Esempio n. 6
0
if pyversion >= '3':
    VERBOSE_FALSE = False
else:
    VERBOSE_FALSE = 0


def test_rev_options_repr():
    rev_options = RevOptions(Git(), 'develop')
    assert repr(rev_options) == "<RevOptions git: rev='develop'>"


@pytest.mark.parametrize(('vcs', 'expected1', 'expected2', 'kwargs'), [
    # First check VCS-specific RevOptions behavior.
    (Bazaar(), [], ['-r', '123'], {}),
    (Git(), ['HEAD'], ['123'], {}),
    (Mercurial(), [], ['123'], {}),
    (Subversion(), [], ['-r', '123'], {}),
    # Test extra_args.  For this, test using a single VersionControl class.
    (Git(), ['HEAD', 'opt1', 'opt2'], ['123', 'opt1', 'opt2'],
        dict(extra_args=['opt1', 'opt2'])),
])
def test_rev_options_to_args(vcs, expected1, expected2, kwargs):
    """
    Test RevOptions.to_args().
    """
    assert RevOptions(vcs, **kwargs).to_args() == expected1
    assert RevOptions(vcs, '123', **kwargs).to_args() == expected2


def test_rev_options_to_display():
    """