From 730d8106d1bc8a25b37689a0305df2ccc00a3427 Mon Sep 17 00:00:00 2001 From: Lucas Carvalho Date: Wed, 17 Nov 2021 15:55:33 -0300 Subject: [PATCH] Apply black to new code --- Makefile | 2 +- dojo_toolkit/__main__.py | 41 +++++++++++++++++++------------------ dojo_toolkit/test_runner.py | 16 +++++++-------- tests/test_test_runner.py | 20 +++++++----------- 4 files changed, 37 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index 0171451..f8d82ba 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ install: format: install poetry run black . - poetry run isort -rc . + poetry run isort . lint: install poetry run flake8 dojo_toolkit tests --max-line-length 100 diff --git a/dojo_toolkit/__main__.py b/dojo_toolkit/__main__.py index 1c92b17..91805ed 100644 --- a/dojo_toolkit/__main__.py +++ b/dojo_toolkit/__main__.py @@ -9,32 +9,33 @@ def parse_args(): build argument parser """ parser = ArgumentParser() - parser.add_argument("-t", "--time", - help="the amount of time a dojo round lasts", - default=Dojo.ROUND_TIME, - type=float) - parser.add_argument("path", - help="the path to the folder containing the code used during the dojo", - nargs="?", - default=".", - type=os.path.realpath) - parser.add_argument("--mute", - help="mute all sounds (default: all sounds are played)", - action='store_true') - parser.add_argument("--runner", - help="name of the runner (default: doctest)", - default="doctest", - type=str) + parser.add_argument( + "-t", + "--time", + help="the amount of time a dojo round lasts", + default=Dojo.ROUND_TIME, + type=float, + ) + parser.add_argument( + "path", + help="the path to the folder containing the code used during the dojo", + nargs="?", + default=".", + type=os.path.realpath, + ) + parser.add_argument( + "--mute", help="mute all sounds (default: all sounds are played)", action="store_true" + ) + parser.add_argument( + "--runner", help="name of the runner (default: doctest)", default="doctest", type=str + ) return parser.parse_args() def main(): args = parse_args() - dojo = Dojo(code_path=args.path, - round_time=args.time, - mute=args.mute, - runner=args.runner) + dojo = Dojo(code_path=args.path, round_time=args.time, mute=args.mute, runner=args.runner) dojo.start() diff --git a/dojo_toolkit/test_runner.py b/dojo_toolkit/test_runner.py index 53a01fe..6e3a37f 100644 --- a/dojo_toolkit/test_runner.py +++ b/dojo_toolkit/test_runner.py @@ -46,8 +46,8 @@ def _handle_success(self): self.sound_player.play_success() def _handle_failure(self): - print('\nTests failed!\n') - notifier.fail('NOT OK TO TALK') + print("\nTests failed!\n") + notifier.fail("NOT OK TO TALK") class DoctestTestRunner(LocalTestRunner): @@ -56,12 +56,12 @@ def _run_doctest(self): ["python -m doctest " + self.code_path + "/*.py"], capture_output=True, shell=True, - encoding="utf-8" + encoding="utf-8", ) return { - 'is_success': result.returncode == 0, - 'output': result.stdout, + "is_success": result.returncode == 0, + "output": result.stdout, } @@ -71,10 +71,10 @@ def _run_doctest(self): ["python -m pytest " + self.code_path + "/*.py"], capture_output=True, shell=True, - encoding="utf-8" + encoding="utf-8", ) return { - 'is_success': result.returncode == 0, - 'output': result.stdout, + "is_success": result.returncode == 0, + "output": result.stdout, } diff --git a/tests/test_test_runner.py b/tests/test_test_runner.py index 39053d5..aa67755 100644 --- a/tests/test_test_runner.py +++ b/tests/test_test_runner.py @@ -106,23 +106,17 @@ def test_docstringfy(): assert docstringfy(code) == '"""\n>>> 1 + 2\n3\n"""' -@pytest.mark.parametrize("runner,test_runner", - [("doctest", DoctestTestRunner), - ("pytest", PytestTestRunner)]) +@pytest.mark.parametrize( + "runner,test_runner", [("doctest", DoctestTestRunner), ("pytest", PytestTestRunner)] +) def test_get_test_runner(runner, test_runner, code_file): - test_runner_got = get_test_runner(None, - runner, - code_path=str(code_file.dirpath()), - sound_player=None - ) + test_runner_got = get_test_runner( + None, runner, code_path=str(code_file.dirpath()), sound_player=None + ) assert isinstance(test_runner_got, test_runner) def test_get_test_runner_invalid_runner(code_file): with pytest.raises(NotImplementedError): - get_test_runner(None, - "", - code_path=str(code_file.dirpath()), - sound_player=None - ) + get_test_runner(None, "", code_path=str(code_file.dirpath()), sound_player=None)