title: Does Python provide support for Assumptions as pre-conditions?
body: <p><strong>Assumptions in Python unit tests</strong></p>
  
  <p>Does Python provide support for Assumptions to be used as pre-conditions for tests similar to those provided by <a href="https://junit.org/junit4/javadoc/4.12/org/junit/Assume.html" rel="nofollow noreferrer">JUnit with <code>assumeThat(...)</code> methods</a> for Java.</p>
  
  <p>This is important, because of the application of <a href="https://en.wikipedia.org/wiki/Hoare_logic" rel="nofollow noreferrer">Hoare Logic</a>, to quote JUnit:</p>
  
  <blockquote>
    <p><em>A set of methods useful for stating assumptions about the conditions in which a test is meaningful. A failed assumption does not mean the code is broken, but that the test provides no useful information. Assume basically means "don't run this test if these conditions don't apply". The default JUnit runner skips tests with failing assumptions. Custom runners may behave differently</em>.</p>
  </blockquote>
  
  <p>It seems that Python doesn't provide these out of the box in its <a href="https://docs.python.org/3.7/library/unittest.html" rel="nofollow noreferrer">unittest framework</a>.  I've tentatively POC my own approach by extending <code>unittest.TestCase</code>.</p>
  
  <pre><code>class LoggingTestCase(unittest.TestCase):
      def assumeTrue(self, expr: Any, msg: Any = ...) -&gt; None:
          try:
              super().assertTrue(expr, msg)
              self.test_result = TestResult.PASSED
          except AssertionError as e:
              self.test_result = TestResult.SKIPPED
              raise InvalidAssumption(e)
  </code></pre>
  
  <p>With this unittest of behaviour:</p>
  
  <pre><code>class TestLoggingTestCase(LoggingTestCase):
      def test_assumeTrue(self):
          self.assertRaises(InvalidAssumption, self.assumeTrue, False)  # Passes as expected.
          self.assertRaises(InvalidAssumption, self.assumeTrue, True)  # Fails as expected.
  </code></pre>
  
  <p>This approach seems to exhibit the correct behaviour I want, is this the best approach, is there better way to do this, or 3rd party library to use?  I'm looking for a better way than wrapping all the base assertions this way to make my own assumptions.</p>