1. You end up either inverting the sense of a `coverage_conditional_plugin`
pragma's name (versus what it actually tests), *or* where you put it in
the code.
2. As the pragmas are only defined in once, in one place, it's better to
invert the sense there, rather than in *every single use case*.
Then technically any 'other' branch isn't guaranteed to
* Always report on coverage, if no tests failed.
* Remove `.coveragerc`, in favour of `pyproject.toml`.
* Use `coverage-conditional-plugin`:
- Two rules added, `sys-platform-win32` and `sys-platform-not-win32`.
- Those rules used so non-win32 code run on win32 doesn't cause coverage
to be reported as less than 100%.
There's the assumption that !win32 means Linux, probably.
* Set `tmpdir` properly for this test.
* Do **NOT** unset `JournalLock.journal_dir_lockfile_name` on release, as
this is needed to remove the file
* Ensure prior test(s) release their locks, *and* remove the file.
* Some `# pragma: no cover' added where it's more pain to get coverage
than to put up with lack of testing.
We are choosing to NOT test retry_lock() or the call to it from
update_lock() as it's tkinter stuff.
* Check `self.journal_dir_lockfile` exists before trying to call
.close() on it.
* Note where platform checks means only one if branch gets run, so of
course coverage will complain about the other one.
* Add test_release_lock_lie_locked() to test when not locked, but
pretend we were so release_lock() returns False.
* Add test_update_lock_same() to check if an attempt is made to 'update'
to the same directory.
This splits the code for opening the lockfile away from that for
actually obtaining the lock. It enables a test for trying to lock again
with the same file handle.
* If it's None then set journal_dir_path to None as well. Setting '' or
nothing results in '.' (CWD), which could cause other issues.
* As we do this in three places, it's in a helper function.
* New JournalLockResult.JOURNALDIR_IS_NONE to signal this.
* Fix checking of return from obtain_lock() to specifically reference
JournalLockResult.ALREADY_LOCKED.
This way we can tell the difference between:
1. This process obtained the lock.
2. Another process has the lock.
3. We couldn't get the lock due to not being able to open the lock file
read-write.
Case 3 is currently also returned if the configured journal directory
doesn't exist. This will be the case on any MacOS system that never had
the game running. Likely given the OS hasn't been supported for the
game in years now.
# Conflicts:
# EDMarketConnector.py
* If it's None then set journal_dir_path to None as well. Setting '' or
nothing results in '.' (CWD), which could cause other issues.
* As we do this in three places, it's in a helper function.
* New JournalLockResult.JOURNALDIR_IS_NONE to signal this.
* Fix checking of return from obtain_lock() to specifically reference
JournalLockResult.ALREADY_LOCKED.
In the scenario of the default Journals location not even existing the
user needs might update it to a network mount. When they do so we
attempt, and fail, to unlock the old location, despite it not being
locked.
So now we have this boolean so we know if we should even attempt
unlocking.
This way we can tell the difference between:
1. This process obtained the lock.
2. Another process has the lock.
3. We couldn't get the lock due to not being able to open the lock file
read-write.
Case 3 is currently also returned if the configured journal directory
doesn't exist. This will be the case on any MacOS system that never had
the game running. Likely given the OS hasn't been supported for the
game in years now.
I'd `git show develop:journal_lock.py > journal_lock.py` a copy in
before, but forgot to commit it, and then removed it when checking out
another branch complained. D'oh!