Ejemplo n.º 1
0
 def test_exit(self):
     with mock.patch("sys.exit", side_effect=TestException) as mocked_exit:
         with self.assertRaises(TestException):
             cli.exit("XXX")
         mocked_exit.assert_called_once()
         args = mocked_exit.call_args[0]
         self.assertEqual(len(args), 1)
         self.assertTrue(args[0].endswith("XXX"))
Ejemplo n.º 2
0
 def test_exit(self):
     with mock.patch(
         "sys.exit", side_effect=ExceptionForTesting, autospec=True
     ) as mocked_exit:
         with pytest.raises(ExceptionForTesting):
             cli.exit("XXX")
         mocked_exit.assert_called_once()
         args = mocked_exit.call_args[0]
         assert len(args) == 1
         assert args[0].endswith("XXX")