Skip to content

Fixed uncaught warnings in tests v2 #7330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 24, 2023

Conversation

vfdev-5
Copy link
Collaborator

@vfdev-5 vfdev-5 commented Feb 24, 2023

No description provided.

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @vfdev-5 !

Comment on lines +1794 to +1799
if to_tensor is transforms.ToTensor:
with pytest.warns(UserWarning, match="deprecated and will be removed"):
to_tensor = to_tensor()
else:
to_tensor = to_tensor()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit, just fyi for those kind of cases we can use something like

cm = pytest.warns(...) if ... else contextlib.nullcontext()
with cm:
    to_tensor = to_tensor()

@NicolasHug NicolasHug merged commit 01ef0a6 into pytorch:main Feb 24, 2023
@github-actions
Copy link

Hey @NicolasHug!

You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

NicolasHug added a commit to NicolasHug/vision that referenced this pull request Feb 24, 2023
facebook-github-bot pushed a commit that referenced this pull request Mar 30, 2023
Summary: Co-authored-by: Nicolas Hug <[email protected]>

Reviewed By: vmoens

Differential Revision: D44416628

fbshipit-source-id: 17a34a28d35b35692ec59997da4b027095333914
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants