From 264ada9efb7635af8411c394e86ae39045cd3100 Mon Sep 17 00:00:00 2001 From: nijkah Date: Fri, 25 Mar 2022 00:41:48 +0000 Subject: [PATCH] add pytest for modify_args --- tests/test_utils/test_modify_args.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/test_utils/test_modify_args.py diff --git a/tests/test_utils/test_modify_args.py b/tests/test_utils/test_modify_args.py new file mode 100644 index 0000000000..476eff4a37 --- /dev/null +++ b/tests/test_utils/test_modify_args.py @@ -0,0 +1,19 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import argparse +from unittest.mock import patch + +from mmedit.utils import modify_args + + +def test_modify_args(): + + def _parse_args(): + parser = argparse.ArgumentParser(description='Generation demo') + parser.add_argument('--config-path', help='test config file path') + args = parser.parse_args() + return args + + with patch('argparse._sys.argv', ['test.py', '--config_path=config.py']): + modify_args() + args = _parse_args() + assert args.config_path == 'config.py'