Unverified Commit 657f03ad authored by Kai Chen's avatar Kai Chen Committed by GitHub
Browse files

replace DeprecationWarning with UserWarning (#353)

parent 79942100
...@@ -63,8 +63,7 @@ class Registry: ...@@ -63,8 +63,7 @@ class Registry:
warnings.warn( warnings.warn(
'The old API of register_module(module, force=False) ' 'The old API of register_module(module, force=False) '
'is deprecated and will be removed, please use the new API ' 'is deprecated and will be removed, please use the new API '
'register_module(name=None, force=False, module=None) instead.', 'register_module(name=None, force=False, module=None) instead.')
DeprecationWarning)
if cls is None: if cls is None:
return partial(self.deprecated_register_module, force=force) return partial(self.deprecated_register_module, force=force)
self._register_module(cls, force=force) self._register_module(cls, force=force)
......
...@@ -82,15 +82,15 @@ def test_registry(): ...@@ -82,15 +82,15 @@ def test_registry():
pass pass
# begin: test old APIs # begin: test old APIs
with pytest.warns(DeprecationWarning): with pytest.warns(UserWarning):
CATS.register_module(SphynxCat) CATS.register_module(SphynxCat)
assert CATS.get('SphynxCat').__name__ == 'SphynxCat' assert CATS.get('SphynxCat').__name__ == 'SphynxCat'
with pytest.warns(DeprecationWarning): with pytest.warns(UserWarning):
CATS.register_module(SphynxCat, force=True) CATS.register_module(SphynxCat, force=True)
assert CATS.get('SphynxCat').__name__ == 'SphynxCat' assert CATS.get('SphynxCat').__name__ == 'SphynxCat'
with pytest.warns(DeprecationWarning): with pytest.warns(UserWarning):
@CATS.register_module @CATS.register_module
class NewCat: class NewCat:
...@@ -98,11 +98,11 @@ def test_registry(): ...@@ -98,11 +98,11 @@ def test_registry():
assert CATS.get('NewCat').__name__ == 'NewCat' assert CATS.get('NewCat').__name__ == 'NewCat'
with pytest.warns(DeprecationWarning): with pytest.warns(UserWarning):
CATS.deprecated_register_module(SphynxCat, force=True) CATS.deprecated_register_module(SphynxCat, force=True)
assert CATS.get('SphynxCat').__name__ == 'SphynxCat' assert CATS.get('SphynxCat').__name__ == 'SphynxCat'
with pytest.warns(DeprecationWarning): with pytest.warns(UserWarning):
@CATS.deprecated_register_module @CATS.deprecated_register_module
class CuteCat: class CuteCat:
...@@ -110,7 +110,7 @@ def test_registry(): ...@@ -110,7 +110,7 @@ def test_registry():
assert CATS.get('CuteCat').__name__ == 'CuteCat' assert CATS.get('CuteCat').__name__ == 'CuteCat'
with pytest.warns(DeprecationWarning): with pytest.warns(UserWarning):
@CATS.deprecated_register_module(force=True) @CATS.deprecated_register_module(force=True)
class NewCat2: class NewCat2:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment