Skip to content

Commit

Permalink
disable benchmark for SQLAlchemy < 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jnak committed Jan 24, 2020
1 parent 6a13b17 commit 0a9a71b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 1 addition & 6 deletions graphene_sqlalchemy/tests/test_batching.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import contextlib
import logging

import pkg_resources
import pytest

import graphene
Expand All @@ -10,7 +9,7 @@
from ..fields import BatchSQLAlchemyConnectionField
from ..types import SQLAlchemyObjectType
from .models import Article, HairKind, Pet, Reporter
from .utils import to_std_dicts
from .utils import is_sqlalchemy_version_less_than, to_std_dicts


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


def is_sqlalchemy_version_less_than(version_string):
return pkg_resources.get_distribution('SQLAlchemy').parsed_version < pkg_resources.parse_version(version_string)


if is_sqlalchemy_version_less_than('1.2'):
pytest.skip('SQL batching only works for SQLAlchemy 1.2+', allow_module_level=True)

Expand Down
5 changes: 5 additions & 0 deletions graphene_sqlalchemy/tests/test_benchmark.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
from graphql.backend import GraphQLCachedBackend, GraphQLCoreBackend

import graphene
Expand All @@ -6,6 +7,10 @@
from ..fields import BatchSQLAlchemyConnectionField
from ..types import SQLAlchemyObjectType
from .models import Article, HairKind, Pet, Reporter
from .utils import is_sqlalchemy_version_less_than

if is_sqlalchemy_version_less_than('1.2'):
pytest.skip('SQL batching only works for SQLAlchemy 1.2+', allow_module_level=True)


def get_schema():
Expand Down
8 changes: 8 additions & 0 deletions graphene_sqlalchemy/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import pkg_resources


def to_std_dicts(value):
"""Convert nested ordered dicts to normal dicts for better comparison."""
if isinstance(value, dict):
Expand All @@ -6,3 +9,8 @@ def to_std_dicts(value):
return [to_std_dicts(v) for v in value]
else:
return value


def is_sqlalchemy_version_less_than(version_string):
"""Check the installed SQLAlchemy version"""
return pkg_resources.get_distribution('SQLAlchemy').parsed_version < pkg_resources.parse_version(version_string)

0 comments on commit 0a9a71b

Please sign in to comment.