Skip to content

Commit 96e2998

Browse files
authored
Merge pull request #2196 from mgorny/called-once
Fix assertions in `test_git_hook`
2 parents 0118e90 + abfb91f commit 96e2998

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/unit/test_hooks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_git_hook(src_dir):
1111
# Ensure correct subprocess command is called
1212
with patch("subprocess.run", MagicMock()) as run_mock:
1313
hooks.git_hook()
14-
assert run_mock.called_once()
14+
run_mock.assert_called_once()
1515
assert run_mock.call_args[0][0] == [
1616
"git",
1717
"diff-index",
@@ -21,8 +21,9 @@ def test_git_hook(src_dir):
2121
"HEAD",
2222
]
2323

24+
with patch("subprocess.run", MagicMock()) as run_mock:
2425
hooks.git_hook(lazy=True)
25-
assert run_mock.called_once()
26+
run_mock.assert_called_once()
2627
assert run_mock.call_args[0][0] == [
2728
"git",
2829
"diff-index",

0 commit comments

Comments
 (0)