Codebase list python-graphene-sqlalchemy / 13597bc9-93d9-447d-a67e-274edd54b489/upstream graphene_sqlalchemy / tests / utils.py
13597bc9-93d9-447d-a67e-274edd54b489/upstream

Tree @13597bc9-93d9-447d-a67e-274edd54b489/upstream (Download .tar.gz)

utils.py @13597bc9-93d9-447d-a67e-274edd54b489/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)