Remove pytest-mock

This commit is contained in:
George Y. Kussumoto
2018-10-06 19:57:30 -03:00
parent 2ad69e12ce
commit bb6b1c33ae
2 changed files with 13 additions and 13 deletions

View File

@@ -5,4 +5,3 @@ flake8
mock
pytest
pytest-env
pytest-mock

View File

@@ -2,24 +2,25 @@
from __future__ import absolute_import
from __future__ import unicode_literals
import mock
import pytest
from pre_commit import xargs
@pytest.fixture
def sys_win32_mock(mocker):
return mocker.Mock(
def sys_win32_mock():
return mock.Mock(
platform='win32',
getfilesystemencoding=mocker.Mock(return_value='utf-8'),
getfilesystemencoding=mock.Mock(return_value='utf-8'),
)
@pytest.fixture
def sys_linux_mock(mocker):
return mocker.Mock(
def sys_linux_mock():
return mock.Mock(
platform='linux',
getfilesystemencoding=mocker.Mock(return_value='utf-8'),
getfilesystemencoding=mock.Mock(return_value='utf-8'),
)
@@ -52,28 +53,28 @@ def test_partition_limits():
)
def test_partition_limit_win32(mocker, sys_win32_mock):
def test_partition_limit_win32(sys_win32_mock):
cmd = ('ninechars',)
varargs = ('😑' * 10,)
with mocker.mock_module.patch('pre_commit.xargs.sys', sys_win32_mock):
with mock.patch('pre_commit.xargs.sys', sys_win32_mock):
ret = xargs.partition(cmd, varargs, _max_length=20)
assert ret == (cmd + varargs,)
def test_partition_limit_linux(mocker, sys_linux_mock):
def test_partition_limit_linux(sys_linux_mock):
cmd = ('ninechars',)
varargs = ('😑' * 5,)
with mocker.mock_module.patch('pre_commit.xargs.sys', sys_linux_mock):
with mock.patch('pre_commit.xargs.sys', sys_linux_mock):
ret = xargs.partition(cmd, varargs, _max_length=30)
assert ret == (cmd + varargs,)
def test_argument_too_long_with_large_unicode(mocker, sys_linux_mock):
def test_argument_too_long_with_large_unicode(sys_linux_mock):
cmd = ('ninechars',)
varargs = ('😑' * 10,) # 4 bytes * 10
with mocker.mock_module.patch('pre_commit.xargs.sys', sys_linux_mock):
with mock.patch('pre_commit.xargs.sys', sys_linux_mock):
with pytest.raises(xargs.ArgumentTooLongError):
xargs.partition(cmd, varargs, _max_length=20)