freedomofpress / dangerzone

Take potentially dangerous PDFs, office documents, or images and convert them to safe PDFs
https://dangerzone.rocks/
GNU Affero General Public License v3.0
3.36k stars 153 forks source link

Fix pytest warnings in CI #796

Closed naglis closed 1 month ago

naglis commented 2 months ago

Currently, pytest issues 3 warnings after running the tests in CI (Linux, macOS, Windows):

../.cache/pypoetry/virtualenvs/dangerzone-3aSsmiER-py3.8/lib/python3.8/site-packages/pytest_cov/plugin.py:256
  /home/circleci/.cache/pypoetry/virtualenvs/dangerzone-3aSsmiER-py3.8/lib/python3.8/site-packages/pytest_cov/plugin.py:256: PytestDeprecationWarning: The hookimpl CovPlugin.pytest_configure_node uses old-style configuration options (marks or attributes).
  Please use the pytest.hookimpl(optionalhook=True) decorator instead
   to configure the hooks.
   See https://docs.pytest.org/en/latest/deprecations.html#configuring-hook-specs-impls-using-markers
    def pytest_configure_node(self, node):

../.cache/pypoetry/virtualenvs/dangerzone-3aSsmiER-py3.8/lib/python3.8/site-packages/pytest_cov/plugin.py:265
  /home/circleci/.cache/pypoetry/virtualenvs/dangerzone-3aSsmiER-py3.8/lib/python3.8/site-packages/pytest_cov/plugin.py:265: PytestDeprecationWarning: The hookimpl CovPlugin.pytest_testnodedown uses old-style configuration options (marks or attributes).
  Please use the pytest.hookimpl(optionalhook=True) decorator instead
   to configure the hooks.
   See https://docs.pytest.org/en/latest/deprecations.html#configuring-hook-specs-impls-using-markers
    def pytest_testnodedown(self, node, error):

tests/test_settings.py::test_new_default_setting
  /home/circleci/project/tests/test_settings.py:77: PytestMockWarning: Mocks returned by pytest-mock do not need to be used as context managers. The mocker fixture automatically undoes mocking at the end of a test. This warning can be ignored if it was triggered by mocking a context manager. https://pytest-mock.readthedocs.io/en/latest/remarks.html#usage-as-context-manager
    with mocker.patch(

The first two warnings are resolved by updating pytest-cov version (this issue was resolved in pytest-cov 4.0.0, but I've bumped it to the latest (5.0.0)).

The last warning is resolved by not using mocker.patch as a context manager. There is only one such case, elsewhere (e.g.) it is already used correctly.

deeplow commented 1 month ago

(note: the CI failure seems to be a transient network error. I have now restarted the test)

apyrgio commented 1 month ago

Merged, thanks a lot!