def __init__(self, *args, **kwargs): if 'deprecated_field' in kwargs: deprecate("0.0.0", "deprecated_field is deprecated for DummyClass.", "Please use non_deprecated_field instead.") kwargs['non_deprecated_field'] = kwargs.pop('deprecated_field') super().__init__(*args, **kwargs)
def test_deprecate_version(): with pytest.warns(DeprecationWarning) as deprecation_warning: deprecate("0.0.0", "message") assert "0.0.0" in str(deprecation_warning[0].message) with pytest.warns(DeprecationWarning) as deprecation_warning: deprecate("0.1.0", "message") assert "0.1.0" in str(deprecation_warning[0].message)
def test_deprecate_advice(): with pytest.warns(DeprecationWarning) as deprecation_warning: deprecate("0.0.0", message="test message", advice="use this instead") assert "use this instead" in str(deprecation_warning[0].message)
def test_deprecate_message(): with pytest.warns(DeprecationWarning) as deprecation_warning: deprecate("0.0.0", message="test message") assert "0.0.0" in str(deprecation_warning[0].message) assert "test message" in str(deprecation_warning[0].message)