Python test to check instance type

后端 未结 2 1299
执笔经年
执笔经年 2021-02-06 22:53

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,

2条回答
  •  半阙折子戏
    2021-02-06 23:03

    This should work:

    self.assertIsInstance(result, sqlalchemy.orm.query.Query)
    

    You need to have import sqlalchemy in the file.

提交回复
热议问题