Skip to content

Commit 6b302ad

Browse files
authored
Rename test.py to test_cherry_picker.py for pytest (#56)
* Rename test.py to test_cherry_picker.py for pytest [Pytest conventions for test discover](https://docs.pytest.org/en/6.2.x/goodpractices.html#test-discovery) do not _discover_ `test.py` but find `test_*.py`. ;-) * pytest.ini: Allow pytest to discover testpaths * Black, isort, pyupgrade and remove pytest
1 parent be40569 commit 6b302ad

File tree

4 files changed

+39
-35
lines changed

4 files changed

+39
-35
lines changed

.github/workflows/lint_python.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@ jobs:
88
- uses: actions/setup-python@v2
99
- run: pip install --upgrade pip wheel
1010
- run: pip install bandit black codespell flake8 flake8-bugbear
11-
flake8-comprehensions isort mypy pytest pyupgrade safety
11+
flake8-comprehensions isort mypy pyupgrade safety
1212
- run: bandit --recursive --skip B101,B404,B603 .
13-
- run: black --check . || true
13+
- run: black --diff .
1414
- run: codespell --ignore-words-list="commitish"
1515
- run: flake8 . --count --ignore=C408,E203,F841,W503 --max-complexity=10
1616
--max-line-length=143 --show-source --statistics
17-
- run: isort --check-only --profile black . || true
18-
- run: pip install -r requirements.txt || pip install --editable . || true
19-
- run: mkdir --parents --verbose .mypy_cache
17+
- run: isort --check-only --profile black .
18+
- run: pip install --editable .
2019
- run: mypy --ignore-missing-imports --install-types --non-interactive .
21-
- run: pytest . || true
22-
- run: pytest --doctest-modules . || true
2320
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
2421
- run: safety check

cherry_picker/cherry_picker.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

4-
import click
53
import collections
64
import enum
75
import os
8-
import subprocess
9-
import webbrowser
106
import re
7+
import subprocess
118
import sys
9+
import webbrowser
10+
11+
import click
1212
import requests
1313
import toml
14-
1514
from gidgethub import sansio
1615

1716
from . import __version__
@@ -167,7 +166,7 @@ def get_pr_url(self, base_branch, head_branch):
167166
return f"https://github.com/{self.config['team']}/{self.config['repo']}/compare/{base_branch}...{self.username}:{head_branch}?expand=1"
168167

169168
def fetch_upstream(self):
170-
""" git fetch <upstream> """
169+
"""git fetch <upstream>"""
171170
set_state(WORKFLOW_STATES.FETCHING_UPSTREAM)
172171
cmd = ["git", "fetch", self.upstream, "--no-tags"]
173172
self.run_cmd(cmd)
@@ -182,7 +181,7 @@ def run_cmd(self, cmd):
182181
return output.decode("utf-8")
183182

184183
def checkout_branch(self, branch_name):
185-
""" git checkout -b <branch_name> """
184+
"""git checkout -b <branch_name>"""
186185
cmd = [
187186
"git",
188187
"checkout",
@@ -219,7 +218,7 @@ def get_commit_message(self, commit_sha):
219218
return message
220219

221220
def checkout_default_branch(self):
222-
""" git checkout default branch """
221+
"""git checkout default branch"""
223222
set_state(WORKFLOW_STATES.CHECKING_OUT_DEFAULT_BRANCH)
224223

225224
cmd = "git", "checkout", self.config["default_branch"]
@@ -236,7 +235,7 @@ def status(self):
236235
return self.run_cmd(cmd)
237236

238237
def cherry_pick(self):
239-
""" git cherry-pick -x <commit_sha1> """
238+
"""git cherry-pick -x <commit_sha1>"""
240239
cmd = ["git", "cherry-pick", "-x", self.commit_sha1]
241240
try:
242241
click.echo(self.run_cmd(cmd))
@@ -261,7 +260,7 @@ def get_exit_message(self, branch):
261260
"""
262261

263262
def amend_commit_message(self, cherry_pick_branch):
264-
""" prefix the commit message with (X.Y) """
263+
"""prefix the commit message with (X.Y)"""
265264

266265
commit_prefix = ""
267266
if self.prefix_commit:
@@ -283,7 +282,7 @@ def amend_commit_message(self, cherry_pick_branch):
283282
return updated_commit_message
284283

285284
def push_to_remote(self, base_branch, head_branch, commit_message=""):
286-
""" git push <origin> <branchname> """
285+
"""git push <origin> <branchname>"""
287286
set_state(WORKFLOW_STATES.PUSHING_TO_REMOTE)
288287

289288
cmd = ["git", "push"]
@@ -607,7 +606,16 @@ class state:
607606
@click.argument("branches", nargs=-1)
608607
@click.pass_context
609608
def cherry_pick_cli(
610-
ctx, dry_run, pr_remote, abort, status, push, auto_pr, config_path, commit_sha1, branches
609+
ctx,
610+
dry_run,
611+
pr_remote,
612+
abort,
613+
status,
614+
push,
615+
auto_pr,
616+
config_path,
617+
commit_sha1,
618+
branches,
611619
):
612620
"""cherry-pick COMMIT_SHA1 into target BRANCHES."""
613621

cherry_picker/test.py renamed to cherry_picker/test_cherry_picker.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@
44
from collections import ChainMap
55
from unittest import mock
66

7-
import pytest
87
import click
8+
import pytest
99

1010
from .cherry_picker import (
11-
get_base_branch,
12-
get_current_branch,
13-
get_full_sha_from_short,
14-
get_author_info_from_short_sha,
11+
DEFAULT_CONFIG,
12+
WORKFLOW_STATES,
1513
CherryPicker,
16-
InvalidRepoException,
1714
CherryPickException,
18-
normalize_commit_message,
19-
DEFAULT_CONFIG,
20-
get_sha1_from,
15+
InvalidRepoException,
2116
find_config,
22-
load_config,
23-
validate_sha,
2417
from_git_rev_read,
25-
reset_state,
26-
set_state,
18+
get_author_info_from_short_sha,
19+
get_base_branch,
20+
get_current_branch,
21+
get_full_sha_from_short,
22+
get_sha1_from,
2723
get_state,
24+
load_config,
2825
load_val_from_git_cfg,
26+
normalize_commit_message,
27+
reset_state,
2928
reset_stored_config_ref,
30-
WORKFLOW_STATES,
29+
set_state,
30+
validate_sha,
3131
)
3232

3333

@@ -945,4 +945,4 @@ def test_abort_cherry_pick_success(
945945

946946

947947
def test_cli_invoked():
948-
subprocess.check_call('cherry_picker --help'.split())
948+
subprocess.check_call("cherry_picker --help".split())

pytest.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ filterwarnings =
55
error
66
junit_duration_report = call
77
junit_suite_name = cherry_picker_test_suite
8-
testpaths = cherry_picker/test.py

0 commit comments

Comments
 (0)