[Fix] Fix warning capture ()

pull/1496/head
fanqiNO1 2024-02-18 14:17:35 +08:00 committed by GitHub
parent f79111ecc0
commit ba5eed8409
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions
tests/test_utils/test_dl_utils

View File

@ -1,5 +1,6 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import warnings
import torch
from mmengine.utils.dl_utils import torch_meshgrid
@ -7,9 +8,8 @@ from mmengine.utils.dl_utils import torch_meshgrid
def test_torch_meshgrid():
# torch_meshgrid should not throw warning
with pytest.warns(None) as record:
with warnings.catch_warnings():
warnings.simplefilter('error')
x = torch.tensor([1, 2, 3])
y = torch.tensor([4, 5, 6])
grid_x, grid_y = torch_meshgrid(x, y)
assert len(record) == 0