mercredi 11 novembre 2015

Python test to check instance type

I want to use unittest in python to check if a method returns object of the right class.

Every example in the web shows tests for 'type' returned.

For example, to check for <type 'list'> or <type 'type'> , we could use:

self.assertIsInstance(result, list)
self.assertIsInstance(result[0], tuple) 

What I am looking for is an example to check for <class'sqlalchemy.orm.query.Query'>

Would appreciate any help. Thankyou.

Aucun commentaire:

Enregistrer un commentaire