Codebase list python-graphene-sqlalchemy / a71e89fa-1625-49b6-9344-235718634cd2/upstream graphene_sqlalchemy / tests / utils.py
a71e89fa-1625-49b6-9344-235718634cd2/upstream

Tree @a71e89fa-1625-49b6-9344-235718634cd2/upstream (Download .tar.gz)

utils.py @a71e89fa-1625-49b6-9344-235718634cd2/upstreamraw · history · blame

import pkg_resources


def to_std_dicts(value):
    """Convert nested ordered dicts to normal dicts for better comparison."""
    if isinstance(value, dict):
        return {k: to_std_dicts(v) for k, v in value.items()}
    elif isinstance(value, list):
        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)