Skip to content

Commit 0a9a71b

Browse files
committed
disable benchmark for SQLAlchemy < 1.2
1 parent 6a13b17 commit 0a9a71b

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

graphene_sqlalchemy/tests/test_batching.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import contextlib
22
import logging
33

4-
import pkg_resources
54
import pytest
65

76
import graphene
@@ -10,7 +9,7 @@
109
from ..fields import BatchSQLAlchemyConnectionField
1110
from ..types import SQLAlchemyObjectType
1211
from .models import Article, HairKind, Pet, Reporter
13-
from .utils import to_std_dicts
12+
from .utils import is_sqlalchemy_version_less_than, to_std_dicts
1413

1514

1615
class MockLoggingHandler(logging.Handler):
@@ -71,10 +70,6 @@ def resolve_reporters(self, info):
7170
return graphene.Schema(query=Query)
7271

7372

74-
def is_sqlalchemy_version_less_than(version_string):
75-
return pkg_resources.get_distribution('SQLAlchemy').parsed_version < pkg_resources.parse_version(version_string)
76-
77-
7873
if is_sqlalchemy_version_less_than('1.2'):
7974
pytest.skip('SQL batching only works for SQLAlchemy 1.2+', allow_module_level=True)
8075

graphene_sqlalchemy/tests/test_benchmark.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from graphql.backend import GraphQLCachedBackend, GraphQLCoreBackend
23

34
import graphene
@@ -6,6 +7,10 @@
67
from ..fields import BatchSQLAlchemyConnectionField
78
from ..types import SQLAlchemyObjectType
89
from .models import Article, HairKind, Pet, Reporter
10+
from .utils import is_sqlalchemy_version_less_than
11+
12+
if is_sqlalchemy_version_less_than('1.2'):
13+
pytest.skip('SQL batching only works for SQLAlchemy 1.2+', allow_module_level=True)
914

1015

1116
def get_schema():

graphene_sqlalchemy/tests/utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import pkg_resources
2+
3+
14
def to_std_dicts(value):
25
"""Convert nested ordered dicts to normal dicts for better comparison."""
36
if isinstance(value, dict):
@@ -6,3 +9,8 @@ def to_std_dicts(value):
69
return [to_std_dicts(v) for v in value]
710
else:
811
return value
12+
13+
14+
def is_sqlalchemy_version_less_than(version_string):
15+
"""Check the installed SQLAlchemy version"""
16+
return pkg_resources.get_distribution('SQLAlchemy').parsed_version < pkg_resources.parse_version(version_string)

0 commit comments

Comments
 (0)