Development: fix unreachable code around assertRaises blocks (#11365)

* tests: general cleanup and fixes for runnning under docker

This now allows tests to be run under a locally built or production
docker image with something like:

  `docker run --rm -v $PWD:/usr/src/paperless --entrypoint=bash paperlessngx/paperless-ngx:latest -c "uv run pytest"`

Specific fixes:
- fix unreachable code around `assertRaises` blocks
- fix `assertInt` typos
- fix `str(e)` vs `str(e.exception)` issues
- skip permission-based checks when root (in a docker container)
- catch `OSError` problems when instantiating `INotify` and
  skip inotify-based tests when it's unavailable.

* Reverts most files to dev while keeping the exception assert fixes

---------

Co-authored-by: Trenton H <797416+stumpylog@users.noreply.github.com>
This commit is contained in:
Ed Bardsley
2025-11-18 10:28:43 -08:00
committed by GitHub
parent 4bf681387a
commit 36d45ecf4d
3 changed files with 26 additions and 24 deletions

View File

@@ -34,7 +34,7 @@ class TestFuzzyMatchCommand(TestCase):
"""
with self.assertRaises(CommandError) as e:
self.call_command("--ratio", "-1")
self.assertIn("The ratio must be between 0 and 100", str(e))
self.assertIn("The ratio must be between 0 and 100", str(e.exception))
def test_invalid_ratio_upper_limit(self):
"""
@@ -47,7 +47,7 @@ class TestFuzzyMatchCommand(TestCase):
"""
with self.assertRaises(CommandError) as e:
self.call_command("--ratio", "101")
self.assertIn("The ratio must be between 0 and 100", str(e))
self.assertIn("The ratio must be between 0 and 100", str(e.exception))
def test_invalid_process_count(self):
"""
@@ -60,7 +60,7 @@ class TestFuzzyMatchCommand(TestCase):
"""
with self.assertRaises(CommandError) as e:
self.call_command("--processes", "0")
self.assertIn("There must be at least 1 process", str(e))
self.assertIn("There must be at least 1 process", str(e.exception))
def test_no_matches(self):
"""