Skip to content

Commit 7fdaa08

Browse files
Update minimum Python version to 3.9 in the configuration (#137)
1 parent e2540af commit 7fdaa08

File tree

2 files changed

+77
-59
lines changed

2 files changed

+77
-59
lines changed

cherry_picker/test_cherry_picker.py

+76-57
Original file line numberDiff line numberDiff line change
@@ -665,13 +665,15 @@ def test_get_updated_commit_message_with_trailers(
665665
with mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True):
666666
cherry_picker = CherryPicker("origin", commit, [])
667667

668-
with mock.patch(
669-
"cherry_picker.cherry_picker.validate_sha", return_value=True
670-
), mock.patch.object(
671-
cherry_picker, "get_commit_message", return_value=commit_message
672-
), mock.patch(
673-
"cherry_picker.cherry_picker.get_author_info_from_short_sha",
674-
return_value="PR Author <[email protected]>",
668+
with (
669+
mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True),
670+
mock.patch.object(
671+
cherry_picker, "get_commit_message", return_value=commit_message
672+
),
673+
mock.patch(
674+
"cherry_picker.cherry_picker.get_author_info_from_short_sha",
675+
return_value="PR Author <[email protected]>",
676+
),
675677
):
676678
updated_commit_message = cherry_picker.get_updated_commit_message(
677679
cherry_pick_branch
@@ -914,9 +916,10 @@ class tested_state:
914916
r"stored in Git config using the following command: "
915917
r"`git config --local --remove-section cherry-picker`"
916918
)
917-
with mock.patch(
918-
"cherry_picker.cherry_picker.validate_sha", return_value=True
919-
), pytest.raises(InvalidRepoException, match=expected_msg_regexp):
919+
with (
920+
mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True),
921+
pytest.raises(InvalidRepoException, match=expected_msg_regexp),
922+
):
920923
CherryPicker("origin", "xxx", [])
921924

922925

@@ -932,9 +935,11 @@ def test_push_to_remote_interactive(tmp_git_repo_dir):
932935
with mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True):
933936
cherry_picker = CherryPicker("origin", "xxx", [])
934937

935-
with mock.patch.object(cherry_picker, "run_cmd"), mock.patch.object(
936-
cherry_picker, "open_pr"
937-
), mock.patch.object(cherry_picker, "get_pr_url", return_value="https://pr_url"):
938+
with (
939+
mock.patch.object(cherry_picker, "run_cmd"),
940+
mock.patch.object(cherry_picker, "open_pr"),
941+
mock.patch.object(cherry_picker, "get_pr_url", return_value="https://pr_url"),
942+
):
938943
cherry_picker.push_to_remote("main", "backport-branch-test")
939944
assert get_state() == WORKFLOW_STATES.PR_OPENING
940945

@@ -944,8 +949,9 @@ def test_push_to_remote_botflow(tmp_git_repo_dir, monkeypatch):
944949
with mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True):
945950
cherry_picker = CherryPicker("origin", "xxx", [])
946951

947-
with mock.patch.object(cherry_picker, "run_cmd"), mock.patch.object(
948-
cherry_picker, "create_gh_pr"
952+
with (
953+
mock.patch.object(cherry_picker, "run_cmd"),
954+
mock.patch.object(cherry_picker, "create_gh_pr"),
949955
):
950956
cherry_picker.push_to_remote("main", "backport-branch-test")
951957
assert get_state() == WORKFLOW_STATES.PR_CREATING
@@ -956,8 +962,9 @@ def test_push_to_remote_no_auto_pr(tmp_git_repo_dir, monkeypatch):
956962
with mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True):
957963
cherry_picker = CherryPicker("origin", "xxx", [], auto_pr=False)
958964

959-
with mock.patch.object(cherry_picker, "run_cmd"), mock.patch.object(
960-
cherry_picker, "create_gh_pr"
965+
with (
966+
mock.patch.object(cherry_picker, "run_cmd"),
967+
mock.patch.object(cherry_picker, "create_gh_pr"),
961968
):
962969
cherry_picker.push_to_remote("main", "backport-branch-test")
963970
assert get_state() == WORKFLOW_STATES.PUSHED_TO_REMOTE
@@ -995,10 +1002,13 @@ def test_backport_cherry_pick_fail(
9951002
pr_remote, scm_revision, cherry_pick_target_branches
9961003
)
9971004

998-
with pytest.raises(CherryPickException), mock.patch.object(
999-
cherry_picker, "checkout_branch"
1000-
), mock.patch.object(cherry_picker, "fetch_upstream"), mock.patch.object(
1001-
cherry_picker, "cherry_pick", side_effect=CherryPickException
1005+
with (
1006+
pytest.raises(CherryPickException),
1007+
mock.patch.object(cherry_picker, "checkout_branch"),
1008+
mock.patch.object(cherry_picker, "fetch_upstream"),
1009+
mock.patch.object(
1010+
cherry_picker, "cherry_pick", side_effect=CherryPickException
1011+
),
10021012
):
10031013
cherry_picker.backport()
10041014

@@ -1027,13 +1037,16 @@ def test_backport_cherry_pick_crash_ignored(
10271037
pr_remote, scm_revision, cherry_pick_target_branches
10281038
)
10291039

1030-
with mock.patch.object(cherry_picker, "checkout_branch"), mock.patch.object(
1031-
cherry_picker, "fetch_upstream"
1032-
), mock.patch.object(cherry_picker, "cherry_pick"), mock.patch.object(
1033-
cherry_picker,
1034-
"amend_commit_message",
1035-
side_effect=subprocess.CalledProcessError(
1036-
1, ("git", "commit", "-am", "new commit message")
1040+
with (
1041+
mock.patch.object(cherry_picker, "checkout_branch"),
1042+
mock.patch.object(cherry_picker, "fetch_upstream"),
1043+
mock.patch.object(cherry_picker, "cherry_pick"),
1044+
mock.patch.object(
1045+
cherry_picker,
1046+
"amend_commit_message",
1047+
side_effect=subprocess.CalledProcessError(
1048+
1, ("git", "commit", "-am", "new commit message")
1049+
),
10371050
),
10381051
):
10391052
cherry_picker.backport()
@@ -1067,9 +1080,10 @@ def test_backport_cherry_pick_branch_already_exists(
10671080
)
10681081
git_branch(backport_branch_name)
10691082

1070-
with mock.patch.object(cherry_picker, "fetch_upstream"), pytest.raises(
1071-
BranchCheckoutException
1072-
) as exc_info:
1083+
with (
1084+
mock.patch.object(cherry_picker, "fetch_upstream"),
1085+
pytest.raises(BranchCheckoutException) as exc_info,
1086+
):
10731087
cherry_picker.backport()
10741088

10751089
assert exc_info.value.branch_name == backport_branch_name
@@ -1098,10 +1112,12 @@ def test_backport_success(
10981112
pr_remote, scm_revision, cherry_pick_target_branches
10991113
)
11001114

1101-
with mock.patch.object(cherry_picker, "checkout_branch"), mock.patch.object(
1102-
cherry_picker, "fetch_upstream"
1103-
), mock.patch.object(
1104-
cherry_picker, "amend_commit_message", return_value="commit message"
1115+
with (
1116+
mock.patch.object(cherry_picker, "checkout_branch"),
1117+
mock.patch.object(cherry_picker, "fetch_upstream"),
1118+
mock.patch.object(
1119+
cherry_picker, "amend_commit_message", return_value="commit message"
1120+
),
11051121
):
11061122
cherry_picker.backport()
11071123

@@ -1141,8 +1157,11 @@ def test_backport_pause_and_continue(
11411157
pr_remote, scm_revision, cherry_pick_target_branches, push=False
11421158
)
11431159

1144-
with mock.patch.object(cherry_picker, "fetch_upstream"), mock.patch.object(
1145-
cherry_picker, "amend_commit_message", return_value="commit message"
1160+
with (
1161+
mock.patch.object(cherry_picker, "fetch_upstream"),
1162+
mock.patch.object(
1163+
cherry_picker, "amend_commit_message", return_value="commit message"
1164+
),
11461165
):
11471166
cherry_picker.backport()
11481167

@@ -1164,26 +1183,26 @@ def test_backport_pause_and_continue(
11641183
11651184
Co-authored-by: Author Name <[email protected]>"""
11661185

1167-
with mock.patch(
1168-
"cherry_picker.cherry_picker.wipe_cfg_vals_from_git_cfg"
1169-
), mock.patch(
1170-
"cherry_picker.cherry_picker.get_full_sha_from_short",
1171-
return_value="xxxxxxyyyyyy",
1172-
), mock.patch(
1173-
"cherry_picker.cherry_picker.get_base_branch", return_value="3.8"
1174-
), mock.patch(
1175-
"cherry_picker.cherry_picker.get_current_branch",
1176-
return_value="backport-xxx-3.8",
1177-
), mock.patch.object(
1178-
cherry_picker, "amend_commit_message", return_value=commit_message
1179-
) as amend_commit_message, mock.patch.object(
1180-
cherry_picker, "get_updated_commit_message", return_value=commit_message
1181-
) as get_updated_commit_message, mock.patch.object(
1182-
cherry_picker, "checkout_branch"
1183-
), mock.patch.object(
1184-
cherry_picker, "fetch_upstream"
1185-
), mock.patch.object(
1186-
cherry_picker, "cleanup_branch"
1186+
with (
1187+
mock.patch("cherry_picker.cherry_picker.wipe_cfg_vals_from_git_cfg"),
1188+
mock.patch(
1189+
"cherry_picker.cherry_picker.get_full_sha_from_short",
1190+
return_value="xxxxxxyyyyyy",
1191+
),
1192+
mock.patch("cherry_picker.cherry_picker.get_base_branch", return_value="3.8"),
1193+
mock.patch(
1194+
"cherry_picker.cherry_picker.get_current_branch",
1195+
return_value="backport-xxx-3.8",
1196+
),
1197+
mock.patch.object(
1198+
cherry_picker, "amend_commit_message", return_value=commit_message
1199+
) as amend_commit_message,
1200+
mock.patch.object(
1201+
cherry_picker, "get_updated_commit_message", return_value=commit_message
1202+
) as get_updated_commit_message,
1203+
mock.patch.object(cherry_picker, "checkout_branch"),
1204+
mock.patch.object(cherry_picker, "fetch_upstream"),
1205+
mock.patch.object(cherry_picker, "cleanup_branch"),
11871206
):
11881207
cherry_picker.continue_cherry_pick()
11891208

pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ name = "cherry-picker"
1010
readme = "README.md"
1111
maintainers = [ { name = "Python Core Developers", email = "[email protected]" } ]
1212
authors = [ { name = "Mariatta Wijaya", email = "[email protected]" } ]
13-
requires-python = ">=3.8"
13+
requires-python = ">=3.9"
1414
classifiers = [
1515
"Intended Audience :: Developers",
1616
"License :: OSI Approved :: Apache Software License",
1717
"Programming Language :: Python :: 3 :: Only",
18-
"Programming Language :: Python :: 3.8",
1918
"Programming Language :: Python :: 3.9",
2019
"Programming Language :: Python :: 3.10",
2120
"Programming Language :: Python :: 3.11",

0 commit comments

Comments
 (0)