@@ -56,6 +56,12 @@ def git_init():
56
56
return lambda : subprocess .run (git_init_cmd , check = True )
57
57
58
58
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
+
59
65
@pytest .fixture
60
66
def git_add ():
61
67
git_add_cmd = "git" , "add"
@@ -217,6 +223,27 @@ def test_get_cherry_pick_branch(os_path_exists, config):
217
223
assert cp .get_cherry_pick_branch ("3.6" ) == "backport-22a594a-3.6"
218
224
219
225
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
+
220
247
def test_get_pr_url (config ):
221
248
branches = ["3.6" ]
222
249
0 commit comments