From a86683e2b85624fc9e1398bda187a944e755cc2e Mon Sep 17 00:00:00 2001 From: Manu <3916435+m3nu@users.noreply.github.com> Date: Sun, 13 Sep 2020 12:55:10 +0800 Subject: [PATCH] Cancel Borg thread at end of test. (#648) Maybe fixes #632 --- tests/conftest.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 012bd1bb..f462a420 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -52,6 +52,17 @@ def local_en(): os.environ['LANG'] = 'en' +@pytest.fixture(scope='function', autouse=True) +def cleanup(request, qapp, qtbot): + """ + Ensure BorgThread is stopped when new test starts. + """ + def ensure_borg_thread_stopped(): + qapp.backup_cancelled_event.emit() + qtbot.waitUntil(lambda: not vorta.borg.borg_thread.BorgThread.is_running()) + request.addfinalizer(ensure_borg_thread_stopped) + + @pytest.fixture(scope='session') def qapp(tmpdir_factory, local_en): tmp_db = tmpdir_factory.mktemp('Vorta').join('settings.sqlite')