public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python-httmock] epel10.2: Complete migration to pyproject macros
@ 2026-10-10  7:53 Steve Traylen
  0 siblings, 0 replies; only message in thread
From: Steve Traylen @ 2026-10-10  7:53 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/python-httmock
            Branch : epel10.2
            Commit : 0014b0654c5272224242808b32aae435fb8c9f1c
            Author : Steve Traylen <steve.traylen@cern.ch>
            Date   : 2023-05-05T22:18:46+02:00
            Stats  : +60/-30 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/python-httmock/c/0014b0654c5272224242808b32aae435fb8c9f1c?branch=epel10.2

            Log:
            Complete migration to pyproject macros

* Complete migration to pyproject macros
* Switch SPDX license field
* Use tests.py matching released version of module (rhbz#2175195)

---
diff --git a/.gitignore b/.gitignore
index 31d8679..50cff98 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
 /httmock-1.2.6.tar.gz
 /httmock-1.3.0.tar.gz
-/tests.py
 /httmock-1.4.0.tar.gz

diff --git a/python-httmock.spec b/python-httmock.spec
index d3e21ff..0474a21 100644
--- a/python-httmock.spec
+++ b/python-httmock.spec
@@ -1,61 +1,67 @@
-%{?python_enable_dependency_generator}
-# Created by pyp2rpm-3.3.0
-%global pypi_name httmock
-
-Name:           python-%{pypi_name}
+Name:           python-httmock
 Version:        1.4.0
-Release:        8%{?dist}
+Release:        9%{?dist}
 Summary:        A mocking library for requests
-
-License:        ASL 2.0
+License:        Apache-2.0
 URL:            https://github.com/patrys/httmock
+
+# Switch to github at next release to avoid the extra Source1
 Source0:        https://files.pythonhosted.org/packages/source/h/httmock/httmock-%{version}.tar.gz
 Source1:        https://raw.githubusercontent.com/patrys/httmock/%{version}/tests.py
+
 # Add a tox file.
 # https://bugzilla.redhat.com/show_bug.cgi?id=2019409
 Patch0:         https://patch-diff.githubusercontent.com/raw/patrys/httmock/pull/64.diff
 BuildArch:      noarch
  
-%description
+%global _description %{expand:
 A mocking library for requests for Python.
 You can use it to mock third-party APIs and test libraries 
-that use requests internally. 
+that use requests internally}
+
 
-%package -n     python3-%{pypi_name}
+%description %_description
+
+%package -n     python3-httmock
 Summary:        %{summary}
 BuildRequires:  python3-devel
 
-%generate_buildrequires
-%pyproject_buildrequires -t
+%description -n python3-httmock %_description
 
-%description -n python3-%{pypi_name}
-A mocking library for requests for Python.
-You can use it to mock third-party APIs and test libraries 
-that use requests internally. 
 
 %prep
-%autosetup -p1 -n %{pypi_name}-%{version}
-# Remove bundled egg-info
-rm -rf %{pypi_name}.egg-info
+%autosetup -p1 -n httmock-%{version}
 cp %{SOURCE1} .
 
+%generate_buildrequires
+%pyproject_buildrequires -t
+
+
 %build
-%py3_build
+%pyproject_wheel
+
 
 %install
-%py3_install
+%pyproject_install
+
+%pyproject_save_files httmock
+
 
 %check
 %{tox}
 
-%files -n python3-%{pypi_name}
+
+%files -n python3-httmock -f %{pyproject_files}
 %license LICENSE
 %doc README.md
-%{python3_sitelib}/__pycache__/*
-%{python3_sitelib}/%{pypi_name}.py
-%{python3_sitelib}/%{pypi_name}-%{version}-py%{python3_version}.egg-info
+
 
 %changelog
+* Fri May 05 2023 Steve Traylen <steve.traylen@cern.ch> 1.4.0-9
+- Complete migration to pyproject macros
+- Switch SPDX license field
+- Use tests.py matching released version of module (rhbz#2175195)
+
 * Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-8
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
 

diff --git a/tests.py b/tests.py
index c396192..9d4cabb 100644
--- a/tests.py
+++ b/tests.py
@@ -66,7 +66,8 @@ def any_mock(url, request):
 def dict_any_mock(url, request):
     return {
         'content': 'Hello from %s' % (url.netloc,),
-        'status_code': 200
+        'status_code': 200,
+        'http_vsn': 10,
     }
 
 
@@ -136,6 +137,13 @@ class MockTest(unittest.TestCase):
         self.assertEqual(r.text, u'Motörhead')
         self.assertEqual(r.content, r.text.encode('utf-8'))
 
+    def test_has_raw_version(self):
+        with HTTMock(any_mock):
+            r = requests.get('http://example.com')
+        self.assertEqual(r.raw.version, 11)
+        with HTTMock(dict_any_mock):
+            r = requests.get('http://example.com')
+        self.assertEqual(r.raw.version, 10)
 
 class DecoratorTest(unittest.TestCase):
 
@@ -242,6 +250,11 @@ class ResponseTest(unittest.TestCase):
         r = response(200, None, {'Content-Type': 'application/json'})
         self.assertEqual(r.headers['content-type'], 'application/json')
 
+    def test_response_raw_version(self):
+        r = response(200, None, {'Content-Type': 'application/json'},
+                     http_vsn=10)
+        self.assertEqual(r.raw.version, 10)
+
     def test_response_cookies(self):
         @all_requests
         def response_content(url, request):
@@ -268,6 +281,18 @@ class ResponseTest(unittest.TestCase):
         self.assertTrue('foo' in session.cookies)
         self.assertEqual(session.cookies['foo'], 'bar')
 
+    def test_session_persistent_cookies(self):
+        session = requests.Session()
+        with HTTMock(lambda u, r: response(200, 'Foo', {'Set-Cookie': 'foo=bar;'}, request=r)):
+            session.get('https://foo_bar')
+        with HTTMock(lambda u, r: response(200, 'Baz', {'Set-Cookie': 'baz=qux;'}, request=r)):
+            session.get('https://baz_qux')
+        self.assertEqual(len(session.cookies), 2)
+        self.assertTrue('foo' in session.cookies)
+        self.assertEqual(session.cookies['foo'], 'bar')
+        self.assertTrue('baz' in session.cookies)
+        self.assertEqual(session.cookies['baz'], 'qux')
+
     def test_python_version_encoding_differences(self):
         # Previous behavior would result in this test failing in Python3 due
         # to how requests checks for utf-8 JSON content in requests.utils with:
@@ -341,7 +366,7 @@ class RememberCalledTest(unittest.TestCase):
             results = self.several_calls(
                 1, requests.get, 'http://facebook.com/')
 
-        self.assertEquals(facebook_mock_count.call['count'], 1)
+        self.assertEqual(facebook_mock_count.call['count'], 1)
 
     @with_httmock(google_mock_count, facebook_mock_count)
     def test_several_call_decorated(self):
@@ -357,7 +382,7 @@ class RememberCalledTest(unittest.TestCase):
             self.assertEqual(r.content, b'Hello from Facebook')
 
         self.several_calls(1, requests.get, 'http://facebook.com/')
-        self.assertEquals(facebook_mock_count.call['count'], 4)
+        self.assertEqual(facebook_mock_count.call['count'], 4)
 
     def test_store_several_requests(self):
         with HTTMock(google_mock_store_requests):

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-10  7:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-10  7:53 [rpms/python-httmock] epel10.2: Complete migration to pyproject macros Steve Traylen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox