From 384d0f4194f535e23cdc86b3df517d55d98445c56fe2427cd7faba5803e39e12 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 15 Apr 2025 22:19:57 +0000 Subject: [PATCH] - Add gh-132535-rsrc-warn-test_timeout.patch to fix failing tests in the build system without network access (gh#python/cpython#132535). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:Factory/python313?expand=0&rev=89 --- gh-132535-rsrc-warn-test_timeout.patch | 94 ++++++++++++++++++++++++++ python313.changes | 3 + python313.spec | 6 +- 3 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 gh-132535-rsrc-warn-test_timeout.patch diff --git a/gh-132535-rsrc-warn-test_timeout.patch b/gh-132535-rsrc-warn-test_timeout.patch new file mode 100644 index 0000000..1dc73a4 --- /dev/null +++ b/gh-132535-rsrc-warn-test_timeout.patch @@ -0,0 +1,94 @@ +From 0e461dd411e9ec3dbdf376435154ca2834bcab51 Mon Sep 17 00:00:00 2001 +From: Serhiy Storchaka +Date: Wed, 16 Apr 2025 00:24:56 +0300 +Subject: [PATCH] gh-132535: Fix resource warnings in test_timeout + +They were emitted if internet connection was not available. +--- + Lib/test/test_timeout.py | 43 ++++++++++++++++--------------------------- + 1 file changed, 16 insertions(+), 27 deletions(-) + +Index: Python-3.13.3/Lib/test/test_timeout.py +=================================================================== +--- Python-3.13.3.orig/Lib/test/test_timeout.py 2025-04-08 15:54:08.000000000 +0200 ++++ Python-3.13.3/Lib/test/test_timeout.py 2025-04-15 23:45:55.028517897 +0200 +@@ -26,10 +26,8 @@ + """Test case for socket.gettimeout() and socket.settimeout()""" + + def setUp(self): +- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +- +- def tearDown(self): +- self.sock.close() ++ self.sock = self.enterContext( ++ socket.socket(socket.AF_INET, socket.SOCK_STREAM)) + + def testObjectCreation(self): + # Test Socket creation +@@ -113,8 +111,6 @@ + def setUp(self): + raise NotImplementedError() + +- tearDown = setUp +- + def _sock_operation(self, count, timeout, method, *args): + """ + Test the specified socket method. +@@ -142,12 +138,10 @@ + """TCP test case for socket.socket() timeout functions""" + + def setUp(self): +- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ++ self.sock = self.enterContext( ++ socket.socket(socket.AF_INET, socket.SOCK_STREAM)) + self.addr_remote = resolve_address('www.python.org.', 80) + +- def tearDown(self): +- self.sock.close() +- + def testConnectTimeout(self): + # Testing connect timeout is tricky: we need to have IP connectivity + # to a host that silently drops our packets. We can't simulate this +@@ -190,19 +184,16 @@ + # for the current configuration. + + skip = True +- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +- timeout = support.LOOPBACK_TIMEOUT +- sock.settimeout(timeout) +- try: +- sock.connect((whitehole)) +- except TimeoutError: +- pass +- except OSError as err: +- if err.errno == errno.ECONNREFUSED: +- skip = False +- finally: +- sock.close() +- del sock ++ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: ++ try: ++ timeout = support.LOOPBACK_TIMEOUT ++ sock.settimeout(timeout) ++ sock.connect((whitehole)) ++ except TimeoutError: ++ pass ++ except OSError as err: ++ if err.errno == errno.ECONNREFUSED: ++ skip = False + + if skip: + self.skipTest( +@@ -269,10 +260,8 @@ + """UDP test case for socket.socket() timeout functions""" + + def setUp(self): +- self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +- +- def tearDown(self): +- self.sock.close() ++ self.sock = self.enterContext( ++ socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) + + def testRecvfromTimeout(self): + # Test recvfrom() timeout diff --git a/python313.changes b/python313.changes index 59874cb..095a92f 100644 --- a/python313.changes +++ b/python313.changes @@ -273,6 +273,9 @@ Fri Apr 11 19:47:34 UTC 2025 - Matej Cepl ignorable. - Add gh126985-mv-pyvenv.cfg2getpath.patch to remove failing tests in test_sysconfig. +- Add gh-132535-rsrc-warn-test_timeout.patch to fix + failing tests in the build system without network access + (gh#python/cpython#132535). ------------------------------------------------------------------- Mon Mar 10 15:44:31 UTC 2025 - Bernhard Wiedemann diff --git a/python313.spec b/python313.spec index 8fed4f3..408383d 100644 --- a/python313.spec +++ b/python313.spec @@ -225,6 +225,9 @@ Patch41: doc-py38-to-py36.patch # PATCH-FIX-UPSTREAM gh126985-mv-pyvenv.cfg2getpath.patch mcepl@suse.com # Remove tests failing in test_sysconfig Patch42: gh126985-mv-pyvenv.cfg2getpath.patch +# PATCH-FIX-UPSTREAM gh-132535-rsrc-warn-test_timeout.patch gh#python/cpython#132535 mcepl@suse.com +# allows test_timeout tests to pass +Patch43: gh-132535-rsrc-warn-test_timeout.patch BuildRequires: autoconf-archive BuildRequires: automake BuildRequires: fdupes @@ -654,9 +657,6 @@ EXCLUDE="$EXCLUDE test_faulthandler" EXCLUDE="$EXCLUDE test_external_inspection test_faulthandler test_os test_posix test_signal test_socket test_subprocess" %endif -# gh#python/cpython#132535 -EXCLUDE="$EXCLUDE test_timeout" - # This test (part of test_uuid) requires real network interfaces # so that ifconfig output has "HWaddr ". Some kvm instances # done have any such interface breaking the uuid module.