diff --git a/pygmt/helpers/decorators.py b/pygmt/helpers/decorators.py index e6b87180cd1..eb3383f328d 100644 --- a/pygmt/helpers/decorators.py +++ b/pygmt/helpers/decorators.py @@ -567,16 +567,13 @@ def new_module(*args, **kwargs): ) warnings.warn(msg, category=SyntaxWarning, stacklevel=2) - # timestamp (U) is deprecated since v0.9.0. + # timestamp (U) is deprecated since v0.9.0 and removed in v0.12.0. if "U" in kwargs or "timestamp" in kwargs: - if "timestamp" in kwargs: - kwargs["U"] = kwargs.pop("timestamp") msg = ( - "Parameters 'U' and 'timestamp' are deprecated since v0.9.0 " - "and will be removed in v0.12.0. " + "Parameters 'U' and 'timestamp' are no longer supported since v0.12.0. " "Use Figure.timestamp() instead." ) - warnings.warn(msg, category=SyntaxWarning, stacklevel=2) + raise GMTInvalidInput(msg) # xshift (X) is deprecated since v0.8.0. if "X" in kwargs or "xshift" in kwargs: diff --git a/pygmt/tests/test_timestamp.py b/pygmt/tests/test_timestamp.py index 3a5e9506574..0d7f42493c2 100644 --- a/pygmt/tests/test_timestamp.py +++ b/pygmt/tests/test_timestamp.py @@ -2,7 +2,8 @@ Test Figure.timestamp. """ import pytest -from pygmt import Figure, config +from pygmt import Figure +from pygmt.exceptions import GMTInvalidInput @pytest.fixture(scope="module", name="faketime") @@ -95,36 +96,16 @@ def test_timestamp_text_truncated(): return fig -@pytest.mark.mpl_image_compare(filename="test_timestamp.png") -def test_timestamp_deprecated_timestamp(faketime): - """ - Check if the deprecated parameter 'timestamp' works but raises a warning. +def test_timestamp_unsupported_u_timestamp(): """ - fig = Figure() - with pytest.warns(expected_warning=SyntaxWarning) as record: - with config(FORMAT_TIME_STAMP=faketime): - # plot nothing (the data is outside the region) but a timestamp - fig.plot( - x=0, - y=0, - style="p", - projection="X1c", - region=[1, 2, 1, 2], - timestamp=True, - ) - assert len(record) == 1 # check that only one warning was raised - return fig + Raise an exception when either U or timestamp is used. - -@pytest.mark.mpl_image_compare(filename="test_timestamp.png") -def test_timestamp_deprecated_u(faketime): - """ - Check if the deprecated parameter 'U' works but raises a warning. + Parameters U and timestamp are no longer supported since v0.12.0. """ fig = Figure() - with pytest.warns(expected_warning=SyntaxWarning) as record: - with config(FORMAT_TIME_STAMP=faketime): - # plot nothing (the data is outside the region) but a timestamp - fig.plot(x=0, y=0, style="p", projection="X1c", region=[1, 2, 1, 2], U=True) - assert len(record) == 1 # check that only one warning was raised - return fig + with pytest.raises(GMTInvalidInput): + fig.plot(x=0, y=0, style="p", projection="X1c", region=[1, 2, 1, 2], U=True) + with pytest.raises(GMTInvalidInput): + fig.plot( + x=0, y=0, style="p", projection="X1c", region=[1, 2, 1, 2], timestamp=True + )