From fb0c139865dab28b684d77a76c5187bc0230247e Mon Sep 17 00:00:00 2001
From: Athanasius <github@miggy.org>
Date: Mon, 5 Sep 2022 12:44:13 +0100
Subject: [PATCH] tests: journal_lock: Ensure all tests, that should, clean up

---
 tests/journal_lock.py/test_journal_lock.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tests/journal_lock.py/test_journal_lock.py b/tests/journal_lock.py/test_journal_lock.py
index 514edac9..b271543c 100644
--- a/tests/journal_lock.py/test_journal_lock.py
+++ b/tests/journal_lock.py/test_journal_lock.py
@@ -200,9 +200,9 @@ class TestJournalLock:
         locked = jlock.obtain_lock()
         assert locked == JournalLockResult.LOCKED
         assert jlock.locked
-        assert jlock.release_lock()
 
         # Cleanup, to avoid side-effect on other tests
+        assert jlock.release_lock()
         os.unlink(str(jlock.journal_dir_lockfile_name))
 
     def test_obtain_lock_with_tmpdir_ro(self, mock_journaldir: py_path_local_LocalPath):
@@ -314,6 +314,9 @@ class TestJournalLock:
         with open(mock_journaldir / 'edmc-journal-lock.txt', mode='w+') as lf:
             assert _obtain_lock('release-lock', lf)
 
+        # Cleanup, to avoid side-effect on other tests
+        os.unlink(str(jlock.journal_dir_lockfile_name))
+
     def test_release_lock_not_locked(self, mock_journaldir: py_path_local_LocalPath):
         """Test JournalLock.release_lock() when not locked."""
         jlock = JournalLock()
@@ -350,7 +353,9 @@ class TestJournalLock:
         assert jlock.journal_dir != old_journaldir
         assert jlock.locked
 
+        # Cleanup, to avoid side-effect on other tests
         assert jlock.release_lock()
+        os.unlink(str(jlock.journal_dir_lockfile_name))
 
     def test_update_lock_same(self, mock_journaldir: py_path_local_LocalPath):
         """
@@ -370,3 +375,7 @@ class TestJournalLock:
         jlock.update_lock(None)  # type: ignore
         assert jlock.journal_dir == old_journaldir
         assert jlock.locked
+
+        # Cleanup, to avoid side-effect on other tests
+        assert jlock.release_lock()
+        os.unlink(str(jlock.journal_dir_lockfile_name))