I'm writing unit tests as I develop a program. I'm using SQLAlchemy for database processes, so I have a few functions like this:
def create_sqla_engine():
""" Create and return the SQLA engine """
mysql_uri = os.environ.get('MYSQL_CONNECTION_URI')
engine = sqlalchemy.create_engine(mysql_uri)
return engine
If I do print(type(engine)) I can see that the type is <class 'sqlalchemy.engine.base.Engine'>
...so I want to test if this function works by checking if the type is correct (assuming the type will be None if the create_engine call fails...)
This code is in unittests.py:
class TestDatabase(unittest.TestCase):
def test_database_create_merkle_sqla_session(self):
assert type(myprogram_database.create_sqla_engine()) is # ?
How do I check the type of a variable that is a class?
Aucun commentaire:
Enregistrer un commentaire