Skip to content

Commit 8e2abe9

Browse files
saygoxLee-W
authored andcommitted
refactor(commands/commit): change valiable by comment and use black
1 parent 581233b commit 8e2abe9

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

commitizen/commands/commit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ def __call__(self):
194194
raise DryRunExit()
195195

196196
if commit_msg_file:
197-
defaultmesaage = ""
197+
default_message = ""
198198
with open(commit_msg_file) as f:
199-
defaultmesaage = f.read()
199+
default_message = f.read()
200200
with open(commit_msg_file, "w") as f:
201201
f.write(m)
202-
f.write(defaultmesaage)
202+
f.write(default_message)
203203
out.success("Commit message is successful!")
204204
return
205205

tests/commands/test_commit_command.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -554,44 +554,42 @@ def test_commit_from_pre_commit_msg_hook(config, mocker, capsys):
554554
assert "Commit message is successful!" in out
555555
commit_mock.assert_not_called()
556556

557+
557558
def test_WrapStdx(mocker):
558559
mocker.patch("os.open")
559560
reader_mock = mocker.mock_open(read_data="data")
560561
mocker.patch("builtins.open", reader_mock, create=True)
561562

562-
stdin_mock_fileno=mocker.patch.object(sys.stdin, 'fileno')
563+
stdin_mock_fileno = mocker.patch.object(sys.stdin, "fileno")
563564
stdin_mock_fileno.return_value = 0
564565
wrap_stdin = commands.commit.WrapStdx(sys.stdin)
565566

566567
assert wrap_stdin.encoding == "UTF-8"
567568
assert wrap_stdin.read() == "data"
568569

569-
570570
writer_mock = mocker.mock_open(read_data="data")
571571
mocker.patch("builtins.open", writer_mock, create=True)
572-
stdout_mock_fileno=mocker.patch.object(sys.stdout, 'fileno')
572+
stdout_mock_fileno = mocker.patch.object(sys.stdout, "fileno")
573573
stdout_mock_fileno.return_value = 1
574574
wrap_stout = commands.commit.WrapStdx(sys.stdout)
575575
wrap_stout.write("data")
576576

577-
if sys.platform == 'linux':
578-
writer_mock.assert_called_once_with("/dev/tty", 'w')
577+
if sys.platform == "linux":
578+
writer_mock.assert_called_once_with("/dev/tty", "w")
579579
else:
580580
pass
581581
writer_mock().write.assert_called_once_with("data")
582582

583-
584583
writer_mock = mocker.mock_open(read_data="data")
585584
mocker.patch("builtins.open", writer_mock, create=True)
586-
stderr_mock_fileno=mocker.patch.object(sys.stdout, 'fileno')
585+
stderr_mock_fileno = mocker.patch.object(sys.stdout, "fileno")
587586
stderr_mock_fileno.return_value = 2
588587
wrap_sterr = commands.commit.WrapStdx(sys.stderr)
589588

590-
591589
wrap_sterr.write("data")
592590

593-
if sys.platform == 'linux':
594-
writer_mock.assert_called_once_with("/dev/tty", 'w')
591+
if sys.platform == "linux":
592+
writer_mock.assert_called_once_with("/dev/tty", "w")
595593
else:
596594
pass
597595
writer_mock().write.assert_called_once_with("data")

0 commit comments

Comments
 (0)