Skip to content
Snippets Groups Projects
Unverified Commit b8e7c8ee authored by Mashiro's avatar Mashiro Committed by GitHub
Browse files

Fix test_auto_argparse when pytest has multiple arguments (#34)

parent e908959c
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,6 @@ import copy
import os
import os.path as osp
import platform
import re
import shutil
import sys
import tempfile
......@@ -26,6 +25,11 @@ DELETE_KEY = '_delete_'
DEPRECATION_KEY = '_deprecation_'
RESERVED_KEYS = ['filename', 'text', 'pretty_text']
if platform.system() == 'Windows':
import regex as re
else:
import re # type: ignore
class ConfigDict(Dict):
"""A dictionary for config which has the same interface as python's built-
......
# Copyright (c) OpenMMLab. All rights reserved.
from mmcv import Config # isort:skip
from mmengine import Config # isort:skip
cfg = Config.fromfile('tests/data/config/py_config/simple_config.py')
item5 = cfg.item1[0] + cfg.item2.a
......@@ -169,7 +169,9 @@ class TestConfig:
cfg.merge_from_dict(input_options, allow_list_keys=True)
def test_auto_argparser(self):
tmp = sys.argv[1]
# Temporarily make sys.argv only has one argument and keep backups
tmp = sys.argv[1:]
sys.argv = sys.argv[:2]
sys.argv[1] = osp.join(
self.data_path,
'config/py_config/test_merge_from_multiple_bases.py')
......@@ -181,7 +183,7 @@ class TestConfig:
assert not getattr(args, key)
# TODO currently do not support nested keys, bool args will be
# overwritten by int
sys.argv[1] = tmp
sys.argv.extend(tmp)
def test_dump(self, tmp_path):
file_path = 'config/py_config/test_merge_from_multiple_bases.py'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment