summaryrefslogtreecommitdiff
path: root/tests/PexpectTestCase.py
diff options
context:
space:
mode:
authorRed_M <1468433+Red-M@users.noreply.github.com>2023-03-14 07:21:54 +1000
committerGitHub <noreply@github.com>2023-03-14 07:21:54 +1000
commitdd3cc5c8ea71e1400f0e21fbcc3749c49af5362b (patch)
tree9a74b1ac8ce67b814bd7663998fbd043c076593c /tests/PexpectTestCase.py
parent5c59b0bc6e1ccc3082f114f2a8615198b86064c9 (diff)
parent571ca4b49d2c469aaaa57bfea6d8a28d8a91c4fc (diff)
downloadpexpect-dd3cc5c8ea71e1400f0e21fbcc3749c49af5362b.tar.gz
Merge pull request #745 from tapple/socket_spawn
Socket Pexpect (for Windows support)
Diffstat (limited to 'tests/PexpectTestCase.py')
-rw-r--r--tests/PexpectTestCase.py35
1 files changed, 19 insertions, 16 deletions
diff --git a/tests/PexpectTestCase.py b/tests/PexpectTestCase.py
index 5d7a168..a762d8f 100644
--- a/tests/PexpectTestCase.py
+++ b/tests/PexpectTestCase.py
@@ -49,22 +49,25 @@ class PexpectTestCase(unittest.TestCase):
print('\n', self.id(), end=' ')
sys.stdout.flush()
- # some build agents will ignore SIGHUP and SIGINT, which python
- # inherits. This causes some of the tests related to terminate()
- # to fail. We set them to the default handlers that they should
- # be, and restore them back to their SIG_IGN value on tearDown.
- #
- # I'm not entirely convinced they need to be restored, only our
- # test runner is affected.
- self.restore_ignored_signals = [
- value for value in (signal.SIGHUP, signal.SIGINT,)
- if signal.getsignal(value) == signal.SIG_IGN]
- if signal.SIGHUP in self.restore_ignored_signals:
- # sighup should be set to default handler
- signal.signal(signal.SIGHUP, signal.SIG_DFL)
- if signal.SIGINT in self.restore_ignored_signals:
- # SIGINT should be set to signal.default_int_handler
- signal.signal(signal.SIGINT, signal.default_int_handler)
+ if sys.platform != 'win32':
+ # some build agents will ignore SIGHUP and SIGINT, which python
+ # inherits. This causes some of the tests related to terminate()
+ # to fail. We set them to the default handlers that they should
+ # be, and restore them back to their SIG_IGN value on tearDown.
+ #
+ # I'm not entirely convinced they need to be restored, only our
+ # test runner is affected.
+ self.restore_ignored_signals = [
+ value for value in (signal.SIGHUP, signal.SIGINT,)
+ if signal.getsignal(value) == signal.SIG_IGN]
+ if signal.SIGHUP in self.restore_ignored_signals:
+ # sighup should be set to default handler
+ signal.signal(signal.SIGHUP, signal.SIG_DFL)
+ if signal.SIGINT in self.restore_ignored_signals:
+ # SIGINT should be set to signal.default_int_handler
+ signal.signal(signal.SIGINT, signal.default_int_handler)
+ else:
+ self.restore_ignored_signals = []
unittest.TestCase.setUp(self)
def tearDown(self):