def test_parse_args_invalid(argv): def mock_error(*args): """Prevent argparse from calling sys.exit()""" raise AssertionError(*args) error_patch = unittest.mock.patch.object(argparse.ArgumentParser, 'error', mock_error) with error_patch: with pytest.raises(AssertionError): gen_dockerfile.parse_args(argv)
def test_parse_args_invalid(argv): def mock_error(*args): """Prevent argparse from calling sys.exit()""" raise AssertionError(*args) error_patch = unittest.mock.patch.object( argparse.ArgumentParser, 'error', mock_error) with error_patch: with pytest.raises(AssertionError): gen_dockerfile.parse_args(argv)
def test_parse_args_config(argv, env, expected): if env is None: mock_environ = {} else: mock_environ = {gen_dockerfile.GAE_APPLICATION_YAML_PATH: env} with unittest.mock.patch.dict('os.environ', mock_environ, clear=True): args = gen_dockerfile.parse_args(argv) assert args.config == expected
def test_parse_args_valid(argv): args = gen_dockerfile.parse_args(argv) assert args is not None