summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_signal.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_signal.py')
-rw-r--r--Lib/test/test_signal.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index 7635eec..7ce89f6 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -67,9 +67,28 @@ class PosixTests(unittest.TestCase):
script = os.path.join(dirname, 'signalinterproctester.py')
assert_python_ok(script)
+ def test_valid_signals(self):
+ s = signal.valid_signals()
+ self.assertIsInstance(s, set)
+ self.assertIn(signal.Signals.SIGINT, s)
+ self.assertIn(signal.Signals.SIGALRM, s)
+ self.assertNotIn(0, s)
+ self.assertNotIn(signal.NSIG, s)
+ self.assertLess(len(s), signal.NSIG)
+
@unittest.skipUnless(sys.platform == "win32", "Windows specific")
class WindowsSignalTests(unittest.TestCase):
+
+ def test_valid_signals(self):
+ s = signal.valid_signals()
+ self.assertIsInstance(s, set)
+ self.assertGreaterEqual(len(s), 6)
+ self.assertIn(signal.Signals.SIGINT, s)
+ self.assertNotIn(0, s)
+ self.assertNotIn(signal.NSIG, s)
+ self.assertLess(len(s), signal.NSIG)
+
def test_issue9324(self):
# Updated for issue #10003, adding SIGBREAK
handler = lambda x, y: None
@@ -922,6 +941,17 @@ class PendingSignalsTests(unittest.TestCase):
self.assertRaises(TypeError, signal.pthread_sigmask, 1)
self.assertRaises(TypeError, signal.pthread_sigmask, 1, 2, 3)
self.assertRaises(OSError, signal.pthread_sigmask, 1700, [])
+ with self.assertRaises(ValueError):
+ signal.pthread_sigmask(signal.SIG_BLOCK, [signal.NSIG])
+
+ @unittest.skipUnless(hasattr(signal, 'pthread_sigmask'),
+ 'need signal.pthread_sigmask()')
+ def test_pthread_sigmask_valid_signals(self):
+ s = signal.pthread_sigmask(signal.SIG_BLOCK, signal.valid_signals())
+ self.addCleanup(signal.pthread_sigmask, signal.SIG_SETMASK, s)
+ # Get current blocked set
+ s = signal.pthread_sigmask(signal.SIG_UNBLOCK, signal.valid_signals())
+ self.assertLessEqual(s, signal.valid_signals())
@unittest.skipUnless(hasattr(signal, 'pthread_sigmask'),
'need signal.pthread_sigmask()')