mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Use in_git_dir in more places
This commit is contained in:
parent
2af0b0b4f3
commit
d46bbc486f
7 changed files with 88 additions and 143 deletions
|
|
@ -421,17 +421,14 @@ def test_replace_old_commit_script(tempdir_factory, store):
|
||||||
assert NORMAL_PRE_COMMIT_RUN.match(output)
|
assert NORMAL_PRE_COMMIT_RUN.match(output)
|
||||||
|
|
||||||
|
|
||||||
def test_uninstall_doesnt_remove_not_our_hooks(tempdir_factory):
|
def test_uninstall_doesnt_remove_not_our_hooks(in_git_dir):
|
||||||
path = git_dir(tempdir_factory)
|
pre_commit = in_git_dir.join('.git/hooks').ensure_dir().join('pre-commit')
|
||||||
with cwd(path):
|
pre_commit.write('#!/usr/bin/env bash\necho 1\n')
|
||||||
mkdirp(os.path.join(path, '.git/hooks'))
|
make_executable(pre_commit.strpath)
|
||||||
with io.open(os.path.join(path, '.git/hooks/pre-commit'), 'w') as f:
|
|
||||||
f.write('#!/usr/bin/env bash\necho 1\n')
|
|
||||||
make_executable(f.name)
|
|
||||||
|
|
||||||
assert uninstall() == 0
|
assert uninstall() == 0
|
||||||
|
|
||||||
assert os.path.exists(os.path.join(path, '.git/hooks/pre-commit'))
|
assert pre_commit.exists()
|
||||||
|
|
||||||
|
|
||||||
PRE_INSTALLED = re.compile(
|
PRE_INSTALLED = re.compile(
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,10 @@ def in_tmpdir(tempdir_factory):
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def in_git_dir(tmpdir):
|
def in_git_dir(tmpdir):
|
||||||
with tmpdir.as_cwd():
|
repo = tmpdir.join('repo').ensure_dir()
|
||||||
|
with repo.as_cwd():
|
||||||
cmd_output('git', 'init')
|
cmd_output('git', 'init')
|
||||||
yield tmpdir
|
yield repo
|
||||||
|
|
||||||
|
|
||||||
def _make_conflict():
|
def _make_conflict():
|
||||||
|
|
|
||||||
|
|
@ -9,45 +9,34 @@ import pytest
|
||||||
from pre_commit import git
|
from pre_commit import git
|
||||||
from pre_commit.error_handler import FatalError
|
from pre_commit.error_handler import FatalError
|
||||||
from pre_commit.util import cmd_output
|
from pre_commit.util import cmd_output
|
||||||
from testing.fixtures import git_dir
|
|
||||||
from testing.util import cwd
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_root_at_root(tempdir_factory):
|
def test_get_root_at_root(in_git_dir):
|
||||||
path = git_dir(tempdir_factory)
|
expected = os.path.normcase(in_git_dir.strpath)
|
||||||
with cwd(path):
|
assert os.path.normcase(git.get_root()) == expected
|
||||||
assert os.path.normcase(git.get_root()) == os.path.normcase(path)
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_root_deeper(tempdir_factory):
|
def test_get_root_deeper(in_git_dir):
|
||||||
path = git_dir(tempdir_factory)
|
expected = os.path.normcase(in_git_dir.strpath)
|
||||||
|
with in_git_dir.join('foo').ensure_dir().as_cwd():
|
||||||
foo_path = os.path.join(path, 'foo')
|
assert os.path.normcase(git.get_root()) == expected
|
||||||
os.mkdir(foo_path)
|
|
||||||
with cwd(foo_path):
|
|
||||||
assert os.path.normcase(git.get_root()) == os.path.normcase(path)
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_root_not_git_dir(tempdir_factory):
|
def test_get_root_not_git_dir(in_tmpdir):
|
||||||
with cwd(tempdir_factory.get()):
|
with pytest.raises(FatalError):
|
||||||
with pytest.raises(FatalError):
|
git.get_root()
|
||||||
git.get_root()
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_staged_files_deleted(tempdir_factory):
|
def test_get_staged_files_deleted(in_git_dir):
|
||||||
path = git_dir(tempdir_factory)
|
in_git_dir.join('test').ensure()
|
||||||
with cwd(path):
|
cmd_output('git', 'add', 'test')
|
||||||
open('test', 'a').close()
|
cmd_output('git', 'commit', '-m', 'foo', '--allow-empty')
|
||||||
cmd_output('git', 'add', 'test')
|
cmd_output('git', 'rm', '--cached', 'test')
|
||||||
cmd_output('git', 'commit', '-m', 'foo', '--allow-empty')
|
assert git.get_staged_files() == []
|
||||||
cmd_output('git', 'rm', '--cached', 'test')
|
|
||||||
assert git.get_staged_files() == []
|
|
||||||
|
|
||||||
|
|
||||||
def test_is_not_in_merge_conflict(tempdir_factory):
|
def test_is_not_in_merge_conflict(in_git_dir):
|
||||||
path = git_dir(tempdir_factory)
|
assert git.is_in_merge_conflict() is False
|
||||||
with cwd(path):
|
|
||||||
assert git.is_in_merge_conflict() is False
|
|
||||||
|
|
||||||
|
|
||||||
def test_is_in_merge_conflict(in_merge_conflict):
|
def test_is_in_merge_conflict(in_merge_conflict):
|
||||||
|
|
@ -114,11 +103,10 @@ def test_parse_merge_msg_for_conflicts(input, expected_output):
|
||||||
assert ret == expected_output
|
assert ret == expected_output
|
||||||
|
|
||||||
|
|
||||||
def test_get_changed_files(in_tmpdir):
|
def test_get_changed_files(in_git_dir):
|
||||||
cmd_output('git', 'init', '.')
|
|
||||||
cmd_output('git', 'commit', '--allow-empty', '-m', 'initial commit')
|
cmd_output('git', 'commit', '--allow-empty', '-m', 'initial commit')
|
||||||
open('a.txt', 'a').close()
|
in_git_dir.join('a.txt').ensure()
|
||||||
open('b.txt', 'a').close()
|
in_git_dir.join('b.txt').ensure()
|
||||||
cmd_output('git', 'add', '.')
|
cmd_output('git', 'add', '.')
|
||||||
cmd_output('git', 'commit', '-m', 'add some files')
|
cmd_output('git', 'commit', '-m', 'add some files')
|
||||||
files = git.get_changed_files('HEAD', 'HEAD^')
|
files = git.get_changed_files('HEAD', 'HEAD^')
|
||||||
|
|
@ -143,15 +131,12 @@ def test_zsplit(s, expected):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def non_ascii_repo(tmpdir):
|
def non_ascii_repo(in_git_dir):
|
||||||
repo = tmpdir.join('repo').ensure_dir()
|
cmd_output('git', 'commit', '--allow-empty', '-m', 'initial commit')
|
||||||
with repo.as_cwd():
|
in_git_dir.join('интервью').ensure()
|
||||||
cmd_output('git', 'init', '.')
|
cmd_output('git', 'add', '.')
|
||||||
cmd_output('git', 'commit', '--allow-empty', '-m', 'initial commit')
|
cmd_output('git', 'commit', '--allow-empty', '-m', 'initial commit')
|
||||||
repo.join('интервью').ensure()
|
yield in_git_dir
|
||||||
cmd_output('git', 'add', '.')
|
|
||||||
cmd_output('git', 'commit', '--allow-empty', '-m', 'initial commit')
|
|
||||||
yield repo
|
|
||||||
|
|
||||||
|
|
||||||
def test_all_files_non_ascii(non_ascii_repo):
|
def test_all_files_non_ascii(non_ascii_repo):
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
from pre_commit.meta_hooks import check_hooks_apply
|
from pre_commit.meta_hooks import check_hooks_apply
|
||||||
from testing.fixtures import add_config_to_repo
|
from testing.fixtures import add_config_to_repo
|
||||||
from testing.fixtures import git_dir
|
|
||||||
from testing.util import cwd
|
|
||||||
|
|
||||||
|
|
||||||
def test_hook_excludes_everything(capsys, tempdir_factory, mock_store_dir):
|
def test_hook_excludes_everything(capsys, in_git_dir, mock_store_dir):
|
||||||
config = {
|
config = {
|
||||||
'repos': [
|
'repos': [
|
||||||
{
|
{
|
||||||
|
|
@ -19,17 +17,15 @@ def test_hook_excludes_everything(capsys, tempdir_factory, mock_store_dir):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = git_dir(tempdir_factory)
|
add_config_to_repo(in_git_dir.strpath, config)
|
||||||
add_config_to_repo(repo, config)
|
|
||||||
|
|
||||||
with cwd(repo):
|
assert check_hooks_apply.main(()) == 1
|
||||||
assert check_hooks_apply.main(()) == 1
|
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert 'check-useless-excludes does not apply to this repository' in out
|
assert 'check-useless-excludes does not apply to this repository' in out
|
||||||
|
|
||||||
|
|
||||||
def test_hook_includes_nothing(capsys, tempdir_factory, mock_store_dir):
|
def test_hook_includes_nothing(capsys, in_git_dir, mock_store_dir):
|
||||||
config = {
|
config = {
|
||||||
'repos': [
|
'repos': [
|
||||||
{
|
{
|
||||||
|
|
@ -44,17 +40,15 @@ def test_hook_includes_nothing(capsys, tempdir_factory, mock_store_dir):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = git_dir(tempdir_factory)
|
add_config_to_repo(in_git_dir.strpath, config)
|
||||||
add_config_to_repo(repo, config)
|
|
||||||
|
|
||||||
with cwd(repo):
|
assert check_hooks_apply.main(()) == 1
|
||||||
assert check_hooks_apply.main(()) == 1
|
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert 'check-useless-excludes does not apply to this repository' in out
|
assert 'check-useless-excludes does not apply to this repository' in out
|
||||||
|
|
||||||
|
|
||||||
def test_hook_types_not_matched(capsys, tempdir_factory, mock_store_dir):
|
def test_hook_types_not_matched(capsys, in_git_dir, mock_store_dir):
|
||||||
config = {
|
config = {
|
||||||
'repos': [
|
'repos': [
|
||||||
{
|
{
|
||||||
|
|
@ -69,19 +63,15 @@ def test_hook_types_not_matched(capsys, tempdir_factory, mock_store_dir):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = git_dir(tempdir_factory)
|
add_config_to_repo(in_git_dir.strpath, config)
|
||||||
add_config_to_repo(repo, config)
|
|
||||||
|
|
||||||
with cwd(repo):
|
assert check_hooks_apply.main(()) == 1
|
||||||
assert check_hooks_apply.main(()) == 1
|
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert 'check-useless-excludes does not apply to this repository' in out
|
assert 'check-useless-excludes does not apply to this repository' in out
|
||||||
|
|
||||||
|
|
||||||
def test_hook_types_excludes_everything(
|
def test_hook_types_excludes_everything(capsys, in_git_dir, mock_store_dir):
|
||||||
capsys, tempdir_factory, mock_store_dir,
|
|
||||||
):
|
|
||||||
config = {
|
config = {
|
||||||
'repos': [
|
'repos': [
|
||||||
{
|
{
|
||||||
|
|
@ -96,17 +86,15 @@ def test_hook_types_excludes_everything(
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = git_dir(tempdir_factory)
|
add_config_to_repo(in_git_dir.strpath, config)
|
||||||
add_config_to_repo(repo, config)
|
|
||||||
|
|
||||||
with cwd(repo):
|
assert check_hooks_apply.main(()) == 1
|
||||||
assert check_hooks_apply.main(()) == 1
|
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert 'check-useless-excludes does not apply to this repository' in out
|
assert 'check-useless-excludes does not apply to this repository' in out
|
||||||
|
|
||||||
|
|
||||||
def test_valid_exceptions(capsys, tempdir_factory, mock_store_dir):
|
def test_valid_exceptions(capsys, in_git_dir, mock_store_dir):
|
||||||
config = {
|
config = {
|
||||||
'repos': [
|
'repos': [
|
||||||
{
|
{
|
||||||
|
|
@ -142,11 +130,9 @@ def test_valid_exceptions(capsys, tempdir_factory, mock_store_dir):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = git_dir(tempdir_factory)
|
add_config_to_repo(in_git_dir.strpath, config)
|
||||||
add_config_to_repo(repo, config)
|
|
||||||
|
|
||||||
with cwd(repo):
|
assert check_hooks_apply.main(()) == 0
|
||||||
assert check_hooks_apply.main(()) == 0
|
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert out == ''
|
assert out == ''
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
from pre_commit.meta_hooks import check_useless_excludes
|
from pre_commit.meta_hooks import check_useless_excludes
|
||||||
from testing.fixtures import add_config_to_repo
|
from testing.fixtures import add_config_to_repo
|
||||||
from testing.fixtures import git_dir
|
|
||||||
from testing.util import cwd
|
|
||||||
|
|
||||||
|
|
||||||
def test_useless_exclude_global(capsys, tempdir_factory):
|
def test_useless_exclude_global(capsys, in_git_dir):
|
||||||
config = {
|
config = {
|
||||||
'exclude': 'foo',
|
'exclude': 'foo',
|
||||||
'repos': [
|
'repos': [
|
||||||
|
|
@ -15,18 +13,16 @@ def test_useless_exclude_global(capsys, tempdir_factory):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = git_dir(tempdir_factory)
|
add_config_to_repo(in_git_dir.strpath, config)
|
||||||
add_config_to_repo(repo, config)
|
|
||||||
|
|
||||||
with cwd(repo):
|
assert check_useless_excludes.main(()) == 1
|
||||||
assert check_useless_excludes.main(()) == 1
|
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
out = out.strip()
|
out = out.strip()
|
||||||
assert "The global exclude pattern 'foo' does not match any files" == out
|
assert "The global exclude pattern 'foo' does not match any files" == out
|
||||||
|
|
||||||
|
|
||||||
def test_useless_exclude_for_hook(capsys, tempdir_factory):
|
def test_useless_exclude_for_hook(capsys, in_git_dir):
|
||||||
config = {
|
config = {
|
||||||
'repos': [
|
'repos': [
|
||||||
{
|
{
|
||||||
|
|
@ -36,11 +32,9 @@ def test_useless_exclude_for_hook(capsys, tempdir_factory):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = git_dir(tempdir_factory)
|
add_config_to_repo(in_git_dir.strpath, config)
|
||||||
add_config_to_repo(repo, config)
|
|
||||||
|
|
||||||
with cwd(repo):
|
assert check_useless_excludes.main(()) == 1
|
||||||
assert check_useless_excludes.main(()) == 1
|
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
out = out.strip()
|
out = out.strip()
|
||||||
|
|
@ -51,7 +45,7 @@ def test_useless_exclude_for_hook(capsys, tempdir_factory):
|
||||||
assert expected == out
|
assert expected == out
|
||||||
|
|
||||||
|
|
||||||
def test_useless_exclude_with_types_filter(capsys, tempdir_factory):
|
def test_useless_exclude_with_types_filter(capsys, in_git_dir):
|
||||||
config = {
|
config = {
|
||||||
'repos': [
|
'repos': [
|
||||||
{
|
{
|
||||||
|
|
@ -67,11 +61,9 @@ def test_useless_exclude_with_types_filter(capsys, tempdir_factory):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = git_dir(tempdir_factory)
|
add_config_to_repo(in_git_dir.strpath, config)
|
||||||
add_config_to_repo(repo, config)
|
|
||||||
|
|
||||||
with cwd(repo):
|
assert check_useless_excludes.main(()) == 1
|
||||||
assert check_useless_excludes.main(()) == 1
|
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
out = out.strip()
|
out = out.strip()
|
||||||
|
|
@ -82,7 +74,7 @@ def test_useless_exclude_with_types_filter(capsys, tempdir_factory):
|
||||||
assert expected == out
|
assert expected == out
|
||||||
|
|
||||||
|
|
||||||
def test_no_excludes(capsys, tempdir_factory):
|
def test_no_excludes(capsys, in_git_dir):
|
||||||
config = {
|
config = {
|
||||||
'repos': [
|
'repos': [
|
||||||
{
|
{
|
||||||
|
|
@ -92,17 +84,15 @@ def test_no_excludes(capsys, tempdir_factory):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = git_dir(tempdir_factory)
|
add_config_to_repo(in_git_dir.strpath, config)
|
||||||
add_config_to_repo(repo, config)
|
|
||||||
|
|
||||||
with cwd(repo):
|
assert check_useless_excludes.main(()) == 0
|
||||||
assert check_useless_excludes.main(()) == 0
|
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert out == ''
|
assert out == ''
|
||||||
|
|
||||||
|
|
||||||
def test_valid_exclude(capsys, tempdir_factory):
|
def test_valid_exclude(capsys, in_git_dir):
|
||||||
config = {
|
config = {
|
||||||
'repos': [
|
'repos': [
|
||||||
{
|
{
|
||||||
|
|
@ -117,11 +107,9 @@ def test_valid_exclude(capsys, tempdir_factory):
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
repo = git_dir(tempdir_factory)
|
add_config_to_repo(in_git_dir.strpath, config)
|
||||||
add_config_to_repo(repo, config)
|
|
||||||
|
|
||||||
with cwd(repo):
|
assert check_useless_excludes.main(()) == 0
|
||||||
assert check_useless_excludes.main(()) == 0
|
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert out == ''
|
assert out == ''
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ from __future__ import absolute_import
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import io
|
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
@ -24,7 +23,6 @@ from pre_commit.languages import rust
|
||||||
from pre_commit.repository import Repository
|
from pre_commit.repository import Repository
|
||||||
from pre_commit.util import cmd_output
|
from pre_commit.util import cmd_output
|
||||||
from testing.fixtures import config_with_local_hooks
|
from testing.fixtures import config_with_local_hooks
|
||||||
from testing.fixtures import git_dir
|
|
||||||
from testing.fixtures import make_config_from_repo
|
from testing.fixtures import make_config_from_repo
|
||||||
from testing.fixtures import make_repo
|
from testing.fixtures import make_repo
|
||||||
from testing.fixtures import modify_manifest
|
from testing.fixtures import modify_manifest
|
||||||
|
|
@ -96,17 +94,14 @@ def test_python_hook_args_with_spaces(tempdir_factory, store):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_python_hook_weird_setup_cfg(tempdir_factory, store):
|
def test_python_hook_weird_setup_cfg(in_git_dir, tempdir_factory, store):
|
||||||
path = git_dir(tempdir_factory)
|
in_git_dir.join('setup.cfg').write('[install]\ninstall_scripts=/usr/sbin')
|
||||||
with cwd(path):
|
|
||||||
with io.open('setup.cfg', 'w') as setup_cfg:
|
|
||||||
setup_cfg.write('[install]\ninstall_scripts=/usr/sbin\n')
|
|
||||||
|
|
||||||
_test_hook_repo(
|
_test_hook_repo(
|
||||||
tempdir_factory, store, 'python_hooks_repo',
|
tempdir_factory, store, 'python_hooks_repo',
|
||||||
'foo', [os.devnull],
|
'foo', [os.devnull],
|
||||||
b"['" + five.to_bytes(os.devnull) + b"']\nHello World\n",
|
b"['" + five.to_bytes(os.devnull) + b"']\nHello World\n",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@xfailif_no_venv
|
@xfailif_no_venv
|
||||||
|
|
@ -444,14 +439,12 @@ def _norm_pwd(path):
|
||||||
)[1].strip()
|
)[1].strip()
|
||||||
|
|
||||||
|
|
||||||
def test_cwd_of_hook(tempdir_factory, store):
|
def test_cwd_of_hook(in_git_dir, tempdir_factory, store):
|
||||||
# Note: this doubles as a test for `system` hooks
|
# Note: this doubles as a test for `system` hooks
|
||||||
path = git_dir(tempdir_factory)
|
_test_hook_repo(
|
||||||
with cwd(path):
|
tempdir_factory, store, 'prints_cwd_repo',
|
||||||
_test_hook_repo(
|
'prints_cwd', ['-L'], _norm_pwd(in_git_dir.strpath) + b'\n',
|
||||||
tempdir_factory, store, 'prints_cwd_repo',
|
)
|
||||||
'prints_cwd', ['-L'], _norm_pwd(path) + b'\n',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_lots_of_files(tempdir_factory, store):
|
def test_lots_of_files(tempdir_factory, store):
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,11 @@ def get_short_git_status():
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def foo_staged(tempdir_factory):
|
def foo_staged(in_git_dir):
|
||||||
path = git_dir(tempdir_factory)
|
foo = in_git_dir.join('foo')
|
||||||
with cwd(path):
|
foo.write(FOO_CONTENTS)
|
||||||
with io.open('foo', 'w') as foo_file:
|
cmd_output('git', 'add', 'foo')
|
||||||
foo_file.write(FOO_CONTENTS)
|
yield auto_namedtuple(path=in_git_dir.strpath, foo_filename=foo.strpath)
|
||||||
cmd_output('git', 'add', 'foo')
|
|
||||||
foo_filename = os.path.join(path, 'foo')
|
|
||||||
yield auto_namedtuple(path=path, foo_filename=foo_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _test_foo_state(
|
def _test_foo_state(
|
||||||
|
|
@ -134,13 +131,11 @@ def test_foo_both_modify_conflicting(foo_staged, patch_dir):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def img_staged(tempdir_factory):
|
def img_staged(in_git_dir):
|
||||||
path = git_dir(tempdir_factory)
|
img = in_git_dir.join('img.jpg')
|
||||||
with cwd(path):
|
shutil.copy(get_resource_path('img1.jpg'), img.strpath)
|
||||||
img_filename = os.path.join(path, 'img.jpg')
|
cmd_output('git', 'add', 'img.jpg')
|
||||||
shutil.copy(get_resource_path('img1.jpg'), img_filename)
|
yield auto_namedtuple(path=in_git_dir.strpath, img_filename=img.strpath)
|
||||||
cmd_output('git', 'add', 'img.jpg')
|
|
||||||
yield auto_namedtuple(path=path, img_filename=img_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _test_img_state(path, expected_file='img1.jpg', status='A'):
|
def _test_img_state(path, expected_file='img1.jpg', status='A'):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue