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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 24 deletions

View file

@ -571,7 +571,7 @@ class TestExportImport(
with self.assertRaises(CommandError) as e:
call_command(*args)
self.assertEqual("That path isn't a directory", str(e))
self.assertEqual("That path doesn't exist", str(e.exception))
def test_export_target_exists_but_is_file(self):
"""
@ -589,7 +589,7 @@ class TestExportImport(
with self.assertRaises(CommandError) as e:
call_command(*args)
self.assertEqual("That path isn't a directory", str(e))
self.assertEqual("That path isn't a directory", str(e.exception))
def test_export_target_not_writable(self):
"""
@ -608,7 +608,10 @@ class TestExportImport(
with self.assertRaises(CommandError) as e:
call_command(*args)
self.assertEqual("That path doesn't appear to be writable", str(e))
self.assertEqual(
"That path doesn't appear to be writable",
str(e.exception),
)
def test_no_archive(self):
"""