Skip to content

Commit

Permalink
refactor(tests): Rename parentdir -> repos_path
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Mar 12, 2022
1 parent 206e1fb commit 96d2ada
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def user_path(home_path: pathlib.Path):


@pytest.fixture(scope="function")
def parentdir(user_path: pathlib.Path, request: pytest.FixtureRequest):
def repos_path(user_path: pathlib.Path, request: pytest.FixtureRequest):
"""Return temporary directory for repository checkout guaranteed unique."""
dir = user_path / "repos"
dir.mkdir(exist_ok=True)
Expand All @@ -35,12 +35,12 @@ def clean():


@pytest.fixture
def pip_url_kwargs(parentdir: pathlib.Path, git_remote: pathlib.Path):
def pip_url_kwargs(repos_path: pathlib.Path, git_remote: pathlib.Path):
"""Return kwargs for :func:`create_repo_from_pip_url`."""
repo_name = "repo_clone"
return {
"pip_url": f"git+file://{git_remote}",
"repo_dir": parentdir / repo_name,
"repo_dir": repos_path / repo_name,
}


Expand All @@ -53,12 +53,12 @@ def git_repo(pip_url_kwargs: Dict):


@pytest.fixture
def git_remote(parentdir: pathlib.Path):
def git_remote(repos_path: pathlib.Path):
"""Create a git repo with 1 commit, used as a remote."""
name = "dummyrepo"
repo_dir = parentdir / name
repo_dir = repos_path / name

run(["git", "init", name], cwd=parentdir)
run(["git", "init", name], cwd=repos_path)

testfile_filename = "testfile.test"

Expand Down
6 changes: 3 additions & 3 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def test_repr_base():


def test_ensure_dir_creates_parent_if_not_exist(tmp_path: pathlib.Path):
parentdir = tmp_path / "parentdir" # doesn't exist yet
repo_dir = parentdir / "myrepo"
repos_path = tmp_path / "repos_path" # doesn't exist yet
repo_dir = repos_path / "myrepo"
repo = BaseRepo(url="file://path/to/myrepo", repo_dir=repo_dir)

repo.ensure_dir()
assert parentdir.is_dir()
assert repos_path.is_dir()


def test_convert_pip_url():
Expand Down
8 changes: 4 additions & 4 deletions tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ def progress_callback_spy(output, timestamp):
assert progress_callback.called


def test_remotes(parentdir, git_remote):
def test_remotes(repos_path, git_remote):
repo_name = "myrepo"
remote_name = "myremote"
remote_url = "https://localhost/my/git/repo.git"

git_repo = create_repo_from_pip_url(
pip_url=f"git+file://{git_remote}",
repo_dir=parentdir / repo_name,
repo_dir=repos_path / repo_name,
)
git_repo.obtain()
git_repo.set_remote(name=remote_name, url=remote_url)
Expand Down Expand Up @@ -160,10 +160,10 @@ def test_git_get_url_and_rev_from_pip_url():
assert rev == "eucalyptus"


def test_remotes_preserves_git_ssh(parentdir, git_remote):
def test_remotes_preserves_git_ssh(repos_path, git_remote):
# Regression test for #14
repo_name = "myexamplegit"
repo_dir = parentdir / repo_name
repo_dir = repos_path / repo_name
remote_name = "myremote"
remote_url = "git+ssh://[email protected]/tony/AlgoXY.git"

Expand Down
12 changes: 6 additions & 6 deletions tests/test_hg.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ def hgrc_default(monkeypatch: pytest.MonkeyPatch, user_path: pathlib.Path):


@pytest.fixture
def hg_remote(parentdir):
def hg_remote(repos_path):
"""Create a git repo with 1 commit, used as a remote."""
name = "test_hg_repo"
repo_path = parentdir / name
repo_path = repos_path / name

run(["hg", "init", name], cwd=parentdir)
run(["hg", "init", name], cwd=repos_path)

testfile_filename = "testfile.test"

Expand All @@ -53,13 +53,13 @@ def hg_remote(parentdir):
return repo_path


def test_repo_mercurial(tmp_path: pathlib.Path, parentdir, hg_remote):
def test_repo_mercurial(tmp_path: pathlib.Path, repos_path, hg_remote):
repo_name = "my_mercurial_project"

mercurial_repo = create_repo_from_pip_url(
**{
"pip_url": f"hg+file://{hg_remote}",
"repo_dir": parentdir / repo_name,
"repo_dir": repos_path / repo_name,
}
)

Expand All @@ -68,7 +68,7 @@ def test_repo_mercurial(tmp_path: pathlib.Path, parentdir, hg_remote):
mercurial_repo.update_repo()

test_repo_revision = run(
["hg", "parents", "--template={rev}"], cwd=parentdir / repo_name
["hg", "parents", "--template={rev}"], cwd=repos_path / repo_name
)

assert mercurial_repo.get_revision() == test_repo_revision
4 changes: 2 additions & 2 deletions tests/test_svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@


@pytest.fixture
def svn_remote(parentdir, scope="session"):
def svn_remote(repos_path, scope="session"):
"""Create a git repo with 1 commit, used as a remote."""
server_dirname = "server_dir"
server_dir = parentdir / server_dirname
server_dir = repos_path / server_dirname

run(["svnadmin", "create", server_dir])

Expand Down

0 comments on commit 96d2ada

Please sign in to comment.