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.
This commit is contained in:
Ed Bardsley 2025-11-14 05:51:09 +00:00
parent dd6f7fad32
commit 7b220f737f
11 changed files with 103 additions and 39 deletions

View file

@ -152,6 +152,19 @@ $ ng build --configuration production
configuration. This is not ideal. But for now, make sure no settings
except for DEBUG are overridden when testing.
- Testing under docker is possible (but generally unsupported) if a
bare-metal environment cannot be setup. To run tests under docker, use
this command:
```bash
# paperless-ngx/
$ docker run --rm -i -t \
-v $PWD:/usr/src/paperless \
--entrypoint=uv paperlessngx/paperless-ngx:latest \
run pytest
```
!!! note
The line length rule E501 is generally useful for getting multiple