Skip to content

Commit 665f8df

Browse files
Ruff: PT011 pytest-raises-too-broad
1 parent 0dfdbc2 commit 665f8df

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

ruff.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6210,15 +6210,13 @@ convention = "google"
62106210
"test/TestAbstractActuatorBase.py" = [
62116211
"EXE001",
62126212
"N999",
6213-
"PT011",
62146213
"PT012",
62156214
"SLF001",
62166215
]
62176216
"test/TestAbstractMotorBase.py" = [
62186217
"B017",
62196218
"EXE001",
62206219
"N999",
6221-
"PT011",
62226220
"PT012",
62236221
"SLF001",
62246222
]
@@ -6227,7 +6225,6 @@ convention = "google"
62276225
"C400",
62286226
"EXE001",
62296227
"N999",
6230-
"PT011",
62316228
"PT012",
62326229
]
62336230
"test/TestHardwareObjectBase.py" = [
@@ -6349,7 +6346,6 @@ convention = "google"
63496346
"PIE804",
63506347
]
63516348
"test/test_resolution.py" = [
6352-
"PT011",
63536349
"PT012",
63546350
"PT022",
63556351
"SLF001",

test/TestAbstractActuatorBase.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ def test_value_setting(self, test_object):
8080

8181
if test_object.read_only:
8282
# test that there is an exception as read only
83-
with pytest.raises(ValueError):
83+
with pytest.raises(
84+
ValueError, match="Attempt to set value for read-only Actuator"
85+
):
8486
test_object.set_value(test_object.default_value)
8587
else:
8688
# Test set_value with and without a timeout (different code branch)

test/TestAbstractMotorBase.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def test_setting_with_tolerance(self, test_object):
121121
assert not test_object.validate_value(toobig), (
122122
"Too-big value %s validates as OK" % toobig
123123
)
124-
with pytest.raises(ValueError):
124+
with pytest.raises(ValueError, match=r"Invalid value [\d\.]*"):
125125
test_object.set_value(toobig, timeout=None)
126126

127127
# Must be set first so the next command causes a change
@@ -158,7 +158,7 @@ def test_setting_timeouts_1(self, test_object):
158158

159159
# Must be set first so the next command causes a change
160160
test_object.set_value(low, timeout=90)
161-
with pytest.raises(Exception):
161+
with pytest.raises(RuntimeError):
162162
test_object.set_value(high, timeout=1.0e-6)
163163

164164
def test_setting_timeouts_2(self, test_object):
@@ -174,7 +174,7 @@ def test_setting_timeouts_2(self, test_object):
174174

175175
# Must be set first so the next command causes a change
176176
test_object.set_value(high, timeout=None)
177-
with pytest.raises(Exception):
177+
with pytest.raises(RuntimeError):
178178
test_object.set_value(low, timeout=0)
179179
test_object.wait_ready(timeout=1.0e-6)
180180

test/TestAbstractNStateBase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_setting_timeouts_1(self, test_object):
6969

7070
# Must be set first so the next command causes a change
7171
test_object.set_value(val1, timeout=90)
72-
with pytest.raises(Exception):
72+
with pytest.raises(RuntimeError):
7373
test_object.set_value(val2, timeout=1.0e-6)
7474

7575
def test_setting_timeouts_2(self, test_object):
@@ -84,6 +84,6 @@ def test_setting_timeouts_2(self, test_object):
8484

8585
# Must be set first so the next command causes a change
8686
test_object.set_value(val2, timeout=None)
87-
with pytest.raises(Exception):
87+
with pytest.raises(RuntimeError):
8888
test_object.set_value(val1, timeout=0)
8989
test_object.wait_ready(timeout=1.0e-6)

test/test_resolution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_setting_with_tolerance(self, test_object):
7777
f"Too big value {toobig} validates as OK"
7878
)
7979

80-
with pytest.raises(ValueError):
80+
with pytest.raises(ValueError, match=r"Invalid value [\d\.]*"):
8181
test_object.set_value(toobig, timeout=None)
8282

8383
# Must be set first so the next command causes a change

0 commit comments

Comments
 (0)