Kaydet (Commit) 4af23d7d authored tarafından Berker Peksag's avatar Berker Peksag

Use requires_os_func() to skip SpawnTests

üst 03179ef3
...@@ -90,6 +90,10 @@ def ignore_deprecation_warnings(msg_regex, quiet=False): ...@@ -90,6 +90,10 @@ def ignore_deprecation_warnings(msg_regex, quiet=False):
yield yield
def requires_os_func(name):
return unittest.skipUnless(hasattr(os, name), 'requires os.%s' % name)
class _PathLike(os.PathLike): class _PathLike(os.PathLike):
def __init__(self, path=""): def __init__(self, path=""):
...@@ -2193,55 +2197,55 @@ class SpawnTests(unittest.TestCase): ...@@ -2193,55 +2197,55 @@ class SpawnTests(unittest.TestCase):
return args return args
@unittest.skipUnless(hasattr(os, 'spawnl'), 'need os.spawnl') @requires_os_func('spawnl')
def test_spawnl(self): def test_spawnl(self):
args = self.create_args() args = self.create_args()
exitcode = os.spawnl(os.P_WAIT, args[0], *args) exitcode = os.spawnl(os.P_WAIT, args[0], *args)
self.assertEqual(exitcode, self.exitcode) self.assertEqual(exitcode, self.exitcode)
@unittest.skipUnless(hasattr(os, 'spawnle'), 'need os.spawnle') @requires_os_func('spawnle')
def test_spawnle(self): def test_spawnle(self):
args = self.create_args(with_env=True) args = self.create_args(with_env=True)
exitcode = os.spawnle(os.P_WAIT, args[0], *args, self.env) exitcode = os.spawnle(os.P_WAIT, args[0], *args, self.env)
self.assertEqual(exitcode, self.exitcode) self.assertEqual(exitcode, self.exitcode)
@unittest.skipUnless(hasattr(os, 'spawnlp'), 'need os.spawnlp') @requires_os_func('spawnlp')
def test_spawnlp(self): def test_spawnlp(self):
args = self.create_args() args = self.create_args()
exitcode = os.spawnlp(os.P_WAIT, args[0], *args) exitcode = os.spawnlp(os.P_WAIT, args[0], *args)
self.assertEqual(exitcode, self.exitcode) self.assertEqual(exitcode, self.exitcode)
@unittest.skipUnless(hasattr(os, 'spawnlpe'), 'need os.spawnlpe') @requires_os_func('spawnlpe')
def test_spawnlpe(self): def test_spawnlpe(self):
args = self.create_args(with_env=True) args = self.create_args(with_env=True)
exitcode = os.spawnlpe(os.P_WAIT, args[0], *args, self.env) exitcode = os.spawnlpe(os.P_WAIT, args[0], *args, self.env)
self.assertEqual(exitcode, self.exitcode) self.assertEqual(exitcode, self.exitcode)
@unittest.skipUnless(hasattr(os, 'spawnv'), 'need os.spawnv') @requires_os_func('spawnv')
def test_spawnv(self): def test_spawnv(self):
args = self.create_args() args = self.create_args()
exitcode = os.spawnv(os.P_WAIT, args[0], args) exitcode = os.spawnv(os.P_WAIT, args[0], args)
self.assertEqual(exitcode, self.exitcode) self.assertEqual(exitcode, self.exitcode)
@unittest.skipUnless(hasattr(os, 'spawnve'), 'need os.spawnve') @requires_os_func('spawnve')
def test_spawnve(self): def test_spawnve(self):
args = self.create_args(with_env=True) args = self.create_args(with_env=True)
exitcode = os.spawnve(os.P_WAIT, args[0], args, self.env) exitcode = os.spawnve(os.P_WAIT, args[0], args, self.env)
self.assertEqual(exitcode, self.exitcode) self.assertEqual(exitcode, self.exitcode)
@unittest.skipUnless(hasattr(os, 'spawnvp'), 'need os.spawnvp') @requires_os_func('spawnvp')
def test_spawnvp(self): def test_spawnvp(self):
args = self.create_args() args = self.create_args()
exitcode = os.spawnvp(os.P_WAIT, args[0], args) exitcode = os.spawnvp(os.P_WAIT, args[0], args)
self.assertEqual(exitcode, self.exitcode) self.assertEqual(exitcode, self.exitcode)
@unittest.skipUnless(hasattr(os, 'spawnvpe'), 'need os.spawnvpe') @requires_os_func('spawnvpe')
def test_spawnvpe(self): def test_spawnvpe(self):
args = self.create_args(with_env=True) args = self.create_args(with_env=True)
exitcode = os.spawnvpe(os.P_WAIT, args[0], args, self.env) exitcode = os.spawnvpe(os.P_WAIT, args[0], args, self.env)
self.assertEqual(exitcode, self.exitcode) self.assertEqual(exitcode, self.exitcode)
@unittest.skipUnless(hasattr(os, 'spawnv'), 'need os.spawnv') @requires_os_func('spawnv')
def test_nowait(self): def test_nowait(self):
args = self.create_args() args = self.create_args()
pid = os.spawnv(os.P_NOWAIT, args[0], args) pid = os.spawnv(os.P_NOWAIT, args[0], args)
...@@ -2254,7 +2258,7 @@ class SpawnTests(unittest.TestCase): ...@@ -2254,7 +2258,7 @@ class SpawnTests(unittest.TestCase):
else: else:
self.assertEqual(status, self.exitcode << 8) self.assertEqual(status, self.exitcode << 8)
@unittest.skipUnless(hasattr(os, 'spawnve'), 'need os.spawnve') @requires_os_func('spawnve')
def test_spawnve_bytes(self): def test_spawnve_bytes(self):
# Test bytes handling in parse_arglist and parse_envlist (#28114) # Test bytes handling in parse_arglist and parse_envlist (#28114)
args = self.create_args(with_env=True, use_bytes=True) args = self.create_args(with_env=True, use_bytes=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment