From 879217e8cca4564125fb6b60a6106d21d32dfe69 Mon Sep 17 00:00:00 2001 From: Richard Murray Date: Sat, 6 Feb 2021 13:32:32 -0800 Subject: [PATCH] skip timeout test if SIGALRM is not defined --- control/tests/rlocus_test.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/control/tests/rlocus_test.py b/control/tests/rlocus_test.py index 799d45784..3117af947 100644 --- a/control/tests/rlocus_test.py +++ b/control/tests/rlocus_test.py @@ -95,11 +95,17 @@ def test_rlocus_default_wn(self): [-1e-2, 1-1e7j, 1+1e7j], [0, -1e7j, 1e7j], 1)) # Set up a timer to catch execution time - def signal_handler(signum, frame): - raise Exception("rlocus took too long to complete") - signal.signal(signal.SIGALRM, signal_handler) - - # Run the command and reset the alarm - signal.alarm(2) # 2 second timeout - ct.root_locus(sys) - signal.alarm(0) # reset the alarm + try: + def signal_handler(signum, frame): + raise Exception("rlocus took too long to complete") + signal.signal(signal.SIGALRM, signal_handler) + + # Run the command and reset the alarm + signal.alarm(2) # 2 second timeout + ct.root_locus(sys) + signal.alarm(0) # reset the alarm + + except AttributeError: + # If no SIGALRM (eg, on Windows), then skip this test + pass +