ivankorobkov / python-inject

Python dependency injection
Apache License 2.0
671 stars 77 forks source link

Use assertRaisesRegex instead of assertRaisesRegexp to fix deprecation warnings #68

Closed tirkarthi closed 3 years ago

tirkarthi commented 3 years ago

Fixes below deprecation warnings regarding unittest assertion helper.

=========================================================================== warnings summary ===========================================================================
test/test_binder.py::TestBinder::test_bind__class_required
  /root/checked_repos/python-inject/test/test_binder.py:16: DeprecationWarning: Please use assertRaisesRegex instead.
    self.assertRaisesRegexp(InjectorException, 'Binding key cannot be None',

test/test_binder.py::TestBinder::test_bind__duplicate_binding
  /root/checked_repos/python-inject/test/test_binder.py:23: DeprecationWarning: Please use assertRaisesRegex instead.
    self.assertRaisesRegexp(InjectorException, "Duplicate binding",

test/test_binder.py::TestBinder::test_bind_constructor__constructor_required
  /root/checked_repos/python-inject/test/test_binder.py:47: DeprecationWarning: Please use assertRaisesRegex instead.
    self.assertRaisesRegexp(InjectorException, "Constructor cannot be None",

test/test_binder.py::TestBinder::test_bind_provider__provider_required
  /root/checked_repos/python-inject/test/test_binder.py:35: DeprecationWarning: Please use assertRaisesRegex instead.
    self.assertRaisesRegexp(InjectorException, "Provider cannot be None",

test/test_inject_configuration.py::TestInjectConfiguration::test_configure__already_configured
  /root/checked_repos/python-inject/test/test_inject_configuration.py:22: DeprecationWarning: Please use assertRaisesRegex instead.
    self.assertRaisesRegexp(InjectorException, 'Injector is already configured',

test/test_inject_configuration.py::TestInjectConfiguration::test_configure__runtime_binding_disabled
  /root/checked_repos/python-inject/test/test_inject_configuration.py:56: DeprecationWarning: Please use assertRaisesRegex instead.
    self.assertRaisesRegexp(InjectorException,

test/test_inject_configuration.py::TestInjectConfiguration::test_get_injector_or_die
  /root/checked_repos/python-inject/test/test_inject_configuration.py:51: DeprecationWarning: Please use assertRaisesRegex instead.
    self.assertRaisesRegexp(InjectorException, 'No injector is configured',

-- Docs: https://docs.pytest.org/en/stable/warnings.html
==================================================================== 46 passed, 7 warnings in 0.25s ====================================================================
tirkarthi commented 3 years ago

Thanks @ivankorobkov :)

ivankorobkov commented 3 years ago

I'll make a new release later today.

ivankorobkov commented 3 years ago

https://pypi.org/project/Inject/4.3.1/