From 5a0e31436b2f3f84239d4b3993bc631660319fb4 Mon Sep 17 00:00:00 2001
From: Athanasius <github@miggy.org>
Date: Wed, 7 Sep 2022 12:27:35 +0100
Subject: [PATCH] tests: journal_lock: Works 100% on Linux, remove 'plan'
 docstring text

---
 tests/journal_lock.py/test_journal_lock.py | 39 ++++------------------
 1 file changed, 6 insertions(+), 33 deletions(-)

diff --git a/tests/journal_lock.py/test_journal_lock.py b/tests/journal_lock.py/test_journal_lock.py
index 7afa588c..016a8f1b 100644
--- a/tests/journal_lock.py/test_journal_lock.py
+++ b/tests/journal_lock.py/test_journal_lock.py
@@ -1,33 +1,4 @@
-"""
-Tests for journal_lock.py code.
-
-Tests:
- - Is file actually locked after obtain_lock().  Problem: We opened the
-    file in a manner which means nothing else can open it.  Also I assume
-    that the same process will either be allowed to lock it 'again' or
-    overwrite the lock.
-
-    Expected failures if:
-
-     1. Lock already held (elsewhere).
-     2. Can't open lock file 'w+'.
-     3. Path to lock file doesn't exist.
-     4. journaldir is None (default on Linux).
-
- - Does release_lock() work?  Easier to test, if it's worked....
-     1. return True if not locked.
-     2. return True if locked, but successful unlock.
-     3. return False otherwise.
-
- - JournalLock.set_path_from_journaldir
-     1. When journaldir is None.
-     2. Succeeds otherwise?
-
- - Can any string to pathlib.Path result in an invalid path for other
-   operations?
-
- - Not sure about testing JournalAlreadyLocked class.
-"""
+"""Tests for journal_lock.py code."""
 import multiprocessing as mp
 import os
 import pathlib
@@ -327,11 +298,13 @@ class TestJournalLock:
         # Now attempt to lock with to-test code
         jlock = JournalLock()
         second_attempt = jlock.obtain_lock()
-        # Fails on Linux, because flock(2) is per process, so we'd need to
-        # use multiprocessing to test this.
         assert second_attempt == JournalLockResult.ALREADY_LOCKED
-        # And need to release any handles on the lockfile
+
+        # Need to release any handles on the lockfile else the sub-process
+        # might not be able to clean up properly, and that will impact
+        # on later tests.
         jlock.journal_dir_lockfile.close()
+
         print('Telling sub-process to quit...')
         exit_q.put('quit')
         print('Waiting for sub-process...')