Skip to content
Snippets Groups Projects
Commit baf0ad8b authored by jan.bednarik's avatar jan.bednarik
Browse files

Pytest fixture for automatic test indices in Elasticsearch.

parent df2a497f
No related branches found
No related tags found
No related merge requests found
from elasticsearch import Elasticsearch
import os
import pytest
from django_elasticsearch_dsl.test import ESTestCase
@pytest.fixture(scope='session')
def es():
"""Elasticsearch client."""
es_dsn = os.environ.get('ELASTICSEARCH_DSN', 'http://localhost:9200')
es_client = Elasticsearch(es_dsn)
yield es_client
es_client.indices.delete('test_*')
class DummyTestCase:
def setUp(self):
pass
def tearDown(self):
pass
class TestCase(ESTestCase, DummyTestCase):
pass
@pytest.fixture
def django_es():
"""Setup and teardown of test indices."""
testCase = TestCase()
testCase.setUp()
yield
testCase.tearDown()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment