
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
pytest-elasticsearch
Advanced tools
.. image:: https://raw.githubusercontent.com/ClearcodeHQ/pytest-elasticsearch/master/logo.png :width: 100px :height: 100px
.. image:: https://img.shields.io/pypi/v/pytest-elasticsearch.svg :target: https://pypi.python.org/pypi/pytest-elasticsearch/ :alt: Latest PyPI version
.. image:: https://img.shields.io/pypi/wheel/pytest-elasticsearch.svg :target: https://pypi.python.org/pypi/pytest-elasticsearch/ :alt: Wheel Status
.. image:: https://img.shields.io/pypi/pyversions/pytest-elasticsearch.svg :target: https://pypi.python.org/pypi/pytest-elasticsearch/ :alt: Supported Python Versions
.. image:: https://img.shields.io/pypi/l/pytest-elasticsearch.svg :target: https://pypi.python.org/pypi/pytest-elasticsearch/ :alt: License
This is a pytest plugin that enables you to test your code that relies on a running Elasticsearch search engine. It allows you to specify fixtures for Elasticsearch process and client.
.. warning::
This plugin requires at least version 6.0 of elasticsearch to work.
The plugin contains two fixtures:
Simply include one of these fixtures into your tests fixture list.
You can also create additional elasticsearch client and process fixtures if you'd need to:
.. code-block:: python
from pytest_elasticsearch import factories
elasticsearch_my_proc = factories.elasticsearch_proc(port=None)
elasticsearch_my = factories.elasticsearch('elasticsearch_my_proc')
.. note::
Each elasticsearch process fixture can be configured in a different way than the others through the fixture factory arguments.
Some projects are using already running Elasticsearch servers
(ie on docker instances). In order to connect to them, one would be using the
elasticsearch_nooproc
fixture.
.. code-block:: python
es_external = factories.elasticsearch('elasticsearch_nooproc')
By default the elasticsearch_nooproc
fixture would connect to elasticsearch
instance using 9300 port.
You can define your settings in three ways, it's fixture factory argument, command line option and pytest.ini configuration option. You can pick which you prefer, but remember that these settings are handled in the following order:
.. list-table:: Configuration options :header-rows: 1
Example usage:
pass it as an argument in your own fixture
.. code-block:: python
elasticsearch_proc = factories.elasticsearch_proc(
cluster_name='awsome_cluster)
specify your directory as elasticsearch_cluster_name
in your pytest.ini
file.
To do so, put a line like the following under the [pytest]
section of your pytest.ini
:
.. code-block:: ini
[pytest]
elasticsearch_cluster_name = awsome_cluster
It might happen, that the process can't be started due to lack of permissions. The files that user running tests has to have access to are:
Make sure that you either run tests as a user that has access to these files, or you give user proper permissions or add it to proper user groups.
In CI at the moment, we install elasticsearch from tar/zip archives, which do not set up additional permission restrictions, so it's not a problem on the CI/CD.
FAQs
Elasticsearch fixtures and fixture factories for Pytest.
We found that pytest-elasticsearch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.