title: Comparison in Python assert statement
body: <p>After checking few python open source projects I found examples where same function have test cases with <code>assert &lt;&gt;</code> and <code>assert &lt;&gt; is True</code>.</p>
  
  <p>And I cannot find answer about best practices of using <code>assert</code> statement with and without full condition.</p>
  
  <p>For example function</p>
  
  <pre><code>def is_even(number):
      if number % 2 == 0:
          return True
      else:
          return False
  </code></pre>
  
  <p>can be tested in such way</p>
  
  <pre><code>assert is_even(6) is True 
  assert is_even(6) == True
  </code></pre>
  
  <p>but also it can be tested like</p>
  
  <pre><code>assert is_even(6)
  </code></pre>
  
  <p>And here I see problem cause if function <code>is_even</code> will be changed on</p>
  
  <pre><code>def is_even(number):
      if number % 2 == 0:
          return &lt;&gt;
      else:
          return False
  </code></pre>
  
  <p>Where <code>&lt;&gt;</code> can be changed on any number(except <code>0</code>) or non empty string - last test will pass. But this will be another function.</p>
  
  <p>I saw <a href="https://stackoverflow.com/questions/5142418/what-is-the-use-of-assert-in-python">this</a> and <a href="https://stackoverflow.com/questions/944592/best-practice-for-python-assert">this</a> SO question about assert usage but seems they don't fully cover my question.</p>
  
  <p>From another side PEP 8 <a href="https://www.python.org/dev/peps/pep-0008/" rel="nofollow noreferrer">specification</a> have such example</p>
  
  <ul>
  <li><p>Don't compare boolean values to True or False using <code>==</code></p>
  
  <pre><code>Yes:   if greeting:
  No:    if greeting == True:
  Worse: if greeting is True:
  </code></pre></li>
  </ul>
  
  <p>But is it also about <code>assert</code> usage?</p>