!15 update to 3.6.1
From: @caodongxia Reviewed-by: @licihua Signed-off-by: @licihua
This commit is contained in:
commit
049e20fbd6
@ -1,50 +0,0 @@
|
|||||||
From b4d1b1166d4d9e5a9df1b1fdea73021c936891b6 Mon Sep 17 00:00:00 2001
|
|
||||||
From: baizg1107 <preloyalwhite@163.com>
|
|
||||||
Date: Tue, 12 Jan 2021 10:25:28 +0800
|
|
||||||
Subject: [PATCH] fix tests expectations with pytest4
|
|
||||||
|
|
||||||
reference: https://github.com/nicoddemus/pytest-mock/commit/970e4b1f8cfd6bd750b4c8240efad378cbf049c2
|
|
||||||
---
|
|
||||||
test_pytest_mock.py | 2 +-
|
|
||||||
tox.ini | 8 +++++++-
|
|
||||||
2 files changed, 8 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/test_pytest_mock.py b/test_pytest_mock.py
|
|
||||||
index e50b5b8..45dbe3f 100644
|
|
||||||
--- a/test_pytest_mock.py
|
|
||||||
+++ b/test_pytest_mock.py
|
|
||||||
@@ -585,7 +585,7 @@ def test_detailed_introspection(testdir):
|
|
||||||
"*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*",
|
|
||||||
]
|
|
||||||
diff --git a/tox.ini b/tox.ini
|
|
||||||
index 7a270b1..bc9eaa0 100644
|
|
||||||
--- a/tox.ini
|
|
||||||
+++ b/tox.ini
|
|
||||||
@@ -12,7 +12,7 @@ commands =
|
|
||||||
|
|
||||||
[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 @@ deps =
|
|
||||||
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
|
|
||||||
--
|
|
||||||
2.23.0
|
|
||||||
|
|
||||||
@ -1,72 +0,0 @@
|
|||||||
From 91ece5ec239e7bf68e928e0377c5335ca5fc214a Mon Sep 17 00:00:00 2001
|
|
||||||
From: Daniel Hahler <git@thequod.de>
|
|
||||||
Date: Sat, 30 Mar 2019 10:58:12 +0100
|
|
||||||
Subject: [PATCH] tests: handle new output format with Python 3.8
|
|
||||||
|
|
||||||
Fixes https://github.com/pytest-dev/pytest-mock/issues/139.
|
|
||||||
---
|
|
||||||
test_pytest_mock.py | 43 +++++++++++++++++++++++++++++--------------
|
|
||||||
1 file changed, 29 insertions(+), 14 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/test_pytest_mock.py b/test_pytest_mock.py
|
|
||||||
index 1cb3889..2413593 100644
|
|
||||||
--- a/test_pytest_mock.py
|
|
||||||
+++ b/test_pytest_mock.py
|
|
||||||
@@ -12,6 +12,9 @@ pytest_plugins = 'pytester'
|
|
||||||
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).
|
|
||||||
+PY38 = sys.version_info >= (3, 8)
|
|
||||||
+
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def needs_assert_rewrite(pytestconfig):
|
|
||||||
@@ -179,7 +182,11 @@ class TestMockerStub:
|
|
||||||
|
|
||||||
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 PY38:
|
|
||||||
+ 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,11 +566,20 @@ def test_detailed_introspection(testdir):
|
|
||||||
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 PY38:
|
|
||||||
+ 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*",
|
|
||||||
@@ -572,7 +588,8 @@ def test_detailed_introspection(testdir):
|
|
||||||
"*Right contains more items:*",
|
|
||||||
"*{'bar': 4}*",
|
|
||||||
"*Use -v to get the full diff*",
|
|
||||||
- ])
|
|
||||||
+ ]
|
|
||||||
+ result.stdout.fnmatch_lines(expected_lines)
|
|
||||||
|
|
||||||
|
|
||||||
def test_assert_called_with_unicode_arguments(mocker):
|
|
||||||
Binary file not shown.
BIN
pytest-mock-3.6.1.tar.gz
Normal file
BIN
pytest-mock-3.6.1.tar.gz
Normal file
Binary file not shown.
46
pytest-mock-issue272-asyncio.patch
Normal file
46
pytest-mock-issue272-asyncio.patch
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
Index: pytest-mock-3.6.1/tests/test_pytest_mock.py
|
||||||
|
===================================================================
|
||||||
|
--- pytest-mock-3.6.1.orig/tests/test_pytest_mock.py
|
||||||
|
+++ pytest-mock-3.6.1/tests/test_pytest_mock.py
|
||||||
|
@@ -839,7 +839,7 @@ def test_plain_stopall(testdir: Any) ->
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = testdir.runpytest_subprocess()
|
||||||
|
- result.stdout.fnmatch_lines("* 1 passed in *")
|
||||||
|
+ result.stdout.fnmatch_lines("* 1 passed*")
|
||||||
|
assert "RuntimeError" not in result.stderr.str()
|
||||||
|
|
||||||
|
|
||||||
|
@@ -978,7 +978,7 @@ def test_used_with_class_scope(testdir:
|
||||||
|
)
|
||||||
|
result = testdir.runpytest_subprocess()
|
||||||
|
assert "AssertionError" not in result.stderr.str()
|
||||||
|
- result.stdout.fnmatch_lines("* 1 passed in *")
|
||||||
|
+ result.stdout.fnmatch_lines("* 1 passed*")
|
||||||
|
|
||||||
|
|
||||||
|
def test_used_with_module_scope(testdir: Any) -> None:
|
||||||
|
@@ -1000,7 +1000,7 @@ def test_used_with_module_scope(testdir:
|
||||||
|
)
|
||||||
|
result = testdir.runpytest_subprocess()
|
||||||
|
assert "AssertionError" not in result.stderr.str()
|
||||||
|
- result.stdout.fnmatch_lines("* 1 passed in *")
|
||||||
|
+ result.stdout.fnmatch_lines("* 1 passed*")
|
||||||
|
|
||||||
|
|
||||||
|
def test_used_with_package_scope(testdir: Any) -> None:
|
||||||
|
@@ -1023,7 +1023,7 @@ def test_used_with_package_scope(testdir
|
||||||
|
)
|
||||||
|
result = testdir.runpytest_subprocess()
|
||||||
|
assert "AssertionError" not in result.stderr.str()
|
||||||
|
- result.stdout.fnmatch_lines("* 1 passed in *")
|
||||||
|
+ result.stdout.fnmatch_lines("* 1 passed*")
|
||||||
|
|
||||||
|
|
||||||
|
def test_used_with_session_scope(testdir: Any) -> None:
|
||||||
|
@@ -1046,4 +1046,4 @@ def test_used_with_session_scope(testdir
|
||||||
|
)
|
||||||
|
result = testdir.runpytest_subprocess()
|
||||||
|
assert "AssertionError" not in result.stderr.str()
|
||||||
|
- result.stdout.fnmatch_lines("* 1 passed in *")
|
||||||
|
+ result.stdout.fnmatch_lines("* 1 passed*")
|
||||||
@ -1,12 +1,11 @@
|
|||||||
Name: python-pytest-mock
|
Name: python-pytest-mock
|
||||||
Version: 1.10.0
|
Version: 3.6.1
|
||||||
Release: 8
|
Release: 1
|
||||||
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/b3/08/b131e1b5c628a7d46c9b8d676a86a8d235bced79b9d90845500e39df81b9/pytest-mock-%{version}.tar.gz
|
||||||
Patch0001: backport-tests-handle-new-output-format-with-Python-3.8.patch
|
Patch0001: pytest-mock-issue272-asyncio.patch
|
||||||
Patch0002: 0001-fix-tests-expectations-with-pytest4.patch
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -18,7 +17,7 @@ it also provides other nice utilities.
|
|||||||
%package -n python3-pytest-mock
|
%package -n python3-pytest-mock
|
||||||
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
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRequires: python3-devel python3-pytest >= 2.7 python3-setuptools_scm
|
BuildRequires: python3-devel python3-pytest >= 2.7 python3-setuptools_scm python3-pytest-mock
|
||||||
Requires: python3-pytest >= 2.7
|
Requires: python3-pytest >= 2.7
|
||||||
%{?python_provide:%python_provide python3-pytest-mock}
|
%{?python_provide:%python_provide python3-pytest-mock}
|
||||||
|
|
||||||
@ -41,17 +40,18 @@ rm -rf *.egg-info
|
|||||||
|
|
||||||
|
|
||||||
%check
|
%check
|
||||||
PYTHONPATH="$(pwd)" py.test-%{python3_version} test_pytest_mock.py
|
/usr/bin/pytest --assert=plain
|
||||||
|
|
||||||
%files -n python3-pytest-mock
|
%files -n python3-pytest-mock
|
||||||
%doc README.rst
|
%doc README.rst
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
%{python3_sitelib}/pytest_mock-%{version}-py%{python3_version}.egg-info/
|
%{python3_sitelib}/pytest_mock-%{version}-py%{python3_version}.egg-info/
|
||||||
%{python3_sitelib}/pytest_mock.py*
|
%{python3_sitelib}/pytest_mock/
|
||||||
%{python3_sitelib}/_pytest_mock_version.py*
|
|
||||||
%{python3_sitelib}/__pycache__/*
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Apr 26 2022 caodongxia <caodongxia@h-partners.com> - 3.6.1-1
|
||||||
|
- update to 3.6.1
|
||||||
|
|
||||||
* Mon Jan 11 2021 maminjie <maminje1@huawei.com> - 1.10.0-8
|
* Mon Jan 11 2021 maminjie <maminje1@huawei.com> - 1.10.0-8
|
||||||
- fix tests expectations with pytest4
|
- fix tests expectations with pytest4
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user