@@ -4098,6 +4098,8 @@ class FastWaitTestCase(BaseTestCase):
40984098 """Tests for efficient (pidfd_open / kqueue) process waiting in
40994099 subprocess.Popen.wait().
41004100 """
4101+ CAN_USE_PIDFD_OPEN = hasattr (os , "pidfd_open" )
4102+ CAN_USE_KQUEUE = subprocess ._CAN_USE_KQUEUE
41014103
41024104 def assert_fast_waitpid_error (self , patch_point ):
41034105 # Emulate a case where pidfd_open() (Linux) or kqueue()
@@ -4111,19 +4113,15 @@ def assert_fast_waitpid_error(self, patch_point):
41114113 self .assertEqual (p .wait (timeout = support .SHORT_TIMEOUT ), 0 )
41124114 assert m .called
41134115
4114- @unittest .skipIf (not hasattr ( os , "pidfd_open" ) , reason = "LINUX only" )
4116+ @unittest .skipIf (not CAN_USE_PIDFD_OPEN , reason = "LINUX only" )
41154117 def test_wait_pidfd_open_error (self ):
41164118 self .assert_fast_waitpid_error ("os.pidfd_open" )
41174119
4118- @unittest .skipIf (
4119- not subprocess ._CAN_USE_KQUEUE , reason = "macOS / BSD only"
4120- )
4120+ @unittest .skipIf (not CAN_USE_KQUEUE , reason = "macOS / BSD only" )
41214121 def test_wait_kqueue_error (self ):
41224122 self .assert_fast_waitpid_error ("select.kqueue" )
41234123
4124- @unittest .skipIf (
4125- not subprocess ._CAN_USE_KQUEUE , reason = "macOS / BSD only"
4126- )
4124+ @unittest .skipIf (not CAN_USE_KQUEUE , reason = "macOS / BSD only" )
41274125 def test_kqueue_control_error (self ):
41284126 # Emulate a case where kqueue.control() fails. _busy_wait()
41294127 # should be used as fallback.
@@ -4162,13 +4160,11 @@ def wrapper(*args, **kwargs):
41624160 assert m .called
41634161 self .assertEqual (status , 0 )
41644162
4165- @unittest .skipIf (not hasattr ( os , "pidfd_open" ) , reason = "LINUX only" )
4163+ @unittest .skipIf (not CAN_USE_PIDFD_OPEN , reason = "LINUX only" )
41664164 def test_pidfd_open_race (self ):
41674165 self .assert_wait_race_condition ("os.pidfd_open" , os .pidfd_open )
41684166
4169- @unittest .skipIf (
4170- not subprocess ._CAN_USE_KQUEUE , reason = "macOS / BSD only"
4171- )
4167+ @unittest .skipIf (not CAN_USE_KQUEUE , reason = "macOS / BSD only" )
41724168 def test_kqueue_race (self ):
41734169 self .assert_wait_race_condition ("select.kqueue" , select .kqueue )
41744170
0 commit comments