Skip to content

Commit

Permalink
[Fix] Fix warning capture
Browse files Browse the repository at this point in the history
  • Loading branch information
fanqiNO1 committed Feb 18, 2024
1 parent 1080312 commit 5b64bee
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tests/test_utils/test_dl_utils/test_torch_ops.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Copyright (c) OpenMMLab. All rights reserved.
import warnings

import pytest
import torch

from mmengine.utils.dl_utils import torch_meshgrid


def test_torch_meshgrid():
# torch_meshgrid should not throw warning
with warnings.catch_warnings():
warnings.simplefilter('error')
with pytest.warns(UserWarning) as record:
x = torch.tensor([1, 2, 3])
y = torch.tensor([4, 5, 6])
grid_x, grid_y = torch_meshgrid(x, y)
assert len(record) == 0

0 comments on commit 5b64bee

Please sign in to comment.