def _reference_testing(self, arguments, reference): with patch("sys.stdout", new=StringIO()) as fake_stdout: with open(reference, "r") as opened_reference: with raises(SystemExit) as wrapped_exit: main(arguments) self.assertEqual(wrapped_exit.type, SystemExit) self.assertEqual(wrapped_exit.value.code, 0) self.assertEqual(fake_stdout.getvalue(), opened_reference.read())
def test_main_with_invalid_retry(self): with raises(SystemExit) as wrapped_exit: main(["--dispatch", "--retry", "1000", _TEST_DIRECTORY]) self.assertEqual(wrapped_exit.type, SystemExit) self.assertEqual(wrapped_exit.value.code, _INVALID_RETRY)
def test_main_with_invalid_timeout(self): with raises(SystemExit) as wrapped_exit: main(["--dispatch", "--timeout", "-5", _TEST_DIRECTORY]) self.assertEqual(wrapped_exit.type, SystemExit) self.assertEqual(wrapped_exit.value.code, _INVALID_TIMEOUT)
def test_main_with_not_existing_directory(self): with raises(SystemExit) as wrapped_exit: main(["tests/not-existing"]) self.assertEqual(wrapped_exit.type, SystemExit) self.assertEqual(wrapped_exit.value.code, _INVALID_DIRECTORY)