Small cleanups

This commit is contained in:
Anthony Sottile 2017-09-30 15:15:52 -07:00
parent e717df0ba8
commit 18c9e061d8
17 changed files with 40 additions and 58 deletions

View file

@ -11,7 +11,6 @@ import mock
import pytest
from pre_commit import error_handler
from pre_commit.errors import FatalError
from testing.util import cmd_output_mocked_pre_commit_home
@ -28,7 +27,7 @@ def test_error_handler_no_exception(mocked_log_and_exit):
def test_error_handler_fatal_error(mocked_log_and_exit):
exc = FatalError('just a test')
exc = error_handler.FatalError('just a test')
with error_handler.error_handler():
raise exc
@ -46,7 +45,7 @@ def test_error_handler_fatal_error(mocked_log_and_exit):
r' File ".+tests.error_handler_test.py", line \d+, '
r'in test_error_handler_fatal_error\n'
r' raise exc\n'
r'(pre_commit\.errors\.)?FatalError: just a test\n',
r'(pre_commit\.error_handler\.)?FatalError: just a test\n',
mocked_log_and_exit.call_args[0][2],
)
@ -77,7 +76,7 @@ def test_error_handler_uncaught_error(mocked_log_and_exit):
def test_log_and_exit(cap_out, mock_out_store_directory):
with pytest.raises(SystemExit):
error_handler._log_and_exit(
'msg', FatalError('hai'), "I'm a stacktrace",
'msg', error_handler.FatalError('hai'), "I'm a stacktrace",
)
printed = cap_out.get()

View file

@ -7,7 +7,7 @@ import os.path
import pytest
from pre_commit import git
from pre_commit.errors import FatalError
from pre_commit.error_handler import FatalError
from pre_commit.util import cmd_output
from pre_commit.util import cwd
from testing.fixtures import git_dir

View file

@ -4,7 +4,6 @@ from __future__ import unicode_literals
import os.path
import tarfile
import mock
import pytest
from pre_commit import make_archives
@ -53,12 +52,8 @@ def test_make_archive(tempdir_factory):
@skipif_slowtests_false
@pytest.mark.integration
def test_main(tempdir_factory):
path = tempdir_factory.get()
# Don't actually want to make these in the current repo
with mock.patch.object(make_archives, 'RESOURCES_DIR', path):
make_archives.main()
def test_main(tmpdir):
make_archives.main(('--dest', tmpdir.strpath))
for archive, _, _ in make_archives.REPOS:
assert os.path.exists(os.path.join(path, archive + '.tar.gz'))
assert tmpdir.join('{}.tar.gz'.format(archive)).exists()