forked from MarcoMuellner/openapi-python-generator
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
34 lines (24 loc) · 957 Bytes
/
conftest.py
File metadata and controls
34 lines (24 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json
import shutil
from pathlib import Path
from typing import Dict
from typing import Generator
import pytest
from openapi_pydantic import OpenAPI
test_data_folder = Path(__file__).parent / "test_data"
test_data_path = test_data_folder / "test_api.json"
test_result_path = Path(__file__).parent / "test_result"
@pytest.fixture(name="json_data", scope="module")
def json_data_fixture() -> Generator[Dict, None, None]:
with open(test_data_path) as f:
yield json.load(f)
@pytest.fixture(name="model_data", scope="module")
def model_data_fixture(json_data) -> OpenAPI: # type: ignore
yield OpenAPI(**json_data)
@pytest.fixture(name="model_data_with_cleanup", scope="module")
def model_data_with_cleanup_fixture(model_data) -> OpenAPI: # type: ignore
yield model_data
# delete path test_result folder
if test_result_path.exists():
# delete folder and all subfolders
shutil.rmtree(test_result_path)