# Path: graphscale/check.py
# def isinst(obj: Any, ttype: Type, _msg: str=None) -> None:
# def invariant(condition: Any, msg: str) -> None:
# def failed(msg: str) -> NoReturn:
# 
# Path: graphscale/pent.py
# class PentContext:
#     def __init__(self, *, kvetch: Kvetch, config: PentConfig) -> None:
#         self.__kvetch = kvetch
#         self.__config = config
#         self.loader = PentLoader(self)
# 
#     def cls_from_name(self, name: str) -> Type:
#         return self.__config.get_class_from_name(name)
# 
#     @property
#     def kvetch(self) -> Kvetch:
#         return self.__kvetch
# 
#     @property
#     def config(self) -> PentConfig:
#         return self.__config
# 
#     # had to change things to nuke loader at beginning of request again
#     # @property
#     # def loader(self) -> 'PentLoader':
#     #     return self.__loader
# 
# class PentContextfulObject:
#     def __init__(self, context: PentContext) -> None:
#         self.__context = context
# 
#     @property
#     def context(self) -> PentContext:
#         return self.__context
# 
# Path: graphscale/sql.py
# class ConnectionInfo(NamedTuple):
#     host: str
#     user: str
#     password: str
#     db: str
#     charset: str = 'utf8mb4'
# 
# def pymysql_conn_from_info(conn_info: ConnectionInfo) -> pymysql.Connection:
#     return pymysql.connect(
#         host=conn_info.host,
#         user=conn_info.user,
#         password=conn_info.password,
#         db=conn_info.db,
#         charset=conn_info.charset,
#         cursorclass=pymysql.cursors.DictCursor,
#         autocommit=True,
#     )
# 
# Path: graphscale/utils.py
# def print_error(val: Any) -> None:
#     """Print value to stderr"""
#     sys.stderr.write(str(val) + '\n')


import traceback
import pymysql
import pymysql.cursors
from typing import Callable, List, Dict, Any
from graphql import GraphQLSchema, graphql
from graphscale import check
from graphscale.pent import PentContext, PentContextfulObject
from graphscale.sql import ConnectionInfo, pymysql_conn_from_info
from graphscale.utils import print_error
    is_up = None

    @staticmethod
    def get_unittest_conn_info() -> ConnectionInfo:
        return MagnusConn.get_conn_info('graphscale-unittest')

    @staticmethod
    def is_db_unittest_up() -> bool:
        """Tests to see if the unittest-mysql is up and running on the localhost
        This allows for the conditional execution of tests on the db shards in addition
        to the memory shards"""

        if MagnusConn.is_up is not None:
            return MagnusConn.is_up

        try:
            conn_info = MagnusConn.get_unittest_conn_info()
            conn = pymysql_conn_from_info(conn_info)
        except pymysql.err.OperationalError as error:
            print('Could not connect to local mysql instance:')
            print('All tests will run locally')
            print(error)
            MagnusConn.is_up = False
        else:
            MagnusConn.is_up = True
            conn.close()  # type: ignore
        return MagnusConn.is_up

    @staticmethod
    def get_conn_info(db_name: str) -> ConnectionInfo:

# Path: graphscale/check.py
# def isinst(obj: Any, ttype: Type, _msg: str=None) -> None:
# def invariant(condition: Any, msg: str) -> None:
# def failed(msg: str) -> NoReturn:
# 
# Path: graphscale/pent.py
# class PentContext:
#     def __init__(self, *, kvetch: Kvetch, config: PentConfig) -> None:
#         self.__kvetch = kvetch
#         self.__config = config
#         self.loader = PentLoader(self)
# 
#     def cls_from_name(self, name: str) -> Type:
#         return self.__config.get_class_from_name(name)
# 
#     @property
#     def kvetch(self) -> Kvetch:
#         return self.__kvetch
# 
#     @property
#     def config(self) -> PentConfig:
#         return self.__config
# 
#     # had to change things to nuke loader at beginning of request again
#     # @property
#     # def loader(self) -> 'PentLoader':
#     #     return self.__loader
# 
# class PentContextfulObject:
#     def __init__(self, context: PentContext) -> None:
#         self.__context = context
# 
#     @property
#     def context(self) -> PentContext:
#         return self.__context
# 
# Path: graphscale/sql.py
# class ConnectionInfo(NamedTuple):
#     host: str
#     user: str
#     password: str
#     db: str
#     charset: str = 'utf8mb4'
# 
# def pymysql_conn_from_info(conn_info: ConnectionInfo) -> pymysql.Connection:
#     return pymysql.connect(
#         host=conn_info.host,
#         user=conn_info.user,
#         password=conn_info.password,
#         db=conn_info.db,
#         charset=conn_info.charset,
#         cursorclass=pymysql.cursors.DictCursor,
#         autocommit=True,
#     )
# 
# Path: graphscale/utils.py
# def print_error(val: Any) -> None:
#     """Print value to stderr"""
#     sys.stderr.write(str(val) + '\n')


# Path: graphscale/test/utils.py
import traceback
import pymysql
import pymysql.cursors
from typing import Callable, List, Dict, Any
from graphql import GraphQLSchema, graphql
from graphscale import check
from graphscale.pent import PentContext, PentContextfulObject
from graphscale.sql import ConnectionInfo, pymysql_conn_from_info
from graphscale.utils import print_error

    is_up = None

    @staticmethod
    def get_unittest_conn_info() -> ConnectionInfo:
        return MagnusConn.get_conn_info('graphscale-unittest')

    @staticmethod
    def is_db_unittest_up() -> bool:
        """Tests to see if the unittest-mysql is up and running on the localhost
        This allows for the conditional execution of tests on the db shards in addition
        to the memory shards"""

        if MagnusConn.is_up is not None:
            return MagnusConn.is_up

        try:
            conn_info = MagnusConn.get_unittest_conn_info()
            conn = pymysql_conn_from_info(conn_info)
        except pymysql.err.OperationalError as error:
            print('Could not connect to local mysql instance:')
            print('All tests will run locally')
            print(error)
            MagnusConn.is_up = False
        else:
            MagnusConn.is_up = True
            conn.close()  # type: ignore
        return MagnusConn.is_up

    @staticmethod
    def get_conn_info(db_name: str) -> ConnectionInfo:

        return ConnectionInfo(