-
-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy path__init__.py
56 lines (38 loc) · 1.17 KB
/
__init__.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Fixtures for graphql tests"""
import json
from gc import collect
from pathlib import Path
import pytest
__all__ = [
"big_schema_introspection_result",
"big_schema_sdl",
"cleanup",
"kitchen_sink_query",
"kitchen_sink_sdl",
]
def cleanup(rounds=5):
"""Run garbage collector.
This can be used to remove coroutines that were not awaited after running tests.
"""
for _generation in range(rounds):
collect()
def read_graphql(name):
path = (Path(__file__).parent / name).with_suffix(".graphql")
with path.open(encoding="utf-8") as file:
return file.read()
def read_json(name):
path = (Path(__file__).parent / name).with_suffix(".json")
with path.open(encoding="utf-8") as file:
return json.load(file)
@pytest.fixture(scope="module")
def kitchen_sink_query():
return read_graphql("kitchen_sink")
@pytest.fixture(scope="module")
def kitchen_sink_sdl():
return read_graphql("schema_kitchen_sink")
@pytest.fixture(scope="module")
def big_schema_sdl():
return read_graphql("github_schema")
@pytest.fixture(scope="module")
def big_schema_introspection_result():
return read_json("github_schema")