From ba5eed8409d51a7af608ec3d1a300f1dd352906b Mon Sep 17 00:00:00 2001 From: fanqiNO1 <75657629+fanqiNO1@users.noreply.github.com> Date: Sun, 18 Feb 2024 14:17:35 +0800 Subject: [PATCH] [Fix] Fix warning capture (#1494) --- tests/test_utils/test_dl_utils/test_torch_ops.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_utils/test_dl_utils/test_torch_ops.py b/tests/test_utils/test_dl_utils/test_torch_ops.py index 9fffaf7f53..03e5decf0d 100644 --- a/tests/test_utils/test_dl_utils/test_torch_ops.py +++ b/tests/test_utils/test_dl_utils/test_torch_ops.py @@ -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 @@ 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