openapi-core/tests/integration/contrib/django/conftest.py

22 lines
516 B
Python
Raw Normal View History

2021-05-02 18:32:24 +00:00
import mock
import pytest
import os
import sys
@pytest.yield_fixture(autouse=True, scope='module')
def django_setup():
directory = os.path.abspath(os.path.dirname(__file__))
django_project_dir = os.path.join(directory, 'data')
sys.path.insert(0, django_project_dir)
with mock.patch.dict(
os.environ,
{
'DJANGO_SETTINGS_MODULE': 'djangoproject.settings',
}
):
import django
django.setup()
yield
sys.path.remove(django_project_dir)