@@ -196,6 +196,7 @@ def test_sorted_branch(os_path_exists, config, input_branches, sorted_branches):
196
196
],
197
197
)
198
198
@mock .patch ("os.path.exists" )
199
+ @mock .patch ("cherry_picker.cherry_picker.validate_sha" )
199
200
def test_invalid_branches (os_path_exists , config , input_branches ):
200
201
os_path_exists .return_value = True
201
202
cp = CherryPicker (
@@ -209,6 +210,7 @@ def test_invalid_branches(os_path_exists, config, input_branches):
209
210
210
211
211
212
@mock .patch ("os.path.exists" )
213
+ @mock .patch ("cherry_picker.cherry_picker.validate_sha" )
212
214
def test_get_cherry_pick_branch (os_path_exists , config ):
213
215
os_path_exists .return_value = True
214
216
branches = ["3.6" ]
@@ -220,21 +222,23 @@ def test_get_cherry_pick_branch(os_path_exists, config):
220
222
221
223
def test_get_pr_url (config ):
222
224
branches = ["3.6" ]
223
- cp = CherryPicker (
224
- "origin" , "22a594a0047d7706537ff2ac676cdc0f1dcb329c" , branches , config = config
225
- )
226
- backport_target_branch = cp .get_cherry_pick_branch ("3.6" )
227
- expected_pr_url = (
228
- "https://github.com/python/cpython/compare/"
229
- "3.6...mock_user:backport-22a594a-3.6?expand=1"
230
- )
231
- with mock .patch (
232
- "subprocess.check_output" ,
233
- return_value = b"https://github.com/mock_user/cpython.git" ,
234
- ):
235
- actual_pr_url = cp .get_pr_url ("3.6" , backport_target_branch )
225
+ with mock .patch ("cherry_picker.cherry_picker.validate_sha" ):
226
+
227
+ cp = CherryPicker (
228
+ "origin" , "22a594a0047d7706537ff2ac676cdc0f1dcb329c" , branches , config = config
229
+ )
230
+ backport_target_branch = cp .get_cherry_pick_branch ("3.6" )
231
+ expected_pr_url = (
232
+ "https://github.com/python/cpython/compare/"
233
+ "3.6...mock_user:backport-22a594a-3.6?expand=1"
234
+ )
235
+ with mock .patch (
236
+ "subprocess.check_output" ,
237
+ return_value = b"https://github.com/mock_user/cpython.git" ,
238
+ ):
239
+ actual_pr_url = cp .get_pr_url ("3.6" , backport_target_branch )
236
240
237
- assert actual_pr_url == expected_pr_url
241
+ assert actual_pr_url == expected_pr_url
238
242
239
243
240
244
@pytest .mark .parametrize (
@@ -250,13 +254,15 @@ def test_get_pr_url(config):
250
254
)
251
255
def test_username (url , config ):
252
256
branches = ["3.6" ]
253
- cp = CherryPicker (
254
- "origin" , "22a594a0047d7706537ff2ac676cdc0f1dcb329c" , branches , config = config
255
- )
256
- with mock .patch ("subprocess.check_output" , return_value = url ):
257
- assert cp .username == "mock_user"
257
+ with mock .patch ("cherry_picker.cherry_picker.validate_sha" ):
258
+ cp = CherryPicker (
259
+ "origin" , "22a594a0047d7706537ff2ac676cdc0f1dcb329c" , branches , config = config
260
+ )
261
+ with mock .patch ("subprocess.check_output" , return_value = url ):
262
+ assert cp .username == "mock_user"
258
263
259
264
265
+ @mock .patch ("cherry_picker.cherry_picker.validate_sha" )
260
266
def test_get_updated_commit_message (config ):
261
267
branches = ["3.6" ]
262
268
cp = CherryPicker (
@@ -274,15 +280,16 @@ def test_get_updated_commit_message(config):
274
280
def test_get_updated_commit_message_without_links_replacement (config ):
275
281
config ["fix_commit_msg" ] = False
276
282
branches = ["3.6" ]
277
- cp = CherryPicker (
278
- "origin" , "22a594a0047d7706537ff2ac676cdc0f1dcb329c" , branches , config = config
279
- )
280
- with mock .patch (
281
- "subprocess.check_output" , return_value = b"bpo-123: Fix Spam Module (#113)"
282
- ):
283
- actual_commit_message = cp .get_commit_message (
284
- "22a594a0047d7706537ff2ac676cdc0f1dcb329c"
283
+ with mock .patch ("cherry_picker.cherry_picker.validate_sha" ):
284
+ cp = CherryPicker (
285
+ "origin" , "22a594a0047d7706537ff2ac676cdc0f1dcb329c" , branches , config = config
285
286
)
287
+ with mock .patch (
288
+ "subprocess.check_output" , return_value = b"bpo-123: Fix Spam Module (#113)"
289
+ ):
290
+ actual_commit_message = cp .get_commit_message (
291
+ "22a594a0047d7706537ff2ac676cdc0f1dcb329c"
292
+ )
286
293
assert actual_commit_message == "bpo-123: Fix Spam Module (#113)"
287
294
288
295
0 commit comments