Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9c7ea88 commit 8d34f95Copy full SHA for 8d34f95
1 file changed
tests/main_test.py
@@ -1,6 +1,7 @@
1
from __future__ import annotations
2
3
import argparse
4
+import contextlib
5
import os.path
6
from unittest import mock
7
@@ -97,11 +98,9 @@ def test_adjust_args_try_repo_repo_relative(in_git_dir):
97
98
99
@pytest.fixture
100
def mock_commands():
- mcks = {fn: mock.patch.object(main, fn).start() for fn in FNS}
101
- ret = auto_namedtuple(**mcks)
102
- yield ret
103
- for mck in ret:
104
- mck.stop()
+ with contextlib.ExitStack() as ctx:
+ mcks = {f: ctx.enter_context(mock.patch.object(main, f)) for f in FNS}
+ yield auto_namedtuple(**mcks)
105
106
107
0 commit comments