Add regression test for #339.

This commit is contained in:
Anthony Sottile
2016-02-07 12:33:39 -08:00
parent 941149942d
commit 982be73784

View File

@@ -596,3 +596,26 @@ def test_unstaged_message_suppressed(
args = _get_opts(**opts)
ret, printed = _do_run(modified_config_repo, args)
assert b'Your .pre-commit-config.yaml is unstaged.' not in printed
def test_files_running_subdir(
repo_with_passing_hook, mock_out_store_directory, tempdir_factory,
):
with cwd(repo_with_passing_hook):
install(Runner(repo_with_passing_hook))
os.mkdir('subdir')
open('subdir/foo.py', 'w').close()
cmd_output('git', 'add', 'subdir/foo.py')
with cwd('subdir'):
# Don't want to write to home directory
env = dict(os.environ, PRE_COMMIT_HOME=tempdir_factory.get())
# Use subprocess to demonstrate behaviour in main
_, stdout, _ = cmd_output(
sys.executable, '-m', 'pre_commit.main', 'run', '-v',
# Files relative to where we are (#339)
'--files', 'foo.py',
env=env,
)
assert 'subdir/foo.py' in stdout