Skip to content

Commit

Permalink
Apply black to new code
Browse files Browse the repository at this point in the history
  • Loading branch information
zsinx6 committed Nov 17, 2021
1 parent 011befd commit 730d810
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 21 additions & 20 deletions dojo_toolkit/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
16 changes: 8 additions & 8 deletions dojo_toolkit/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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,
}


Expand All @@ -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,
}
20 changes: 7 additions & 13 deletions tests/test_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 730d810

Please sign in to comment.