Skip to content

Commit 6637be8

Browse files
committed
fix
1 parent 6765901 commit 6637be8

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ ignore = [
120120
"S607", # todo: Starting a process with a partial executable path
121121
"RET504", # todo:Unnecessary variable assignment before `return` statement
122122
"PT004", # todo: Fixture `tmpdir_unittest_fixture` does not return anything, add leading underscore
123-
"PT011", # todo: `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception
124123
"PT012", # todo: `pytest.raises()` block should contain a single simple statement
125124
"PT019", # todo: Fixture `_` without value is injected as parameter, use `@pytest.mark.usefixtures` instead
126125
]

tests/tests_pytorch/loggers/test_neptune.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,19 @@ def test_online_with_wrong_kwargs(neptune_mock):
121121
init."""
122122
run = neptune_mock.init_run()
123123

124-
with pytest.raises(ValueError):
124+
with pytest.raises(ValueError, match="Run parameter expected to be of type `neptune.Run`*"):
125125
NeptuneLogger(run="some string")
126126

127-
with pytest.raises(ValueError):
127+
with pytest.raises(ValueError, match="When an already initialized run object is provided*"):
128128
NeptuneLogger(run=run, project="redundant project")
129129

130-
with pytest.raises(ValueError):
130+
with pytest.raises(ValueError, match="When an already initialized run object is provided*"):
131131
NeptuneLogger(run=run, api_key="redundant api key")
132132

133-
with pytest.raises(ValueError):
133+
with pytest.raises(ValueError, match="When an already initialized run object is provided*"):
134134
NeptuneLogger(run=run, name="redundant api name")
135135

136-
with pytest.raises(ValueError):
136+
with pytest.raises(ValueError, match="When an already initialized run object is provided*"):
137137
NeptuneLogger(run=run, foo="random **kwarg")
138138

139139
# this should work

tests/tests_pytorch/models/test_hparams.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def __init__(self, arg1, arg2):
527527
)
528528
def test_single_config_models_fail(tmp_path, cls, config):
529529
"""Test fail on passing unsupported config type."""
530-
with pytest.raises(ValueError):
530+
with pytest.raises(ValueError, match=r"Primitives \(<class 'bool'>*"):
531531
_ = cls(**config)
532532

533533

tests/tests_pytorch/profilers/test_profiler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ def test_simple_profiler_overhead(simple_profiler):
8686
def test_simple_profiler_value_errors(simple_profiler):
8787
"""Ensure errors are raised where expected."""
8888
action = "test"
89-
with pytest.raises(ValueError):
89+
with pytest.raises(ValueError, match="Attempting to stop recording an action*"):
9090
simple_profiler.stop(action)
9191

9292
simple_profiler.start(action)
9393

94-
with pytest.raises(ValueError):
94+
with pytest.raises(ValueError, match="Attempted to start test*"):
9595
simple_profiler.start(action)
9696

9797
simple_profiler.stop(action)
@@ -325,7 +325,7 @@ def test_advanced_profiler_dump_states(tmp_path):
325325
def test_advanced_profiler_value_errors(advanced_profiler):
326326
"""Ensure errors are raised where expected."""
327327
action = "test"
328-
with pytest.raises(ValueError):
328+
with pytest.raises(ValueError, match="Attempting to stop recording*"):
329329
advanced_profiler.stop(action)
330330

331331
advanced_profiler.start(action)

tests/tests_pytorch/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def test_lightning_cli_save_config_seed_everything(cleandir):
339339

340340

341341
def test_save_to_log_dir_false_error():
342-
with pytest.raises(ValueError):
342+
with pytest.raises(ValueError, match="`save_to_log_dir=False` only makes sense*"):
343343
SaveConfigCallback(
344344
LightningArgumentParser(),
345345
Namespace(),

0 commit comments

Comments
 (0)