From b650a6bbd8cdf5ef5a9af006284773a80caf97ec Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 25 Aug 2023 13:25:35 +0400 Subject: [PATCH] Fix deprecation warnings --- elasticsearch_dsl/document.py | 2 +- setup.cfg | 10 ++++++++++ setup.py | 6 +++--- tests/conftest.py | 8 ++++---- .../test_examples/test_alias_migration.py | 15 ++++++++------- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/elasticsearch_dsl/document.py b/elasticsearch_dsl/document.py index 4324742fe..5553821f6 100644 --- a/elasticsearch_dsl/document.py +++ b/elasticsearch_dsl/document.py @@ -244,7 +244,7 @@ def mget( for doc in docs ] } - results = es.mget(body, index=cls._default_index(index), **kwargs) + results = es.mget(index=cls._default_index(index), body=body, **kwargs) objs, error_docs, missing_docs = [], [], [] for doc in results["docs"]: diff --git a/setup.cfg b/setup.cfg index c4b838fee..798d7e9b5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,3 +5,13 @@ all_files = 1 [isort] profile = black + +[tool:pytest] +filterwarnings = + error + # The body parameter is no longer deprecated, see + # https://github.com/elastic/elasticsearch-py/issues/2181#issuecomment-1490932964 + ignore:The 'body' parameter is deprecated .*:DeprecationWarning + # calendar_interval was only added in Elasticsearch 7.2 and we still support Elasticsearch 7.0 + # using `default` instead of `ignore` to show it in the output as a reminder to remove it for Elasticsearch 8 + default:\[interval\] on \[date_histogram\] is deprecated, use \[fixed_interval\] or \[calendar_interval\] in the future.:elasticsearch.exceptions.ElasticsearchWarning diff --git a/setup.py b/setup.py index 42960dac1..36e0fb224 100644 --- a/setup.py +++ b/setup.py @@ -33,11 +33,11 @@ ] develop_requires = [ - "pytest>=3.0.0", + "pytest", "pytest-cov", - "pytest-mock<3.0.0", + "pytest-mock", "pytz", - "coverage<5.0.0", + "coverage", "sphinx", "sphinx_rtd_theme", ] diff --git a/tests/conftest.py b/tests/conftest.py index 8400ed013..7146cb056 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -131,8 +131,8 @@ def es_version(client): @fixture def write_client(client): yield client - client.indices.delete("test-*", ignore=404) - client.indices.delete_template("test-template", ignore=404) + client.indices.delete(index="test-*", ignore=404) + client.indices.delete_template(name="test-template", ignore=404) @fixture @@ -154,8 +154,8 @@ def data_client(client): bulk(client, DATA, raise_on_error=True, refresh=True) bulk(client, FLAT_DATA, raise_on_error=True, refresh=True) yield client - client.indices.delete("git") - client.indices.delete("flat-git") + client.indices.delete(index="git") + client.indices.delete(index="flat-git") @fixture diff --git a/tests/test_integration/test_examples/test_alias_migration.py b/tests/test_integration/test_examples/test_alias_migration.py index 611fc6911..c76e65e32 100644 --- a/tests/test_integration/test_examples/test_alias_migration.py +++ b/tests/test_integration/test_examples/test_alias_migration.py @@ -33,13 +33,14 @@ def test_alias_migration(write_client): index_name, _ = indices.popitem() # which means we can now save a document - bp = BlogPost( - _id=0, - title="Hello World!", - tags=["testing", "dummy"], - content=open(__file__).read(), - ) - bp.save(refresh=True) + with open(__file__) as f: + bp = BlogPost( + _id=0, + title="Hello World!", + tags=["testing", "dummy"], + content=f.read(), + ) + bp.save(refresh=True) assert BlogPost.search().count() == 1