-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconftest.py
49 lines (32 loc) · 858 Bytes
/
conftest.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
# -*- coding: utf-8 -*-
"""
Global fixtures.
"""
import os
import pytest
from py_gql import build_schema
@pytest.fixture
def fixture_file():
"""
Helper to load fixture files by name.
"""
def load(name):
filepath = os.path.join(os.path.dirname(__file__), "fixtures", name)
with open(filepath, "rb") as f:
return f.read().decode("utf-8")
return load
@pytest.fixture
def starwars_schema():
from ._star_wars import StarWarsSchema
return StarWarsSchema
@pytest.fixture
def github_schema(fixture_file):
return build_schema(fixture_file("github-schema.graphql"))
@pytest.fixture
def raiser():
def factory(cls, *args, **kwargs):
assert issubclass(cls, Exception)
def _raiser(*_a, **_kw):
raise cls(*args, **kwargs)
return _raiser
return factory