From c74eec174c7b8776003591c5757b9d2a47157d3d Mon Sep 17 00:00:00 2001 From: klmcadams <58492561+klmcadams@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:06:21 -0500 Subject: [PATCH] adjust test and add comments --- src/ansys/mechanical/core/embedding/app.py | 1 + tests/embedding/test_app.py | 10 ++-------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/ansys/mechanical/core/embedding/app.py b/src/ansys/mechanical/core/embedding/app.py index d3d2a2435..b8ca1a411 100644 --- a/src/ansys/mechanical/core/embedding/app.py +++ b/src/ansys/mechanical/core/embedding/app.py @@ -220,6 +220,7 @@ def _dispose(self): def open(self, db_file, remove_lock=False): """Open the db file.""" + # Remove the lock file if it exists before opening the project file if remove_lock: lock_file = Path(self.DataModel.Project.ProjectDirectory) / ".mech_lock" if lock_file.exists(): diff --git a/tests/embedding/test_app.py b/tests/embedding/test_app.py index 871c3745e..4e9747800 100644 --- a/tests/embedding/test_app.py +++ b/tests/embedding/test_app.py @@ -441,15 +441,9 @@ def test_app_lock_file_open(embedded_app, tmp_path: pytest.TempPathFactory): lock_file = Path(embedded_app.DataModel.Project.ProjectDirectory) / ".mech_lock" - # Do not remove the lock file before opening the project file - embedded_app.open(project_file) - - # Assert the lock file exists after opening it + # Assert the lock file exists after saving it assert lock_file.exists() + # Assert a warning is emitted if the lock file is going to be removed 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()