diff --git a/src/ansys/mechanical/core/embedding/app.py b/src/ansys/mechanical/core/embedding/app.py index 2967c29a3..d3d2a2435 100644 --- a/src/ansys/mechanical/core/embedding/app.py +++ b/src/ansys/mechanical/core/embedding/app.py @@ -225,7 +225,9 @@ def open(self, db_file, remove_lock=False): if lock_file.exists(): warnings.warn( f"Removing the lock file, {lock_file}, before opening the project. \ -This may corrupt the project file." +This may corrupt the project file.", + UserWarning, + stacklevel=2, ) lock_file.unlink() diff --git a/tests/embedding/test_app.py b/tests/embedding/test_app.py index 31819d132..871c3745e 100644 --- a/tests/embedding/test_app.py +++ b/tests/embedding/test_app.py @@ -447,8 +447,9 @@ def test_app_lock_file_open(embedded_app, tmp_path: pytest.TempPathFactory): # Assert the lock file exists after opening it assert lock_file.exists() - # Remove the lock file before opening the project file - embedded_app.open(project_file, remove_lock=True) + with pytest.warns(UserWarning): + # Remove the lock file before opening the project file + embedded_app.open(project_file, remove_lock=True) # Assert the lock file has been removed assert not lock_file.exists()