title: In Python unittest, SystemExit: False printed even though the test ran "OK"
body: <p>I'm writing a class <code>RecurringInterval</code> which is supposed to represent periodic intervals, and tried firstly to test it as follows:</p>
  
  <pre><code>import datetime
  import dateutil.relativedelta
  import dateutil.rrule
  import dateutil.parser
  
  class RecurringInterval(object):
      def __init__(self, *args, **kwargs):
          self.period = kwargs.pop('period', None)
          assert isinstance(self.period, datetime.timedelta) or isinstance(self.period, dateutil.relativedelta.relativedelta) or (self.period is None)
          self.rrule = dateutil.rrule.rrule(*args, **kwargs)
  
      def __contains__(self, time):
          last_occurrence = self.rrule.before(time)
          return (last_occurrence &lt;= time) and (time &lt;= last_occurrence + self.period)
  
  
  if __name__ == "__main__":
      start = dateutil.parser.parse("Thu Nov 24 14:00 UTC 2016")
      recurring_interval = RecurringInterval(dateutil.rrule.DAILY, dtstart=start, count=5, period=datetime.timedelta(hours=2))
      time = dateutil.parser.parse("Thu Nov 24 15:00 UTC 2016")
      print(time in recurring_interval)
  </code></pre>
  
  <p>When run, this program prints <code>True</code> as expected.</p>
  
  <p>Next, I'd like to convert this script into a <code>unittest</code>. I made the following adaptations to the code:</p>
  
  <pre><code>import datetime
  import dateutil.relativedelta
  import dateutil.rrule
  import dateutil.parser
  import unittest
  
  class RecurringInterval(object):
      def __init__(self, *args, **kwargs):
          self.period = kwargs.pop('period', None)
          assert isinstance(self.period, datetime.timedelta) or isinstance(self.period, dateutil.relativedelta.relativedelta) or (self.period is None)
          self.rrule = dateutil.rrule.rrule(*args, **kwargs)
  
      def __contains__(self, time):
          last_occurrence = self.rrule.before(time)
          return (last_occurrence &lt;= time) and (time &lt;= last_occurrence + self.period)
  
  class TestRecurringInterval(unittest.TestCase):
      def test_contains_method_for_primary_interval(self):
          start = dateutil.parser.parse("Thu Nov 24 14:00 UTC 2016")
          recurring_interval = RecurringInterval(dateutil.rrule.DAILY, dtstart=start, period=datetime.timedelta(hours=2))
          time = dateutil.parser.parse("Thu Nov 25 15:00 UTC 2016")
          self.assertTrue(time in recurring_interval)
  
  if __name__ == "__main__":
      unittest.main()
  </code></pre>
  
  <p>However, when I run this I get an exception:</p>
  
  <pre><code>In [24]: exec(open('recurring_interval.py').read())
  .
  ----------------------------------------------------------------------
  Ran 1 test in 0.002s
  
  OK
  An exception has occurred, use %tb to see the full traceback.
  
  SystemExit: False
  
  /usr/local/lib/python3.5/dist-packages/IPython/core/interactiveshell.py:2889: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
    warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
  </code></pre>
  
  <p>The traceback reads as follows:</p>
  
  <pre><code>In [25]: %tb
  ---------------------------------------------------------------------------
  SystemExit                                Traceback (most recent call last)
  &lt;ipython-input-24-ab8976376637&gt; in &lt;module&gt;()
  ----&gt; 1 exec(open('recurring_interval.py').read())
  
  &lt;string&gt; in &lt;module&gt;()
  
  /usr/lib/python3.5/unittest/main.py in __init__(self, module, defaultTest, argv, testRunner, testLoader, exit, verbosity, failfast, catchbreak, buffer, warnings, tb_locals)
       92         self.progName = os.path.basename(argv[0])
       93         self.parseArgs(argv)
  ---&gt; 94         self.runTests()
       95 
       96     def usageExit(self, msg=None):
  
  /usr/lib/python3.5/unittest/main.py in runTests(self)
      255         self.result = testRunner.run(self.test)
      256         if self.exit:
  --&gt; 257             sys.exit(not self.result.wasSuccessful())
      258 
      259 main = TestProgram
  
  SystemExit: False
  </code></pre>
  
  <p>What is causing this exception? Are the tests not running successfully?</p>