diff --git a/tests/test_launcher.py b/tests/test_launcher.py index 0a68ed1b8a..e890cfc1bc 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -1790,7 +1790,13 @@ def test_get_version_env_var(monkeypatch, version): pytest.raises(VersionError, match="Running MAPDL as a service requires"), None, ], - ["anymode", None, "posix", warnings.catch_warnings(record=True), "anymode"], + [ + "anymode", + None, + "posix", + pytest.warns(UserWarning, match="PyMAPDL couldn't detect MAPDL version"), + "anymode", + ], ], ) def test_check_mode(mode, version, osname, context, res): @@ -1798,15 +1804,6 @@ def test_check_mode(mode, version, osname, context, res): with context as cnt: assert res == check_mode(mode, version) - if mode is not None and version is None: - # check warning - for each in cnt: - if "PyMAPDL couldn't detect MAPDL version" in each.message.args[0]: - break - else: - # if using the break above, this 'else' is not executed. - assert False, "The expected warning was not raised" - @pytest.mark.parametrize("jobid", [1001, 2002]) @patch("subprocess.Popen", lambda *args, **kwargs: None)