Skip to content

Commit 0320595

Browse files
authored
Merge pull request #537 from bnavigator/pytest-timeout
Use pytest-timeout for rlocus test
2 parents 3adc610 + 25114f5 commit 0320595

4 files changed

Lines changed: 7 additions & 10 deletions

File tree

.github/workflows/control-slycot-src.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
sudo apt install -y xvfb
2020
2121
# Install test tools
22-
conda install pip pytest
22+
conda install pip pytest pytest-timeout
2323
2424
# Install python-control dependencies
2525
conda install numpy matplotlib scipy

.github/workflows/python-package-conda.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
sudo apt install -y xvfb
3333
3434
# Install test tools
35-
conda install pip coverage pytest
35+
conda install pip coverage pytest pytest-timeout
3636
pip install coveralls
3737
3838
# Install python-control dependencies

control/tests/rlocus_test.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def test_root_locus_zoom(self):
7676
assert_array_almost_equal(zoom_x, zoom_x_valid)
7777
assert_array_almost_equal(zoom_y, zoom_y_valid)
7878

79+
@pytest.mark.timeout(2)
7980
def test_rlocus_default_wn(self):
8081
"""Check that default wn calculation works properly"""
8182
#
@@ -94,12 +95,5 @@ def test_rlocus_default_wn(self):
9495
sys = ct.tf(*sp.signal.zpk2tf(
9596
[-1e-2, 1-1e7j, 1+1e7j], [0, -1e7j, 1e7j], 1))
9697

97-
# Set up a timer to catch execution time
98-
def signal_handler(signum, frame):
99-
raise Exception("rlocus took too long to complete")
100-
signal.signal(signal.SIGALRM, signal_handler)
101-
102-
# Run the command and reset the alarm
103-
signal.alarm(2) # 2 second timeout
10498
ct.root_locus(sys)
105-
signal.alarm(0) # reset the alarm
99+

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@
4444
install_requires=['numpy',
4545
'scipy',
4646
'matplotlib'],
47+
extras_require={
48+
'test': ['pytest', 'pytest-timeout'],
49+
}
4750
)

0 commit comments

Comments
 (0)