Skip to content

Commit bc6bb6f

Browse files
committed
Add test
1 parent 2cfd2f8 commit bc6bb6f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

cherry_picker/test.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ def git_init():
5656
return lambda: subprocess.run(git_init_cmd, check=True)
5757

5858

59+
@pytest.fixture
60+
def git_remote():
61+
git_remote_cmd = "git", "remote"
62+
return lambda *extra_args: (subprocess.run(git_remote_cmd + extra_args, check=True))
63+
64+
5965
@pytest.fixture
6066
def git_add():
6167
git_add_cmd = "git", "add"
@@ -217,6 +223,27 @@ def test_get_cherry_pick_branch(os_path_exists, config):
217223
assert cp.get_cherry_pick_branch("3.6") == "backport-22a594a-3.6"
218224

219225

226+
@pytest.mark.parametrize("remote_name", ("upstream", "origin", "python"))
227+
def test_upstream_name(remote_name, config, tmp_git_repo_dir, git_remote):
228+
upstream_remote = None
229+
if remote_name == "python":
230+
upstream_remote = "python"
231+
git_remote("add", remote_name, "https://github.com/python/cpython.git")
232+
if remote_name != "origin":
233+
git_remote("add", "origin", "https://github.com/miss-islington/cpython.git")
234+
235+
branches = ["3.6"]
236+
with mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True):
237+
cp = CherryPicker(
238+
"origin",
239+
"22a594a0047d7706537ff2ac676cdc0f1dcb329c",
240+
branches,
241+
config=config,
242+
upstream_remote=upstream_remote,
243+
)
244+
assert cp.upstream == remote_name
245+
246+
220247
def test_get_pr_url(config):
221248
branches = ["3.6"]
222249

0 commit comments

Comments
 (0)