mirror of
https://github.com/open-mmlab/mmengine.git
synced 2025-06-03 21:54:44 +08:00
[Fix] Fix warning capture (#1494)
This commit is contained in:
parent
f79111ecc0
commit
ba5eed8409
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user