gh-60203: Always pass True/False as boolean arguments in tests (GH-99983)

Unless we explicitly test non-bool values.
(cherry picked from commit 76f43fc09a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2022-12-04 04:50:46 -08:00 committed by GitHub
parent 9e38553132
commit 7aa87bba05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 8 deletions

View file

@ -6044,5 +6044,5 @@ class SemLockTests(unittest.TestCase):
class SemLock(_multiprocessing.SemLock): class SemLock(_multiprocessing.SemLock):
pass pass
name = f'test_semlock_subclass-{os.getpid()}' name = f'test_semlock_subclass-{os.getpid()}'
s = SemLock(1, 0, 10, name, 0) s = SemLock(1, 0, 10, name, False)
_multiprocessing.sem_unlink(name) _multiprocessing.sem_unlink(name)

View file

@ -1689,7 +1689,7 @@ class TestThreadedServer(SocketThread):
def run(self): def run(self):
try: try:
with self._sock: with self._sock:
self._sock.setblocking(0) self._sock.setblocking(False)
self._run() self._run()
finally: finally:
self._s1.close() self._s1.close()

View file

@ -558,7 +558,7 @@ class FastCallTests(unittest.TestCase):
self.kwargs.clear() self.kwargs.clear()
gc.collect() gc.collect()
return 0 return 0
x = IntWithDict(dont_inherit=IntWithDict()) x = IntWithDict(optimize=IntWithDict())
# We test the argument handling of "compile" here, the compilation # We test the argument handling of "compile" here, the compilation
# itself is not relevant. When we pass flags=x below, x.__index__() is # itself is not relevant. When we pass flags=x below, x.__index__() is
# called, which changes the keywords dict. # called, which changes the keywords dict.

View file

@ -139,8 +139,9 @@ class CAPITest(unittest.TestCase):
class Z(object): class Z(object):
def __len__(self): def __len__(self):
return 1 return 1
self.assertRaises(TypeError, _posixsubprocess.fork_exec, with self.assertRaisesRegex(TypeError, 'indexing'):
1,Z(),3,(1, 2),5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23) _posixsubprocess.fork_exec(
1,Z(),True,(1, 2),5,6,7,8,9,10,11,12,13,14,True,True,17,False,19,20,21,22,False)
# Issue #15736: overflow in _PySequence_BytesToCharpArray() # Issue #15736: overflow in _PySequence_BytesToCharpArray()
class Z(object): class Z(object):
def __len__(self): def __len__(self):
@ -148,7 +149,7 @@ class CAPITest(unittest.TestCase):
def __getitem__(self, i): def __getitem__(self, i):
return b'x' return b'x'
self.assertRaises(MemoryError, _posixsubprocess.fork_exec, self.assertRaises(MemoryError, _posixsubprocess.fork_exec,
1,Z(),3,(1, 2),5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23) 1,Z(),True,(1, 2),5,6,7,8,9,10,11,12,13,14,True,True,17,False,19,20,21,22,False)
@unittest.skipUnless(_posixsubprocess, '_posixsubprocess required for this test.') @unittest.skipUnless(_posixsubprocess, '_posixsubprocess required for this test.')
def test_subprocess_fork_exec(self): def test_subprocess_fork_exec(self):
@ -158,7 +159,7 @@ class CAPITest(unittest.TestCase):
# Issue #15738: crash in subprocess_fork_exec() # Issue #15738: crash in subprocess_fork_exec()
self.assertRaises(TypeError, _posixsubprocess.fork_exec, self.assertRaises(TypeError, _posixsubprocess.fork_exec,
Z(),[b'1'],3,(1, 2),5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23) Z(),[b'1'],True,(1, 2),5,6,7,8,9,10,11,12,13,14,True,True,17,False,19,20,21,22,False)
@unittest.skipIf(MISSING_C_DOCSTRINGS, @unittest.skipIf(MISSING_C_DOCSTRINGS,
"Signature information for builtins requires docstrings") "Signature information for builtins requires docstrings")

View file

@ -3209,7 +3209,7 @@ class POSIXProcessTestCase(BaseTestCase):
1, 2, 3, 4, 1, 2, 3, 4,
True, True, 0, True, True, 0,
None, None, None, -1, None, None, None, -1,
None, "no vfork") None, True)
self.assertIn('fds_to_keep', str(c.exception)) self.assertIn('fds_to_keep', str(c.exception))
finally: finally:
if not gc_enabled: if not gc_enabled: