def _test_version( self, flag: str, ) -> None: with self.assertRaises( SystemExit) as se, StdRedirect.redirect() as outputs: cli_run(flag, ) self.assertEqual(0, se.exception.code) self.assertIn(__VERSION__, outputs.get_stdout()) self.assertEqual('', outputs.get_stderr())
def test_file_not_found(self) -> None: with self.assertRaises( SystemExit) as se, StdRedirect.redirect() as outputs: cli_run( 'validate', f'--config-file={resource("configurations/does-not-exist.json")}', ) self.assertEqual(1, se.exception.code) self.assertEqual('', outputs.get_stdout()) self.assertNotEqual('', outputs.get_stderr())
def test_format_mismatch(self) -> None: with self.assertRaises( SystemExit) as se, StdRedirect.redirect() as outputs: cli_run( 'validate', f'--config-file={resource("configurations/invalid.yml")}', '--config-format=json', ) self.assertEqual(1, se.exception.code) self.assertEqual('', outputs.get_stdout()) self.assertNotEqual('', outputs.get_stderr())