Merge pull request #555 from pre-commit/no_subprocess_touch_tests

Replace calls to touch with open(..., 'a').close()
This commit is contained in:
Anthony Sottile
2017-07-08 16:09:11 -07:00
committed by GitHub
4 changed files with 6 additions and 6 deletions

View File

@@ -118,7 +118,7 @@ def test_uninstall(tempdir_factory):
def _get_commit_output(tempdir_factory, touch_file='foo', **kwargs):
cmd_output('touch', touch_file)
open(touch_file, 'a').close()
cmd_output('git', 'add', touch_file)
return cmd_output_mocked_pre_commit_home(
'git', 'commit', '-am', 'Commit!', '--allow-empty',

View File

@@ -68,7 +68,7 @@ def _make_conflict():
def in_merge_conflict(tempdir_factory):
path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
with cwd(path):
cmd_output('touch', 'dummy')
open('dummy', 'a').close()
cmd_output('git', 'add', 'dummy')
cmd_output('git', 'commit', '-m', 'Add config.')

View File

@@ -20,13 +20,13 @@ def test_make_archive(tempdir_factory):
git_path = git_dir(tempdir_factory)
# Add a files to the git directory
with cwd(git_path):
cmd_output('touch', 'foo')
open('foo', 'a').close()
cmd_output('git', 'add', '.')
cmd_output('git', 'commit', '-m', 'foo')
# We'll use this sha
head_sha = get_head_sha('.')
# And check that this file doesn't exist
cmd_output('touch', 'bar')
open('bar', 'a').close()
cmd_output('git', 'add', '.')
cmd_output('git', 'commit', '-m', 'bar')

View File

@@ -46,7 +46,7 @@ def test_store_require_created(store):
# Should create the store directory
assert os.path.exists(store.directory)
# Should create a README file indicating what the directory is about
with io.open(os.path.join(store.directory, 'README'), 'r') as readme_file:
with io.open(os.path.join(store.directory, 'README')) as readme_file:
readme_contents = readme_file.read()
for text_line in (
'This directory is maintained by the pre-commit project.',
@@ -73,7 +73,7 @@ def test_does_not_recreate_if_directory_already_exists(store):
# Note: we're intentionally leaving out the README file. This is so we can
# know that `Store` didn't call create
os.mkdir(store.directory)
io.open(store.db_path, 'a+').close()
open(store.db_path, 'a').close()
# Call require_created, this should not call create
store.require_created()
assert not os.path.exists(os.path.join(store.directory, 'README'))