mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 00:54:42 +04:00
Replace deprecated yield_fixture with fixture
Committed via https://github.com/asottile/all-repos
This commit is contained in:
parent
98ec74dcab
commit
0f54fedac9
6 changed files with 28 additions and 28 deletions
|
|
@ -25,7 +25,7 @@ from testing.fixtures import write_config
|
||||||
from testing.util import get_resource_path
|
from testing.util import get_resource_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def up_to_date_repo(tempdir_factory):
|
def up_to_date_repo(tempdir_factory):
|
||||||
yield make_repo(tempdir_factory, 'python_hooks_repo')
|
yield make_repo(tempdir_factory, 'python_hooks_repo')
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ def test_autoupdate_old_revision_broken(
|
||||||
assert update_rev in after
|
assert update_rev in after
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def out_of_date_repo(tempdir_factory):
|
def out_of_date_repo(tempdir_factory):
|
||||||
path = make_repo(tempdir_factory, 'python_hooks_repo')
|
path = make_repo(tempdir_factory, 'python_hooks_repo')
|
||||||
original_sha = git.head_sha(path)
|
original_sha = git.head_sha(path)
|
||||||
|
|
@ -221,7 +221,7 @@ def test_loses_formatting_when_not_detectable(
|
||||||
assert after == expected
|
assert after == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def tagged_repo(out_of_date_repo):
|
def tagged_repo(out_of_date_repo):
|
||||||
with cwd(out_of_date_repo.path):
|
with cwd(out_of_date_repo.path):
|
||||||
cmd_output('git', 'tag', 'v1.2.3')
|
cmd_output('git', 'tag', 'v1.2.3')
|
||||||
|
|
@ -241,7 +241,7 @@ def test_autoupdate_tagged_repo(
|
||||||
assert 'v1.2.3' in open(C.CONFIG_FILE).read()
|
assert 'v1.2.3' in open(C.CONFIG_FILE).read()
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def tagged_repo_with_more_commits(tagged_repo):
|
def tagged_repo_with_more_commits(tagged_repo):
|
||||||
with cwd(tagged_repo.path):
|
with cwd(tagged_repo.path):
|
||||||
cmd_output('git', 'commit', '--allow-empty', '-m', 'commit!')
|
cmd_output('git', 'commit', '--allow-empty', '-m', 'commit!')
|
||||||
|
|
@ -262,7 +262,7 @@ def test_autoupdate_tags_only(
|
||||||
assert 'v1.2.3' in open(C.CONFIG_FILE).read()
|
assert 'v1.2.3' in open(C.CONFIG_FILE).read()
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def hook_disappearing_repo(tempdir_factory):
|
def hook_disappearing_repo(tempdir_factory):
|
||||||
path = make_repo(tempdir_factory, 'python_hooks_repo')
|
path = make_repo(tempdir_factory, 'python_hooks_repo')
|
||||||
original_sha = git.head_sha(path)
|
original_sha = git.head_sha(path)
|
||||||
|
|
|
||||||
|
|
@ -29,14 +29,14 @@ from testing.util import run_opts
|
||||||
from testing.util import xfailif_no_symlink
|
from testing.util import xfailif_no_symlink
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def repo_with_passing_hook(tempdir_factory):
|
def repo_with_passing_hook(tempdir_factory):
|
||||||
git_path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
|
git_path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
|
||||||
with cwd(git_path):
|
with cwd(git_path):
|
||||||
yield git_path
|
yield git_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def repo_with_failing_hook(tempdir_factory):
|
def repo_with_failing_hook(tempdir_factory):
|
||||||
git_path = make_consuming_repo(tempdir_factory, 'failing_hook_repo')
|
git_path = make_consuming_repo(tempdir_factory, 'failing_hook_repo')
|
||||||
with cwd(git_path):
|
with cwd(git_path):
|
||||||
|
|
@ -699,7 +699,7 @@ def test_meta_hook_passes(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def modified_config_repo(repo_with_passing_hook):
|
def modified_config_repo(repo_with_passing_hook):
|
||||||
with modify_config(repo_with_passing_hook, commit=False) as config:
|
with modify_config(repo_with_passing_hook, commit=False) as config:
|
||||||
# Some minor modification
|
# Some minor modification
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ from testing.fixtures import make_consuming_repo
|
||||||
from testing.fixtures import write_config
|
from testing.fixtures import write_config
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def tempdir_factory(tmpdir):
|
def tempdir_factory(tmpdir):
|
||||||
class TmpdirFactory(object):
|
class TmpdirFactory(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
@ -38,7 +38,7 @@ def tempdir_factory(tmpdir):
|
||||||
yield TmpdirFactory()
|
yield TmpdirFactory()
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def in_tmpdir(tempdir_factory):
|
def in_tmpdir(tempdir_factory):
|
||||||
path = tempdir_factory.get()
|
path = tempdir_factory.get()
|
||||||
with cwd(path):
|
with cwd(path):
|
||||||
|
|
@ -65,7 +65,7 @@ def _make_conflict():
|
||||||
cmd_output('git', 'merge', 'foo', retcode=None)
|
cmd_output('git', 'merge', 'foo', retcode=None)
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def in_merge_conflict(tempdir_factory):
|
def in_merge_conflict(tempdir_factory):
|
||||||
path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
|
path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
|
||||||
with cwd(path):
|
with cwd(path):
|
||||||
|
|
@ -80,7 +80,7 @@ def in_merge_conflict(tempdir_factory):
|
||||||
yield os.path.join(conflict_path)
|
yield os.path.join(conflict_path)
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def in_conflicting_submodule(tempdir_factory):
|
def in_conflicting_submodule(tempdir_factory):
|
||||||
git_dir_1 = git_dir(tempdir_factory)
|
git_dir_1 = git_dir(tempdir_factory)
|
||||||
git_dir_2 = git_dir(tempdir_factory)
|
git_dir_2 = git_dir(tempdir_factory)
|
||||||
|
|
@ -116,7 +116,7 @@ def commit_msg_repo(tempdir_factory):
|
||||||
yield path
|
yield path
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture(autouse=True, scope='session')
|
@pytest.fixture(autouse=True, scope='session')
|
||||||
def dont_write_to_home_directory():
|
def dont_write_to_home_directory():
|
||||||
"""pre_commit.store.Store will by default write to the home directory
|
"""pre_commit.store.Store will by default write to the home directory
|
||||||
We'll mock out `Store.get_default_directory` to raise invariantly so we
|
We'll mock out `Store.get_default_directory` to raise invariantly so we
|
||||||
|
|
@ -138,7 +138,7 @@ def configure_logging():
|
||||||
add_logging_handler(use_color=False)
|
add_logging_handler(use_color=False)
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def mock_out_store_directory(tempdir_factory):
|
def mock_out_store_directory(tempdir_factory):
|
||||||
tmpdir = tempdir_factory.get()
|
tmpdir = tempdir_factory.get()
|
||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
|
|
@ -149,23 +149,23 @@ def mock_out_store_directory(tempdir_factory):
|
||||||
yield tmpdir
|
yield tmpdir
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def store(tempdir_factory):
|
def store(tempdir_factory):
|
||||||
yield Store(os.path.join(tempdir_factory.get(), '.pre-commit'))
|
yield Store(os.path.join(tempdir_factory.get(), '.pre-commit'))
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def runner_with_mocked_store(mock_out_store_directory):
|
def runner_with_mocked_store(mock_out_store_directory):
|
||||||
yield Runner('/', C.CONFIG_FILE)
|
yield Runner('/', C.CONFIG_FILE)
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def log_info_mock():
|
def log_info_mock():
|
||||||
with mock.patch.object(logging.getLogger('pre_commit'), 'info') as mck:
|
with mock.patch.object(logging.getLogger('pre_commit'), 'info') as mck:
|
||||||
yield mck
|
yield mck
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def log_warning_mock():
|
def log_warning_mock():
|
||||||
with mock.patch.object(logging.getLogger('pre_commit'), 'warning') as mck:
|
with mock.patch.object(logging.getLogger('pre_commit'), 'warning') as mck:
|
||||||
yield mck
|
yield mck
|
||||||
|
|
@ -197,7 +197,7 @@ class Fixture(object):
|
||||||
return self.get_bytes().decode('UTF-8')
|
return self.get_bytes().decode('UTF-8')
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def cap_out():
|
def cap_out():
|
||||||
stream = FakeStream()
|
stream = FakeStream()
|
||||||
write = functools.partial(output.write, stream=stream)
|
write = functools.partial(output.write, stream=stream)
|
||||||
|
|
@ -207,7 +207,7 @@ def cap_out():
|
||||||
yield Fixture(stream)
|
yield Fixture(stream)
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def fake_log_handler():
|
def fake_log_handler():
|
||||||
handler = mock.Mock(level=logging.INFO)
|
handler = mock.Mock(level=logging.INFO)
|
||||||
logger = logging.getLogger('pre_commit')
|
logger = logging.getLogger('pre_commit')
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ from pre_commit import error_handler
|
||||||
from testing.util import cmd_output_mocked_pre_commit_home
|
from testing.util import cmd_output_mocked_pre_commit_home
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def mocked_log_and_exit():
|
def mocked_log_and_exit():
|
||||||
with mock.patch.object(error_handler, '_log_and_exit') as log_and_exit:
|
with mock.patch.object(error_handler, '_log_and_exit') as log_and_exit:
|
||||||
yield log_and_exit
|
yield log_and_exit
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ FNS = (
|
||||||
CMDS = tuple(fn.replace('_', '-') for fn in FNS)
|
CMDS = tuple(fn.replace('_', '-') for fn in FNS)
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def mock_commands():
|
def mock_commands():
|
||||||
mcks = {fn: mock.patch.object(main, fn).start() for fn in FNS}
|
mcks = {fn: mock.patch.object(main, fn).start() for fn in FNS}
|
||||||
ret = auto_namedtuple(**mcks)
|
ret = auto_namedtuple(**mcks)
|
||||||
|
|
@ -32,7 +32,7 @@ class CalledExit(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def argparse_exit_mock():
|
def argparse_exit_mock():
|
||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
argparse.ArgumentParser, 'exit', side_effect=CalledExit,
|
argparse.ArgumentParser, 'exit', side_effect=CalledExit,
|
||||||
|
|
@ -40,7 +40,7 @@ def argparse_exit_mock():
|
||||||
yield exit_mock
|
yield exit_mock
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def argparse_parse_args_spy():
|
def argparse_parse_args_spy():
|
||||||
parse_args_mock = mock.Mock()
|
parse_args_mock = mock.Mock()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ def get_short_git_status():
|
||||||
return dict(reversed(line.split()) for line in git_status.splitlines())
|
return dict(reversed(line.split()) for line in git_status.splitlines())
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def foo_staged(tempdir_factory):
|
def foo_staged(tempdir_factory):
|
||||||
path = git_dir(tempdir_factory)
|
path = git_dir(tempdir_factory)
|
||||||
with cwd(path):
|
with cwd(path):
|
||||||
|
|
@ -132,7 +132,7 @@ def test_foo_both_modify_conflicting(foo_staged, patch_dir):
|
||||||
_test_foo_state(foo_staged, FOO_CONTENTS.replace('1', 'a'), 'AM')
|
_test_foo_state(foo_staged, FOO_CONTENTS.replace('1', 'a'), 'AM')
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def img_staged(tempdir_factory):
|
def img_staged(tempdir_factory):
|
||||||
path = git_dir(tempdir_factory)
|
path = git_dir(tempdir_factory)
|
||||||
with cwd(path):
|
with cwd(path):
|
||||||
|
|
@ -187,7 +187,7 @@ def test_img_conflict(img_staged, patch_dir):
|
||||||
_test_img_state(img_staged, 'img2.jpg', 'AM')
|
_test_img_state(img_staged, 'img2.jpg', 'AM')
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def submodule_with_commits(tempdir_factory):
|
def submodule_with_commits(tempdir_factory):
|
||||||
path = git_dir(tempdir_factory)
|
path = git_dir(tempdir_factory)
|
||||||
with cwd(path):
|
with cwd(path):
|
||||||
|
|
@ -203,7 +203,7 @@ def checkout_submodule(sha):
|
||||||
cmd_output('git', 'checkout', sha)
|
cmd_output('git', 'checkout', sha)
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.fixture
|
||||||
def sub_staged(submodule_with_commits, tempdir_factory):
|
def sub_staged(submodule_with_commits, tempdir_factory):
|
||||||
path = git_dir(tempdir_factory)
|
path = git_dir(tempdir_factory)
|
||||||
with cwd(path):
|
with cwd(path):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue