inveniosoftware / pytest-invenio

Pytest fixtures for Invenio.
https://pytest-invenio.readthedocs.io
Other
3 stars 22 forks source link

Tests failing with celery>=5, missing pytest-celery #66

Closed ntarocco closed 2 years ago

ntarocco commented 3 years ago

Issue introduced with the commit: https://github.com/inveniosoftware/pytest-invenio/commit/4a3fe92ebc098346cabe27677e2a2201c8143569

Starting with version 5, celery requires to explicitly enable the pytest contrib/fixtures.

Tests error when using celery 5:

file /opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/pytest_invenio/fixtures.py, line 154
  @pytest.fixture(scope='module')
  def app_config(db_uri, broker_uri, celery_config_ext):
file /opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/pytest_invenio/fixtures.py, line 121
          def inner(celery_config):
E       fixture 'celery_config' not found
>       available fixtures: _configure_application, _monkeypatch_response_class, _push_request_context, accept_any, accept_json, accept_jsonp, accept_mimetype, app, app_config, app_with_mail, appctx, base_app, base_client, broker_uri, browser, bucket, bucket_from_dir, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, celery_config_ext, class_mocker, cli_runner, client, client_class, config, cov, create_app, database, db, db_uri, default_handler, doctest_namespace, entry_points, es, es_clear, example_message_factory, extra_entry_points, instance_path, item_record, json_headers, live_server, loan_params, location, mailbox, mocker, module_mocker, monkeypatch, no_cover, package_mocker, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, request_ctx, script_info, session_mocker, testdata, testdata_most_loaned, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory, users, with_access
>       use 'pytest --fixtures [testpath]' for help on them.

Solved by adding pytest-celery to the setup.py, tests dependencies.

From the documentation:

Celery initially ships the plugin in a disabled state, to enable it you can either:
* pip install celery[pytest]
* pip install pytest-celery
* or add an environment variable PYTEST_PLUGINS=celery.contrib.pytest
* or add pytest_plugins = ("celery.contrib.pytest", ) to your root conftest.py
ntarocco commented 3 years ago

Solved by https://github.com/inveniosoftware/pytest-invenio/pull/61