Skip to content

Commit 5342f51

Browse files
committed
Add get_config and get_model test
1 parent 45221f8 commit 5342f51

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

tests/test_config/test_collect_meta.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
from mmengine.config.collect_meta import (_get_external_cfg_base_path,
77
_parse_external_cfg_path,
8-
_parse_rel_cfg_path)
8+
_parse_cfg_name)
99

1010

1111
def test_get_external_cfg_base_path(tmp_path):
1212
package_path = tmp_path
1313
rel_cfg_path = 'cfg_dir/cfg_file'
1414
with pytest.raises(FileNotFoundError):
1515
_get_external_cfg_base_path(str(package_path), rel_cfg_path)
16-
cfg_dir = tmp_path / '.mmengine' / 'configs' / 'cfg_dir'
16+
cfg_dir = tmp_path / '.mim' / 'configs' / 'cfg_dir'
1717
cfg_dir.mkdir(parents=True, exist_ok=True)
1818
f = open(cfg_dir / 'cfg_file', 'w')
1919
f.close()
@@ -22,20 +22,20 @@ def test_get_external_cfg_base_path(tmp_path):
2222

2323

2424
def test_parse_external_cfg_path():
25-
external_cfg_path = 'package::path/cfg'
25+
external_cfg_path = 'mmdet::path/cfg'
2626
package, rel_cfg_path = _parse_external_cfg_path(external_cfg_path)
27-
assert package == 'package'
27+
assert package == 'mmdet'
2828
assert rel_cfg_path == 'path/cfg'
2929
# external config must contain `::`.
3030
external_cfg_path = 'path/cfg'
3131
with pytest.raises(ValueError):
3232
_parse_external_cfg_path(external_cfg_path)
3333
# Use `:::` as operator will raise an error.
34-
external_cfg_path = 'package:::path/cfg'
34+
external_cfg_path = 'mmdet:::path/cfg'
3535
with pytest.raises(ValueError):
3636
_parse_external_cfg_path(external_cfg_path)
3737
# Use `:` as operator will raise an error.
38-
external_cfg_path = 'package:path/cfg'
38+
external_cfg_path = 'mmdet:path/cfg'
3939
with pytest.raises(ValueError):
4040
_parse_external_cfg_path(external_cfg_path)
4141
# Too much `::`
@@ -46,8 +46,5 @@ def test_parse_external_cfg_path():
4646

4747
def test_parse_rel_cfg_path():
4848
rel_cfg_path = 'cfg_dir/cfg_file'
49-
rel_cfg_dir, rel_cfg_file = _parse_rel_cfg_path(rel_cfg_path)
50-
assert rel_cfg_dir == 'cfg_dir'
51-
assert rel_cfg_file == 'cfg_file'
52-
with pytest.raises(AssertionError):
53-
_parse_rel_cfg_path('error/cfg_dir/cfg_file')
49+
cfg_name = _parse_cfg_name(rel_cfg_path)
50+
assert cfg_name == 'cfg_file'

0 commit comments

Comments
 (0)