How to assert that a type equals a given value
<p>I am writing a test for a method and I want to validate that the method returns a specific type. However, when I try this I get an error. </p>

<pre><code>def search_emails(mail):  
  data = mail.uid('search')
  raw_email = data[0][1]  
  return raw_email
</code></pre>

<p>The type(raw_email) is: <code>&lt;class 'bytes'&gt;</code></p>

<p>When I run this test:</p>

<pre><code>def test_search_emails_returns_bytes():  
  result = email_handler.search_emails(mail)
  assert type(result) == "&lt;class 'bytes'&gt;"
</code></pre>

<p>I get this error. How can I state the assertion so the test will pass? Or is there a better way to write the test?</p>

<pre><code>E       assert &lt;class 'bytes'&gt; == "&lt;class 'bytes'&gt;"
</code></pre>