예제 #1
0
def test_replacement_and_action():
    expected = "Use only one of 'replacement' and 'action'"
    with pytest.raises(ValueError, match=expected):
        _deprecate.deprecate("Old thing",
                             10,
                             replacement="new thing",
                             action="Upgrade to new thing")
예제 #2
0
def test_no_replacement_or_action():
    expected = (
        r"Old thing is deprecated and will be removed in Pillow 10 \(2023-07-01\)"
    )
    with pytest.warns(DeprecationWarning, match=expected):
        _deprecate.deprecate("Old thing", 10)
예제 #3
0
def test_action(action):
    expected = (
        r"Old thing is deprecated and will be removed in Pillow 10 \(2023-07-01\)\. "
        r"Upgrade to new thing\.")
    with pytest.warns(DeprecationWarning, match=expected):
        _deprecate.deprecate("Old thing", 10, action=action)
예제 #4
0
def test_plural():
    expected = (
        r"Old things are deprecated and will be removed in Pillow 10 \(2023-07-01\)\. "
        r"Use new thing instead\.")
    with pytest.warns(DeprecationWarning, match=expected):
        _deprecate.deprecate("Old things", 10, "new thing", plural=True)
예제 #5
0
def test_old_version(deprecated, plural, expected):
    expected = r""
    with pytest.raises(RuntimeError, match=expected):
        _deprecate.deprecate(deprecated, 1, plural=plural)
예제 #6
0
def test_unknown_version():
    expected = r"Unknown removal version, update PIL\._deprecate\?"
    with pytest.raises(ValueError, match=expected):
        _deprecate.deprecate("Old thing", 12345, "new thing")
예제 #7
0
def test_version(version, expected):
    with pytest.warns(DeprecationWarning, match=expected):
        _deprecate.deprecate("Old thing", version, "new thing")