python - How to assert that a type equals a given value -
i writing test method , want validate method returns specific type. however, when try error.
def search_emails(mail): data = mail.uid('search') raw_email = data[0][1] return raw_email
the type(raw_email) is: <class 'bytes'>
when run test:
def test_search_emails_returns_bytes(): result = email_handler.search_emails(mail) assert type(result) == "<class 'bytes'>"
i error. how can state assertion test pass? or there better way write test?
e assert <class 'bytes'> == "<class 'bytes'>"
you can use is
operator check variable of specific type
my_var = 'hello world' assert type(my_var) str
Comments
Post a Comment