commit:     8d607e82728af8b47ab080d7fb579248d74fdd58
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun May 22 08:54:16 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun May 22 08:54:16 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8d607e82

dev-python/betamax: Modernize and fix tests

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/betamax/betamax-0.8.1-r1.ebuild         | 42 ++++++++++++----------
 .../betamax/files/betamax-0.8.1-pytest.patch       | 38 ++++++++++++++++++++
 2 files changed, 62 insertions(+), 18 deletions(-)

diff --git a/dev-python/betamax/betamax-0.8.1-r1.ebuild 
b/dev-python/betamax/betamax-0.8.1-r1.ebuild
index 9bfbc639f340..b6b1380f35fe 100644
--- a/dev-python/betamax/betamax-0.8.1-r1.ebuild
+++ b/dev-python/betamax/betamax-0.8.1-r1.ebuild
@@ -5,34 +5,40 @@ EAPI=8
 
 PYTHON_COMPAT=( python3_{8..11} pypy3 )
 DISTUTILS_USE_PEP517=setuptools
+
 inherit distutils-r1
 
 DESCRIPTION="python-requests HTTP exchanges recorder"
-HOMEPAGE="https://github.com/betamaxpy/betamax";
+HOMEPAGE="
+       https://github.com/betamaxpy/betamax/
+       https://pypi.org/project/betamax/
+"
 SRC_URI="mirror://pypi/${PN::1}/${PN}/${P}.tar.gz"
 
 LICENSE="Apache-2.0"
 SLOT="0"
 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~ppc ~ppc64 ~riscv 
~s390 ~sparc ~x86 ~x64-macos"
 
-RDEPEND="dev-python/requests[${PYTHON_USEDEP}]"
+RDEPEND="
+       dev-python/requests[${PYTHON_USEDEP}]
+"
+
+distutils_enable_tests pytest
 
 PATCHES=(
-       "${FILESDIR}/betamax-0.8.1-tests.patch"
+       "${FILESDIR}/${P}-pytest.patch"
 )
 
-distutils_enable_tests pytest
-
-src_prepare() {
-       rm tests/integration/test_hooks.py || die
-       rm tests/integration/test_placeholders.py || die
-       sed -e 's:test_records:_&:' \
-               -e 's:test_replaces:_&:' \
-               -e 's:test_replays:_&:' \
-               -e 's:test_creates:_&:' \
-               -i tests/integration/test_record_modes.py || die
-       rm tests/integration/test_unicode.py || die
-       rm tests/regression/test_gzip_compression.py || die
-       rm tests/regression/test_requests_2_11_body_matcher.py || die
-       distutils-r1_src_prepare
-}
+EPYTEST_DESELECT=(
+       # Internet
+       tests/integration/test_hooks.py
+       tests/integration/test_placeholders.py
+       
tests/integration/test_record_modes.py::TestRecordOnce::test_records_new_interaction
+       
tests/integration/test_record_modes.py::TestRecordOnce::test_replays_response_from_cassette
+       tests/integration/test_record_modes.py::TestRecordNewEpisodes
+       
tests/integration/test_record_modes.py::TestRecordNewEpisodesCreatesCassettes
+       tests/integration/test_record_modes.py::TestRecordAll
+       tests/integration/test_unicode.py
+       tests/regression/test_gzip_compression.py
+       tests/regression/test_requests_2_11_body_matcher.py
+)

diff --git a/dev-python/betamax/files/betamax-0.8.1-pytest.patch 
b/dev-python/betamax/files/betamax-0.8.1-pytest.patch
new file mode 100644
index 000000000000..e3bfe39c81ca
--- /dev/null
+++ b/dev-python/betamax/files/betamax-0.8.1-pytest.patch
@@ -0,0 +1,38 @@
+From 165cc321f2b9839418269e9493b03eb2e43f7ddf Mon Sep 17 00:00:00 2001
+From: Jiri Kuncar <[email protected]>
+Date: Mon, 9 Sep 2019 12:23:18 +0200
+Subject: [PATCH] tests: fix direct calls to PyTest fixtures
+
+https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly
+---
+ tests/unit/test_fixtures.py | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/tests/unit/test_fixtures.py b/tests/unit/test_fixtures.py
+index 387d9ce..41f33eb 100644
+--- a/tests/unit/test_fixtures.py
++++ b/tests/unit/test_fixtures.py
+@@ -27,9 +27,9 @@ def test_adds_stop_as_a_finalizer(self):
+         # Mock a pytest request object
+         request = mock.MagicMock()
+         request.cls = request.module = None
+-        request.function.__name__ = 'test'
++        request.node.name = request.function.__name__ = 'test'
+ 
+-        pytest_fixture.betamax_recorder(request)
++        pytest_fixture._betamax_recorder(request)
+         assert request.addfinalizer.called is True
+         request.addfinalizer.assert_called_once_with(self.mocked_betamax.stop)
+ 
+@@ -37,9 +37,9 @@ def test_auto_starts_the_recorder(self):
+         # Mock a pytest request object
+         request = mock.MagicMock()
+         request.cls = request.module = None
+-        request.function.__name__ = 'test'
++        request.node.name = request.function.__name__ = 'test'
+ 
+-        pytest_fixture.betamax_recorder(request)
++        pytest_fixture._betamax_recorder(request)
+         self.mocked_betamax.start.assert_called_once_with()
+ 
+ 

Reply via email to