Skip to content

Commit 0f54fed

Browse files
committed
Replace deprecated yield_fixture with fixture
Committed via https://github.com/asottile/all-repos
1 parent 98ec74d commit 0f54fed

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

tests/commands/autoupdate_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from testing.util import get_resource_path
2626

2727

28-
@pytest.yield_fixture
28+
@pytest.fixture
2929
def up_to_date_repo(tempdir_factory):
3030
yield make_repo(tempdir_factory, 'python_hooks_repo')
3131

@@ -81,7 +81,7 @@ def test_autoupdate_old_revision_broken(
8181
assert update_rev in after
8282

8383

84-
@pytest.yield_fixture
84+
@pytest.fixture
8585
def out_of_date_repo(tempdir_factory):
8686
path = make_repo(tempdir_factory, 'python_hooks_repo')
8787
original_sha = git.head_sha(path)
@@ -221,7 +221,7 @@ def test_loses_formatting_when_not_detectable(
221221
assert after == expected
222222

223223

224-
@pytest.yield_fixture
224+
@pytest.fixture
225225
def tagged_repo(out_of_date_repo):
226226
with cwd(out_of_date_repo.path):
227227
cmd_output('git', 'tag', 'v1.2.3')
@@ -241,7 +241,7 @@ def test_autoupdate_tagged_repo(
241241
assert 'v1.2.3' in open(C.CONFIG_FILE).read()
242242

243243

244-
@pytest.yield_fixture
244+
@pytest.fixture
245245
def tagged_repo_with_more_commits(tagged_repo):
246246
with cwd(tagged_repo.path):
247247
cmd_output('git', 'commit', '--allow-empty', '-m', 'commit!')
@@ -262,7 +262,7 @@ def test_autoupdate_tags_only(
262262
assert 'v1.2.3' in open(C.CONFIG_FILE).read()
263263

264264

265-
@pytest.yield_fixture
265+
@pytest.fixture
266266
def hook_disappearing_repo(tempdir_factory):
267267
path = make_repo(tempdir_factory, 'python_hooks_repo')
268268
original_sha = git.head_sha(path)

tests/commands/run_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
from testing.util import xfailif_no_symlink
3030

3131

32-
@pytest.yield_fixture
32+
@pytest.fixture
3333
def repo_with_passing_hook(tempdir_factory):
3434
git_path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
3535
with cwd(git_path):
3636
yield git_path
3737

3838

39-
@pytest.yield_fixture
39+
@pytest.fixture
4040
def repo_with_failing_hook(tempdir_factory):
4141
git_path = make_consuming_repo(tempdir_factory, 'failing_hook_repo')
4242
with cwd(git_path):
@@ -699,7 +699,7 @@ def test_meta_hook_passes(
699699
)
700700

701701

702-
@pytest.yield_fixture
702+
@pytest.fixture
703703
def modified_config_repo(repo_with_passing_hook):
704704
with modify_config(repo_with_passing_hook, commit=False) as config:
705705
# Some minor modification

tests/conftest.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from testing.fixtures import write_config
2424

2525

26-
@pytest.yield_fixture
26+
@pytest.fixture
2727
def tempdir_factory(tmpdir):
2828
class TmpdirFactory(object):
2929
def __init__(self):
@@ -38,7 +38,7 @@ def get(self):
3838
yield TmpdirFactory()
3939

4040

41-
@pytest.yield_fixture
41+
@pytest.fixture
4242
def in_tmpdir(tempdir_factory):
4343
path = tempdir_factory.get()
4444
with cwd(path):
@@ -65,7 +65,7 @@ def _make_conflict():
6565
cmd_output('git', 'merge', 'foo', retcode=None)
6666

6767

68-
@pytest.yield_fixture
68+
@pytest.fixture
6969
def in_merge_conflict(tempdir_factory):
7070
path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
7171
with cwd(path):
@@ -80,7 +80,7 @@ def in_merge_conflict(tempdir_factory):
8080
yield os.path.join(conflict_path)
8181

8282

83-
@pytest.yield_fixture
83+
@pytest.fixture
8484
def in_conflicting_submodule(tempdir_factory):
8585
git_dir_1 = git_dir(tempdir_factory)
8686
git_dir_2 = git_dir(tempdir_factory)
@@ -116,7 +116,7 @@ def commit_msg_repo(tempdir_factory):
116116
yield path
117117

118118

119-
@pytest.yield_fixture(autouse=True, scope='session')
119+
@pytest.fixture(autouse=True, scope='session')
120120
def dont_write_to_home_directory():
121121
"""pre_commit.store.Store will by default write to the home directory
122122
We'll mock out `Store.get_default_directory` to raise invariantly so we
@@ -138,7 +138,7 @@ def configure_logging():
138138
add_logging_handler(use_color=False)
139139

140140

141-
@pytest.yield_fixture
141+
@pytest.fixture
142142
def mock_out_store_directory(tempdir_factory):
143143
tmpdir = tempdir_factory.get()
144144
with mock.patch.object(
@@ -149,23 +149,23 @@ def mock_out_store_directory(tempdir_factory):
149149
yield tmpdir
150150

151151

152-
@pytest.yield_fixture
152+
@pytest.fixture
153153
def store(tempdir_factory):
154154
yield Store(os.path.join(tempdir_factory.get(), '.pre-commit'))
155155

156156

157-
@pytest.yield_fixture
157+
@pytest.fixture
158158
def runner_with_mocked_store(mock_out_store_directory):
159159
yield Runner('/', C.CONFIG_FILE)
160160

161161

162-
@pytest.yield_fixture
162+
@pytest.fixture
163163
def log_info_mock():
164164
with mock.patch.object(logging.getLogger('pre_commit'), 'info') as mck:
165165
yield mck
166166

167167

168-
@pytest.yield_fixture
168+
@pytest.fixture
169169
def log_warning_mock():
170170
with mock.patch.object(logging.getLogger('pre_commit'), 'warning') as mck:
171171
yield mck
@@ -197,7 +197,7 @@ def get(self):
197197
return self.get_bytes().decode('UTF-8')
198198

199199

200-
@pytest.yield_fixture
200+
@pytest.fixture
201201
def cap_out():
202202
stream = FakeStream()
203203
write = functools.partial(output.write, stream=stream)
@@ -207,7 +207,7 @@ def cap_out():
207207
yield Fixture(stream)
208208

209209

210-
@pytest.yield_fixture
210+
@pytest.fixture
211211
def fake_log_handler():
212212
handler = mock.Mock(level=logging.INFO)
213213
logger = logging.getLogger('pre_commit')

tests/error_handler_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from testing.util import cmd_output_mocked_pre_commit_home
1515

1616

17-
@pytest.yield_fixture
17+
@pytest.fixture
1818
def mocked_log_and_exit():
1919
with mock.patch.object(error_handler, '_log_and_exit') as log_and_exit:
2020
yield log_and_exit

tests/main_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
CMDS = tuple(fn.replace('_', '-') for fn in FNS)
2020

2121

22-
@pytest.yield_fixture
22+
@pytest.fixture
2323
def mock_commands():
2424
mcks = {fn: mock.patch.object(main, fn).start() for fn in FNS}
2525
ret = auto_namedtuple(**mcks)
@@ -32,15 +32,15 @@ class CalledExit(Exception):
3232
pass
3333

3434

35-
@pytest.yield_fixture
35+
@pytest.fixture
3636
def argparse_exit_mock():
3737
with mock.patch.object(
3838
argparse.ArgumentParser, 'exit', side_effect=CalledExit,
3939
) as exit_mock:
4040
yield exit_mock
4141

4242

43-
@pytest.yield_fixture
43+
@pytest.fixture
4444
def argparse_parse_args_spy():
4545
parse_args_mock = mock.Mock()
4646

tests/staged_files_only_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def get_short_git_status():
3030
return dict(reversed(line.split()) for line in git_status.splitlines())
3131

3232

33-
@pytest.yield_fixture
33+
@pytest.fixture
3434
def foo_staged(tempdir_factory):
3535
path = git_dir(tempdir_factory)
3636
with cwd(path):
@@ -132,7 +132,7 @@ def test_foo_both_modify_conflicting(foo_staged, patch_dir):
132132
_test_foo_state(foo_staged, FOO_CONTENTS.replace('1', 'a'), 'AM')
133133

134134

135-
@pytest.yield_fixture
135+
@pytest.fixture
136136
def img_staged(tempdir_factory):
137137
path = git_dir(tempdir_factory)
138138
with cwd(path):
@@ -187,7 +187,7 @@ def test_img_conflict(img_staged, patch_dir):
187187
_test_img_state(img_staged, 'img2.jpg', 'AM')
188188

189189

190-
@pytest.yield_fixture
190+
@pytest.fixture
191191
def submodule_with_commits(tempdir_factory):
192192
path = git_dir(tempdir_factory)
193193
with cwd(path):
@@ -203,7 +203,7 @@ def checkout_submodule(sha):
203203
cmd_output('git', 'checkout', sha)
204204

205205

206-
@pytest.yield_fixture
206+
@pytest.fixture
207207
def sub_staged(submodule_with_commits, tempdir_factory):
208208
path = git_dir(tempdir_factory)
209209
with cwd(path):

0 commit comments

Comments
 (0)