diff --git a/0001-fix-tests-expectations-with-pytest4.patch b/0001-fix-tests-expectations-with-pytest4.patch deleted file mode 100644 index d6d6c1d120dbc0493a3336d39f46ea0ccf9567e8..0000000000000000000000000000000000000000 --- a/0001-fix-tests-expectations-with-pytest4.patch +++ /dev/null @@ -1,50 +0,0 @@ -From b4d1b1166d4d9e5a9df1b1fdea73021c936891b6 Mon Sep 17 00:00:00 2001 -From: baizg1107 -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 - diff --git a/backport-tests-handle-new-output-format-with-Python-3.8.patch b/backport-tests-handle-new-output-format-with-Python-3.8.patch deleted file mode 100644 index 0f5efa69de9896e36e7f62776d17468eef39eb27..0000000000000000000000000000000000000000 --- a/backport-tests-handle-new-output-format-with-Python-3.8.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 91ece5ec239e7bf68e928e0377c5335ca5fc214a Mon Sep 17 00:00:00 2001 -From: Daniel Hahler -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): diff --git a/pytest-mock-1.10.0.tar.gz b/pytest-mock-1.10.0.tar.gz deleted file mode 100644 index 9247fa744698d58b6e095e3701622f468ea75b5c..0000000000000000000000000000000000000000 Binary files a/pytest-mock-1.10.0.tar.gz and /dev/null differ diff --git a/pytest-mock-2.0.0.tar.gz b/pytest-mock-2.0.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..cbd3f7c9d112ef2a336924a784f1739a5fde128e Binary files /dev/null and b/pytest-mock-2.0.0.tar.gz differ diff --git a/python-pytest-mock.spec b/python-pytest-mock.spec index f951eefd452014c792a8ae5922a5af193a3a5772..b0d68e3091414e8e6d8c02e5643a31a405ab46a5 100644 --- a/python-pytest-mock.spec +++ b/python-pytest-mock.spec @@ -1,68 +1,104 @@ +%global _empty_manifest_terminate_build 0 Name: python-pytest-mock -Version: 1.10.0 -Release: 8 +Version: 2.0.0 +Release: 1 Summary: Thin-wrapper around the mock package for easier use with py.test License: MIT -URL: https://pypi.python.org/pypi/pytest-mock -Source0: https://files.pythonhosted.org/packages/source/p/pytest-mock/pytest-mock-%{version}.tar.gz -Patch0001: backport-tests-handle-new-output-format-with-Python-3.8.patch -Patch0002: 0001-fix-tests-expectations-with-pytest4.patch +URL: https://github.com/pytest-dev/pytest-mock/ +Source0: https://files.pythonhosted.org/packages/e2/8b/b9671ce133aed04838fdd37ef408bfdd402e81ad634beca1c6cd0b8a7524/pytest-mock-2.0.0.tar.gz BuildArch: noarch - %description -This plugin provides a mocker fixture which is a thin-wrapper around the -patching API provided by the mock package. -Besides undoing the mocking automatically after the end of the test, -it also provides other nice utilities. + pytest-mock This plugin provides a mocker fixture which is a thin-wrapper +around the patching API provided by the mock package < code-block:: python +import os class UnixFS: @staticmethod def rm(filename): os.remove(filename) def +test_unix_fs(mocker): mocker.patch('os.remove') UnixFS.rm('file') +os.remove.assert_called_once_with('file') Besides undoing the mocking +automatically after the end of the test, it also provides other nice utilities +such as spy and stub, and uses pytest introspection when comparing calls. -%package -n python3-pytest-mock +%package -n python3-pytest-mock Summary: Thin-wrapper around the mock package for easier use with py.test -BuildArch: noarch -BuildRequires: python3-devel python3-pytest >= 2.7 python3-setuptools_scm -Requires: python3-pytest >= 2.7 -%{?python_provide:%python_provide python3-pytest-mock} - +Provides: python-pytest-mock +# Base build requires +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pbr +BuildRequires: python3-pip +BuildRequires: python3-wheel +# General requires +BuildRequires: python3-pytest +BuildRequires: python3-pre-commit +BuildRequires: python3-tox +# General requires +Requires: python3-pytest +Requires: python3-pre-commit +Requires: python3-tox %description -n python3-pytest-mock -This plugin provides a mocker fixture which is a thin-wrapper around the -patching API provided by the mock package. -Besides undoing the mocking automatically after the end of the test, -it also provides other nice utilities. + pytest-mock This plugin provides a mocker fixture which is a thin-wrapper +around the patching API provided by the mock package < code-block:: python +import os class UnixFS: @staticmethod def rm(filename): os.remove(filename) def +test_unix_fs(mocker): mocker.patch('os.remove') UnixFS.rm('file') +os.remove.assert_called_once_with('file') Besides undoing the mocking +automatically after the end of the test, it also provides other nice utilities +such as spy and stub, and uses pytest introspection when comparing calls. + +%package help +Summary: Thin-wrapper around the mock package for easier use with py.test +Provides: python3-pytest-mock-doc +%description help + pytest-mock This plugin provides a mocker fixture which is a thin-wrapper +around the patching API provided by the mock package < code-block:: python +import os class UnixFS: @staticmethod def rm(filename): os.remove(filename) def +test_unix_fs(mocker): mocker.patch('os.remove') UnixFS.rm('file') +os.remove.assert_called_once_with('file') Besides undoing the mocking +automatically after the end of the test, it also provides other nice utilities +such as spy and stub, and uses pytest introspection when comparing calls. %prep -%autosetup -n pytest-mock-%{version} -p1 -rm -rf *.egg-info +%autosetup -n pytest-mock-%{version} %build %py3_build - %install %py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . %check -PYTHONPATH="$(pwd)" py.test-%{python3_version} test_pytest_mock.py - -%files -n python3-pytest-mock -%doc README.rst -%license LICENSE -%{python3_sitelib}/pytest_mock-%{version}-py%{python3_version}.egg-info/ -%{python3_sitelib}/pytest_mock.py* -%{python3_sitelib}/_pytest_mock_version.py* -%{python3_sitelib}/__pycache__/* +%{__python3} setup.py test -%changelog -* Mon Jan 11 2021 maminjie - 1.10.0-8 -- fix tests expectations with pytest4 +%files -n python3-pytest-mock -f filelist.lst +%dir %{python3_sitelib}/* -* Tue Aug 11 2020 lingsheng - 1.10.0-7 -- Remove python2-pytest-mock subpackage +%files help -f doclist.lst +%{_docdir}/* -* Sun Jun 28 2020 lingsheng - 1.10.0-6 -- Tests handle new output format with Python 3.8 - -* Wed Jun 24 2020 lizhenhua - 1.10.0-5 -- Modify test cases for python3.8 +%changelog +* Mon Feb 14 2022 OpenStack_SIG - 2.0.0-1 +- Init package python3-pytest-mock of version 2.0.0 -* Wed Jan 08 2019 yangjian - 1.10.0-4 -- Package init