Example #1
0
    def test_swallow_works_as_context_manager(self):
        with swallow(KeyError):
            raise KeyError(1)

        try:
            with swallow(KeyError):
                raise ValueError(1)
        except ValueError:
            pass
Example #2
0
    def test_swallow_works_as_context_manager(self):
        with swallow(KeyError):
            raise KeyError(1)

        try:
            with swallow(KeyError):
                raise ValueError(1)
        except ValueError:
            pass
Example #3
0
 def test_eceptions_accept_many_exceptions(self):
     fun = swallow(exceptions=[SystemExit, KeyboardInterrupt])(throw_or_return)
     fun(to_raise=SystemExit)
Example #4
0
 def test_exceptions_accept_single_exception(self):
     fun = swallow(exceptions=SystemExit)(throw_or_return)
     fun(to_raise=SystemExit)
Example #5
0
 def setup(self):
     self.fun = swallow(exceptions=Exception, default='default_value')(throw_or_return)
Example #6
0
 def test_eceptions_accept_many_exceptions(self):
     fun = swallow(
         exceptions=[SystemExit, KeyboardInterrupt])(throw_or_return)
     fun(to_raise=SystemExit)
Example #7
0
 def test_exceptions_accept_single_exception(self):
     fun = swallow(exceptions=SystemExit)(throw_or_return)
     fun(to_raise=SystemExit)
Example #8
0
 def setup(self):
     self.fun = swallow(exceptions=Exception,
                        default='default_value')(throw_or_return)