mmengine/tests/test_registry/test_default_scope.py
Mashiro 563b4bad16
[Feature] add defaut scope (#149)
* add defaut scope

* Fix docstring

* override get_current_instance method in DefaultScope

clean meta nameing

* remove default mmengine argument of DefaltScope

remove default mmengine argument of DefaltScope

remove default mmengine argument of DefaltScope

* Fix unit test

Fix unit test

* Fix example in docstring

* add explaination of DefaultScope
2022-03-28 23:14:41 +08:00

24 lines
824 B
Python

# Copyright (c) OpenMMLab. All rights reserved.
from collections import OrderedDict
import pytest
from mmengine.registry import DefaultScope
class TestDefaultScope:
def test_scope(self):
default_scope = DefaultScope.get_instance('name1', scope_name='mmdet')
assert default_scope.scope_name == 'mmdet'
# `DefaultScope.get_instance` must have `scope_name` argument.
with pytest.raises(TypeError):
DefaultScope.get_instance('name2')
def test_get_current_instance(self):
DefaultScope._instance_dict = OrderedDict()
assert DefaultScope.get_current_instance() is None
DefaultScope.get_instance('instance_name', scope_name='mmengine')
default_scope = DefaultScope.get_current_instance()
assert default_scope.scope_name == 'mmengine'