Esempio n. 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
Esempio n. 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
Esempio n. 3
0
 def test_eceptions_accept_many_exceptions(self):
     fun = swallow(exceptions=[SystemExit, KeyboardInterrupt])(throw_or_return)
     fun(to_raise=SystemExit)
Esempio n. 4
0
 def test_exceptions_accept_single_exception(self):
     fun = swallow(exceptions=SystemExit)(throw_or_return)
     fun(to_raise=SystemExit)
Esempio n. 5
0
 def setup(self):
     self.fun = swallow(exceptions=Exception, default='default_value')(throw_or_return)
Esempio n. 6
0
 def test_eceptions_accept_many_exceptions(self):
     fun = swallow(
         exceptions=[SystemExit, KeyboardInterrupt])(throw_or_return)
     fun(to_raise=SystemExit)
Esempio n. 7
0
 def test_exceptions_accept_single_exception(self):
     fun = swallow(exceptions=SystemExit)(throw_or_return)
     fun(to_raise=SystemExit)
Esempio n. 8
0
 def setup(self):
     self.fun = swallow(exceptions=Exception,
                        default='default_value')(throw_or_return)