aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/python-3-fix-tests.patch
blob: d31af3563015cae1c115c67c71f9781f42a13b0f (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
From f0698133e7d6c353a3e6ae0fc62e57ba558a9bc0 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Date: Wed, 28 Oct 2020 22:55:05 -0400
Subject: [PATCH] Skip problematic Python 3 tests in Guix.

A subset of the hunks in this patch is tracked upstream at
https://bugs.python.org/issue38845, which was contributed by Tanguy Le
Carrour <tanguy@bioneland.org>.

diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
index d8e9c5a760..94fc5929c9 100644
--- a/Lib/ctypes/test/test_callbacks.py
+++ b/Lib/ctypes/test/test_callbacks.py
@@ -5,6 +5,7 @@
 from ctypes import *
 from ctypes.test import need_symbol
 import _ctypes_test
+import platform
 
 class Callbacks(unittest.TestCase):
     functype = CFUNCTYPE
@@ -178,6 +179,8 @@ def func(x):
 
         self.assertLess(diff, 0.01, "%s not less than 0.01" % diff)
 
+    @unittest.skipIf(platform.machine() in ['mips64'],
+                     "This test fails on this platform")
     def test_issue_8959_a(self):
         from ctypes.util import find_library
         libc_path = find_library("c")
diff --git a/Lib/ctypes/test/test_find.py b/Lib/ctypes/test/test_find.py
index 1ff9d019b1..5194954914 100644
--- a/Lib/ctypes/test/test_find.py
+++ b/Lib/ctypes/test/test_find.py
@@ -117,6 +117,7 @@ def test_find_library_with_gcc(self):
         with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None):
             self.assertNotEqual(find_library('c'), None)
 
+    @unittest.skipIf(True, "ldconfig is not used on Guix")
     def test_find_library_with_ld(self):
         with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None), \
              unittest.mock.patch("ctypes.util._findLib_gcc", lambda *args: None):
diff --git a/Lib/ctypes/test/test_libc.py b/Lib/ctypes/test/test_libc.py
index 56285b5ff8..c088ab3db8 100644
--- a/Lib/ctypes/test/test_libc.py
+++ b/Lib/ctypes/test/test_libc.py
@@ -2,6 +2,7 @@
 
 from ctypes import *
 import _ctypes_test
+import platform
 
 lib = CDLL(_ctypes_test.__file__)
 
@@ -17,6 +18,8 @@ def test_sqrt(self):
         import math
         self.assertEqual(lib.my_sqrt(2.0), math.sqrt(2.0))
 
+    @unittest.skipIf(platform.machine() in ['mips64'],
+                     "This test fails on this platform")
     def test_qsort(self):
         comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char))
         lib.my_qsort.argtypes = c_void_p, c_size_t, c_size_t, comparefunc
diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test_archive_util.py
index edcec2513e..a716150763 100644
--- a/Lib/distutils/tests/test_archive_util.py
+++ b/Lib/distutils/tests/test_archive_util.py
@@ -335,6 +335,7 @@ def test_make_archive_xztar(self):
         self.assertEqual(os.path.basename(res), 'archive.tar.xz')
         self.assertEqual(self._tarinfo(res), self._created_files)
 
+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     def test_make_archive_owner_group(self):
         # testing make_archive with owner and group, with various combinations
         # this works even if there's not gid/uid support
@@ -364,6 +365,7 @@ def test_make_archive_owner_group(self):
 
     @unittest.skipUnless(ZLIB_SUPPORT, "Requires zlib")
     @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     def test_tarfile_root_owner(self):
         tmpdir =  self._create_files()
         base_name = os.path.join(self.mkdtemp(), 'archive')
diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
index 752e9db5ba..c66b6323e4 100644
--- a/Lib/distutils/tests/test_sdist.py
+++ b/Lib/distutils/tests/test_sdist.py
@@ -444,6 +444,7 @@ def test_manual_manifest(self):
                      "The tar command is not found")
     @unittest.skipIf(find_executable('gzip') is None,
                      "The gzip command is not found")
+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     def test_make_distribution_owner_group(self):
         # now building a sdist
         dist, cmd = self.get_cmd()
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 8dced90c53..59947e3023 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -1589,6 +1589,7 @@ def _test_wait_result(cls, c, pid):
         if pid is not None:
             os.kill(pid, signal.SIGINT)
 
+    @unittest.skipIf(True, "This fails for unknown reasons on Guix")
     def test_wait_result(self):
         if isinstance(self, ProcessesMixin) and sys.platform != 'win32':
             pid = os.getpid()
@@ -4008,6 +4009,7 @@ def test_shared_memory_across_processes(self):
         sms.close()
 
     @unittest.skipIf(os.name != "posix", "not feasible in non-posix platforms")
+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
     def test_shared_memory_SharedMemoryServer_ignores_sigint(self):
         # bpo-36368: protect SharedMemoryManager server process from
         # KeyboardInterrupt signals.
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
index d77bf95a7b..79912c8230 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -1359,6 +1359,8 @@ def test_create_connection_no_inet_pton(self, m_socket):
         self._test_create_connection_ip_addr(m_socket, False)
 
     @patch_socket
+    @unittest.skipUnless(support.is_resource_enabled('network'),
+                         'network is not enabled')
     def test_create_connection_service_name(self, m_socket):
         m_socket.getaddrinfo = socket.getaddrinfo
         sock = m_socket.socket.return_value
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 3bf5f3b743..23368c8d8b 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -33,6 +33,7 @@ def generator2(self):
         else:
             return "FAILED"
 
+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment')
     def test_raise_and_yield_from(self):
         gen = self.generator1()
         gen.send(None)
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index bf3fc5fb24..21015403f3 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -2546,6 +2546,7 @@ def test_rglob(self):
                          'pwd module does not expose getpwall()')
     @unittest.skipIf(sys.platform == "vxworks",
                      "no home directory on VxWorks")
+    @unittest.skipIf(True, "Guix builder home is '/' which causes trouble for these tests")
     def test_expanduser(self):
         P = self.cls
         import_helper.import_module('pwd')
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 6ac1a4a3c3..4f58cf9b40 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -1315,11 +1315,11 @@ def test_pdb_issue_20766():
     > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
     -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
     (Pdb) continue
-    pdb 1: <built-in function default_int_handler>
+    pdb 1: Handlers.SIG_IGN
     > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
     -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
     (Pdb) continue
-    pdb 2: <built-in function default_int_handler>
+    pdb 2: Handlers.SIG_IGN
     """
 
 def test_pdb_issue_43318():
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index 62e6c28280..7ffee56635 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -810,6 +810,7 @@ def test_fromfile(self):
         output = self.run_tests('--fromfile', filename)
         self.check_executed_tests(output, tests)
 
+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
     def test_interrupted(self):
         code = TEST_INTERRUPTED
         test = self.create_test('sigint', code=code)
@@ -827,6 +828,7 @@ def test_slowest(self):
                  % (self.TESTNAME_REGEX, len(tests)))
         self.check_line(output, regex)
 
+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
     def test_slowest_interrupted(self):
         # Issue #25373: test --slowest with an interrupted test
         code = TEST_INTERRUPTED
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
index f2642c6ba1..4358a20dae 100644
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -150,6 +150,7 @@ def test_freebsd_contants(self):
 
     @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
     @support.requires_linux_version(2, 6, 36)
+    @unittest.skipIf(True, "Bug: the PermissionError is not raised")
     def test_prlimit(self):
         self.assertRaises(TypeError, resource.prlimit)
         self.assertRaises(ProcessLookupError, resource.prlimit,
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 62e9180375..3eda176fa3 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -1497,6 +1497,7 @@ def test_make_archive(self):
         base_name = os.path.join(tmpdir, 'archive')
         self.assertRaises(ValueError, make_archive, base_name, 'xxx')
 
+    @unittest.skipIf(True, "The Guix build container has no root user")
     @support.requires_zlib()
     def test_make_archive_owner_group(self):
         # testing make_archive with owner and group, with various combinations
@@ -1525,6 +1526,7 @@ def test_make_archive_owner_group(self):
         self.assertTrue(os.path.isfile(res))
 
 
+    @unittest.skipIf(True, "The Guix build container has no root user")
     @support.requires_zlib()
     @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
     def test_tarfile_root_owner(self):
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index c2b5861fc3..3c7a9c42cb 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -89,6 +89,7 @@ def test_valid_signals(self):
         self.assertLess(len(s), signal.NSIG)
 
     @unittest.skipUnless(sys.executable, "sys.executable required.")
+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
     def test_keyboard_interrupt_exit_code(self):
         """KeyboardInterrupt triggers exit via SIGINT."""
         process = subprocess.run(
@@ -139,6 +140,7 @@ def test_issue9324(self):
             signal.signal(7, handler)
 
     @unittest.skipUnless(sys.executable, "sys.executable required.")
+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
     def test_keyboard_interrupt_exit_code(self):
         """KeyboardInterrupt triggers an exit using STATUS_CONTROL_C_EXIT."""
         # We don't test via os.kill(os.getpid(), signal.CTRL_C_EVENT) here
@@ -1322,6 +1324,7 @@ def cycle_handlers():
 
 class RaiseSignalTest(unittest.TestCase):
 
+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
     def test_sigint(self):
         with self.assertRaises(KeyboardInterrupt):
             signal.raise_signal(signal.SIGINT)
@@ -1352,6 +1355,7 @@ def handler(a, b):
 
 class PidfdSignalTest(unittest.TestCase):
 
+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
     @unittest.skipUnless(
         hasattr(signal, "pidfd_send_signal"),
         "pidfd support not built in",
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 9c5f6d3dc9..ef74fc5694 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1006,6 +1006,8 @@ def testHostnameRes(self):
         if not fqhn in all_host_names:
             self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))
 
+    @unittest.skipUnless(support.is_resource_enabled('network'),
+                         'network is not enabled')
     def test_host_resolution(self):
         for addr in [socket_helper.HOSTv4, '10.0.0.1', '255.255.255.255']:
             self.assertEqual(socket.gethostbyname(addr), addr)
@@ -1136,6 +1138,8 @@ def testNtoHErrors(self):
             self.assertRaises(OverflowError, socket.ntohl, k)
             self.assertRaises(OverflowError, socket.htonl, k)
 
+    @unittest.skipUnless(os.path.exists("/etc/services"),
+                         "getservbyname uses /etc/services, which is not in the chroot")
     def testGetServBy(self):
         eq = self.assertEqual
         # Find one service that exists, then check all the related interfaces.
@@ -1485,6 +1489,8 @@ def test_sio_loopback_fast_path(self):
             raise
         self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None)
 
+    @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
+                         "getaddrinfo() will fail")
     def testGetaddrinfo(self):
         try:
             socket.getaddrinfo('localhost', 80)
@@ -1567,6 +1573,8 @@ def test_getnameinfo(self):
         # only IP addresses are allowed
         self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0)
 
+    @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
+                         "getaddrinfo() will fail")
     @unittest.skipUnless(support.is_resource_enabled('network'),
                          'network is not enabled')
     def test_idna(self):
diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
index a143acc659..f7207887c0 100644
--- a/Lib/test/test_spwd.py
+++ b/Lib/test/test_spwd.py
@@ -6,8 +6,7 @@
 spwd = import_helper.import_module('spwd')
 
 
-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0,
-                     'root privileges required')
+@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
 class TestSpwdRoot(unittest.TestCase):
 
     def test_getspall(self):
@@ -57,8 +56,7 @@ def test_getspnam(self):
             self.assertRaises(TypeError, spwd.getspnam, bytes_name)
 
 
-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() != 0,
-                     'non-root user required')
+@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
 class TestSpwdNonRoot(unittest.TestCase):
 
     def test_getspnam_exception(self):
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index c658cca7a7..b7188e411e 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -2737,9 +2737,12 @@ def root_is_uid_gid_0():
         import pwd, grp
     except ImportError:
         return False
-    if pwd.getpwuid(0)[0] != 'root':
-        return False
-    if grp.getgrgid(0)[0] != 'root':
+    try:
+        if pwd.getpwuid(0)[0] != 'root':
+            return False
+        if grp.getgrgid(0)[0] != 'root':
+            return False
+    except KeyError:
         return False
     return True
 
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index c54806e594..d9bbca4e6a 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -1620,6 +1620,7 @@ def check_interrupt_main_noerror(self, signum):
             # Restore original handler
             signal.signal(signum, handler)
 
+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
     def test_interrupt_main_subthread(self):
         # Calling start_new_thread with a function that executes interrupt_main
         # should raise KeyboardInterrupt upon completion.
@@ -1631,6 +1632,8 @@ def call_interrupt():
             t.join()
         t.join()
 
+
+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
     def test_interrupt_main_mainthread(self):
         # Make sure that if interrupt_main is called in main thread that
         # KeyboardInterrupt is raised instantly.
diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
index 213b3cf252..a5edd4a119 100644
--- a/Lib/test/test_unicodedata.py
+++ b/Lib/test/test_unicodedata.py
@@ -315,6 +315,7 @@ def test_linebreak_7643(self):
                 self.assertEqual(len(lines), 1,
                                  r"\u%.4x should not be a linebreak" % i)
 
+@requires_resource('network')
 class NormalizationTest(unittest.TestCase):
     @staticmethod
     def check_version(testfile):
diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
index 48feb3f778..e82cafc88a 100644
--- a/Tools/scripts/run_tests.py
+++ b/Tools/scripts/run_tests.py
@@ -40,7 +40,7 @@ def main(regrtest_args):
     if not any(is_multiprocess_flag(arg) for arg in regrtest_args):
         args.extend(['-j', '0'])  # Use all CPU cores
     if not any(is_resource_use_flag(arg) for arg in regrtest_args):
-        args.extend(['-u', 'all,-largefile,-audio,-gui'])
+        args.extend(['-u', 'all,-largefile,-audio,-gui,-network'])
     args.extend(regrtest_args)
     print(' '.join(args))
     if sys.platform == 'win32':