Ejemplo n.º 1
0
    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())
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)