Modify tests to use assertWarnsOnceRegex instead of maybeWarnsRegex (#52387)

Summary:
Related to https://github.com/pytorch/pytorch/issues/50006

Follow on for https://github.com/pytorch/pytorch/issues/48560 to ensure TORCH_WARN_ONCE warnings are caught. Most of this is straight-forward find-and-replace, but I did find one place where the TORCH_WARN_ONCE warning was not wrapped into a python warning.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/52387

Reviewed By: albanD

Differential Revision: D26773387

Pulled By: mruberry

fbshipit-source-id: 5be7efbc8ab4a32ec8437c9c45f3b6c3c328f5dd
This commit is contained in:
mattip
2021-03-08 03:30:11 -08:00
committed by Facebook GitHub Bot
parent d3cde6c23c
commit 54a2498919
10 changed files with 82 additions and 88 deletions

View File

@ -710,9 +710,8 @@ class TestFFT(TestCase):
else:
window = None
if expected_error is None:
with self.maybeWarnsRegex(UserWarning, "stft with return_complex=False"):
result = x.stft(n_fft, hop_length, win_length, window,
center=center, return_complex=False)
result = x.stft(n_fft, hop_length, win_length, window,
center=center, return_complex=False)
# NB: librosa defaults to np.complex64 output, no matter what
# the input dtype
ref_result = librosa_stft(x, n_fft, hop_length, win_length, window, center)