Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c42f1e1

Browse files
committedSep 8, 2019
Add pytest-benchmark and port introspectionFromSchema-benchmark.js
1 parent da6d040 commit c42f1e1

File tree

8 files changed

+13206
-78
lines changed

8 files changed

+13206
-78
lines changed
 

‎poetry.lock

Lines changed: 23 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ python = "^3.6"
3333
[tool.poetry.dev-dependencies]
3434
pytest = "^5"
3535
pytest-asyncio = ">=0.10"
36+
pytest-benchmark = "^3.2"
3637
pytest-cov = "^2.7"
3738
pytest-describe = ">=0.12"
3839
pyyaml = "^5.1"

‎setup.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ python-tag = py3
33

44
[aliases]
55
test = pytest
6+
7+
[tool:pytest]
8+
# Only run benchmarks as tests.
9+
# To actually run the benchmarks, use --benchmark-enable on the command line.
10+
addopts = --benchmark-disable

‎tests/benchmarks/__init__.py

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from graphql import build_schema, parse, execute
2+
from graphql.utilities import introspection_query
3+
4+
# noinspection PyUnresolvedReferences
5+
from ..fixtures import big_schema_sdl # noqa: F401
6+
7+
8+
def test_executing_introspection_query(benchmark, big_schema_sdl): # noqa: F811
9+
schema = build_schema(big_schema_sdl)
10+
query = parse(introspection_query.get_introspection_query())
11+
result = benchmark(lambda: execute(schema, query))
12+
assert result.errors is None

‎tests/fixtures/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from pytest import fixture # type: ignore
66

7-
__all__ = ["kitchen_sink_query", "kitchen_sink_sdl"]
7+
__all__ = ["kitchen_sink_query", "kitchen_sink_sdl", "big_schema_sdl"]
88

99

1010
def read_graphql(name):
@@ -20,3 +20,8 @@ def kitchen_sink_query():
2020
@fixture(scope="module")
2121
def kitchen_sink_sdl():
2222
return read_graphql("schema_kitchen_sink")
23+
24+
25+
@fixture(scope="module")
26+
def big_schema_sdl():
27+
return read_graphql("github_schema")

‎tests/fixtures/github_schema.graphql

Lines changed: 13158 additions & 0 deletions
Large diffs are not rendered by default.

‎tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ setenv =
3939
deps =
4040
pytest>=5.0,<6
4141
pytest-asyncio>=0.10
42+
pytest-benchmark>=3.2,<4
4243
pytest-cov>=2.7,<3
4344
pytest-describe>=0.12
4445
commands =

0 commit comments

Comments
 (0)
Please sign in to comment.