forked from vega/altair
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use singular
@deprecated
, export in utils
- The export is safe and doesn't leak to top level
- Loading branch information
1 parent
fe1917e
commit 4e7ee2a
Showing
4 changed files
with
43 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import pytest | ||
|
||
from altair.utils import AltairDeprecationWarning | ||
from altair.utils.deprecation import deprecated | ||
from altair.utils.deprecation import AltairDeprecationWarning, deprecated | ||
|
||
|
||
def test_deprecated_class(): | ||
class Dummy: | ||
def __init__(self, *args) -> None: | ||
self.args = args | ||
|
||
OldChart = deprecated("", version="", alternative="LayerChart")(Dummy) | ||
with pytest.warns(AltairDeprecationWarning, match=r"alt\.Dummy.+alt\.LayerChart"): | ||
OldChart = deprecated(version="2.0.0", alternative="LayerChart")(Dummy) | ||
|
||
with pytest.warns(AltairDeprecationWarning, match=r"altair=2\.0\.0.+LayerChart"): | ||
OldChart() | ||
|
||
|
||
def test_deprecation_decorator(): | ||
@deprecated("", version="999", alternative="12345") | ||
@deprecated(version="999", alternative="func_12345") | ||
def func(x): | ||
return x + 1 | ||
|
||
with pytest.warns( | ||
AltairDeprecationWarning, match=r"alt\.func.+altair=999.+12345 instead" | ||
AltairDeprecationWarning, match=r"altair=999.+func_12345 instead" | ||
): | ||
y = func(1) | ||
assert y == 2 |