Skip to content

Commit 3162202

Browse files
Skip test for root user.
1 parent 185d5a6 commit 3162202

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Lib/test/test_threading.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,18 +1187,23 @@ def test_start_new_thread_failed(self):
11871187
def f():
11881188
print("shouldn't be printed")
11891189
1190-
resource.setrlimit(resource.RLIMIT_NPROC, (0, 0))
1190+
limits = resource.getrlimit(resource.RLIMIT_NPROC)
1191+
[_, hard] = limits
1192+
resource.setrlimit(resource.RLIMIT_NPROC, (0, hard))
11911193
11921194
try:
11931195
_thread.start_new_thread(f, ())
11941196
except RuntimeError:
1195-
pass
1197+
print('ok')
11961198
else:
1197-
exit('successfully created thread')
1199+
print('skip')
11981200
"""
1199-
_, out, err = assert_python_ok("-c", code)
1201+
_, out, err = assert_python_ok("-u", "-c", code)
1202+
out = out.strip()
1203+
if out == b'skip':
1204+
self.skipTest('RLIMIT_NPROC had no effect; probably superuser')
1205+
self.assertEqual(out, b'ok')
12001206
self.assertEqual(err, b'')
1201-
self.assertEqual(out, b'')
12021207

12031208
@cpython_only
12041209
def test_finalize_daemon_thread_hang(self):

0 commit comments

Comments
 (0)