Skip to content

Commit 3fa940c

Browse files
committed
Add generic deprecation testing
1 parent 3190392 commit 3fa940c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/torchaudio/_internal/module_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def wrapped(*args, **kwargs):
5959

6060
return decorator
6161

62+
UNSUPPORTED = []
6263

6364
def deprecated(direction: str, version: Optional[str] = None, remove: bool = False):
6465
"""Decorator to add deprecation message
@@ -90,6 +91,7 @@ def wrapped(*args, **kwargs):
9091
{direction}
9192
"""
9293

94+
UNSUPPORTED.append(wrapped)
9395
return wrapped
9496

9597
return decorator

src/torchaudio/io/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from torchaudio._internal.module_utils import dropping_support
33

44
from ._effector import AudioEffector
5-
from ._playback import _play_audio
5+
from ._playback import play_audio as _play_audio
66

77
CodecConfig.__init__ = dropping_support(CodecConfig.__init__)
88
StreamReader.__init__ = dropping_support(StreamReader.__init__)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from torchaudio_unittest.common_utils import PytorchTestCase
2+
from torchaudio._internal.module_utils import UNSUPPORTED
3+
4+
5+
class TestDeprecations(PytorchTestCase):
6+
def test_deprecations(self):
7+
for func in UNSUPPORTED:
8+
with self.assertWarnsRegex(UserWarning, r"deprecated"):
9+
try:
10+
func()
11+
except:
12+
pass

0 commit comments

Comments
 (0)