!7 fix testcase failure
From: @lyn1001 Reviewed-by: @hht8,@disnight,@overweight Signed-off-by: @overweight
This commit is contained in:
commit
376fe816e4
85
fix-testcase-error.patch
Normal file
85
fix-testcase-error.patch
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
diff -Nur pytest-mock-1.10.0/test_pytest_mock.py pytest-mock-1.10.0_bak/test_pytest_mock.py
|
||||||
|
--- pytest-mock-1.10.0/test_pytest_mock.py 2018-05-02 01:10:54.000000000 +0800
|
||||||
|
+++ pytest-mock-1.10.0_bak/test_pytest_mock.py 2021-06-03 16:34:18.277654058 +0800
|
||||||
|
@@ -12,6 +12,9 @@
|
||||||
|
skip_pypy = pytest.mark.skipif(platform.python_implementation() == 'PyPy',
|
||||||
|
reason='could not make work on pypy')
|
||||||
|
|
||||||
|
+#Python 3.8 changed the output formatting (bpo-35500), which has been ported to mock 3.0
|
||||||
|
+NEW_FORMATTING = sys.version_info >= (3, 8) or sys.version_info[0] == 2
|
||||||
|
+
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def needs_assert_rewrite(pytestconfig):
|
||||||
|
@@ -179,7 +182,11 @@
|
||||||
|
|
||||||
|
def __test_failure_message(self, mocker, **kwargs):
|
||||||
|
expected_name = kwargs.get('name') or 'mock'
|
||||||
|
- expected_message = 'Expected call: {0}()\nNot called'.format(expected_name)
|
||||||
|
+ if NEW_FORMATTING:
|
||||||
|
+ msg = "expected call not found.\nExpected: {0}()\nActual: not called."
|
||||||
|
+ else:
|
||||||
|
+ msg = "Expected call: {0}()\nNot called"
|
||||||
|
+ expected_message = msg.format(expected_name)
|
||||||
|
stub = mocker.stub(**kwargs)
|
||||||
|
with pytest.raises(AssertionError) as exc_info:
|
||||||
|
stub.assert_called_with()
|
||||||
|
@@ -559,20 +566,30 @@
|
||||||
|
m.assert_called_once_with('', bar=4)
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest('-s')
|
||||||
|
- result.stdout.fnmatch_lines([
|
||||||
|
- "*AssertionError: Expected call: mock('', bar=4)*",
|
||||||
|
- "*Actual call: mock('fo')*",
|
||||||
|
+ if NEW_FORMATTING:
|
||||||
|
+ expected_lines = [
|
||||||
|
+ "*AssertionError: expected call not found.",
|
||||||
|
+ "*Expected: mock('', bar=4)",
|
||||||
|
+ "*Actual: mock('fo')",
|
||||||
|
+ ]
|
||||||
|
+ else:
|
||||||
|
+ expected_lines = [
|
||||||
|
+ "*AssertionError: Expected call: mock('', bar=4)*",
|
||||||
|
+ "*Actual call: mock('fo')*",
|
||||||
|
+ ]
|
||||||
|
+ expected_lines += [
|
||||||
|
"*pytest introspection follows:*",
|
||||||
|
- '*Args:',
|
||||||
|
+ "*Args:",
|
||||||
|
"*assert ('fo',) == ('',)",
|
||||||
|
"*At index 0 diff: 'fo' != ''*",
|
||||||
|
"*Use -v to get the full diff*",
|
||||||
|
"*Kwargs:*",
|
||||||
|
"*assert {} == {'bar': 4}*",
|
||||||
|
- "*Right contains more items:*",
|
||||||
|
+ "*Right contains* more item*",
|
||||||
|
"*{'bar': 4}*",
|
||||||
|
"*Use -v to get the full diff*",
|
||||||
|
- ])
|
||||||
|
+ ]
|
||||||
|
+ result.stdout.fnmatch_lines(expected_lines)
|
||||||
|
|
||||||
|
|
||||||
|
def test_assert_called_with_unicode_arguments(mocker):
|
||||||
|
diff -Nur pytest-mock-1.10.0/tox.ini pytest-mock-1.10.0_bak/tox.ini
|
||||||
|
--- pytest-mock-1.10.0/tox.ini 2018-05-02 01:10:54.000000000 +0800
|
||||||
|
+++ pytest-mock-1.10.0_bak/tox.ini 2021-06-03 15:57:02.000000000 +0800
|
||||||
|
@@ -12,7 +12,7 @@
|
||||||
|
|
||||||
|
[testenv:norewrite]
|
||||||
|
commands =
|
||||||
|
- pytest test_pytest_mock.py --assert=plain -ra
|
||||||
|
+ pytest test_pytest_mock.py --assert=plain
|
||||||
|
|
||||||
|
[testenv:linting]
|
||||||
|
skip_install=True
|
||||||
|
@@ -23,3 +23,9 @@
|
||||||
|
commands =
|
||||||
|
py.test --flakes pytest_mock.py test_pytest_mock.py -m flakes
|
||||||
|
rst-lint CHANGELOG.rst README.rst
|
||||||
|
+
|
||||||
|
+[tool:pytest]
|
||||||
|
+addopts = -r a
|
||||||
|
+
|
||||||
|
+[flake8]
|
||||||
|
+max-line-length = 88
|
||||||
@ -1,10 +1,11 @@
|
|||||||
Name: python-pytest-mock
|
Name: python-pytest-mock
|
||||||
Version: 1.10.0
|
Version: 1.10.0
|
||||||
Release: 4
|
Release: 5
|
||||||
Summary: Thin-wrapper around the mock package for easier use with py.test
|
Summary: Thin-wrapper around the mock package for easier use with py.test
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: https://pypi.python.org/pypi/pytest-mock
|
URL: https://pypi.python.org/pypi/pytest-mock
|
||||||
Source0: https://files.pythonhosted.org/packages/source/p/pytest-mock/pytest-mock-%{version}.tar.gz
|
Source0: https://files.pythonhosted.org/packages/source/p/pytest-mock/pytest-mock-%{version}.tar.gz
|
||||||
|
Patch0001: fix-testcase-error.patch
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -74,5 +75,8 @@ PYTHONPATH="$(pwd)" py.test-%{python3_version} test_pytest_mock.py
|
|||||||
%{python3_sitelib}/__pycache__/*
|
%{python3_sitelib}/__pycache__/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Jun 3 2021 liyanan <liyanan32@huawei.com> - 1.10.0-5
|
||||||
|
- fix testcase failure
|
||||||
|
|
||||||
* Wed Jan 08 2019 yangjian<yangjian79@huawei.com> - 1.10.0-4
|
* Wed Jan 08 2019 yangjian<yangjian79@huawei.com> - 1.10.0-4
|
||||||
- Package init
|
- Package init
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user