Skip to content

Commit

Permalink
Ignore pickle warning for some v2 tests (#8518)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug authored Jul 8, 2024
1 parent e24b3c4 commit 8f9d810
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/test_transforms_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,15 @@ def _check_transform_sample_input_smoke(transform, input, *, adapter):


def check_transform(transform, input, check_v1_compatibility=True, check_sample_input=True):
pickle.loads(pickle.dumps(transform))
# TODO: remove this cm once https://github.com/pytorch/vision/issues/8517
# and https://github.com/pytorch/pytorch/issues/130242 are resolved.
if isinstance(transform, (transforms.RandomResizedCrop, transforms.LinearTransformation)):
cm = pytest.warns(FutureWarning, match="You are using `torch.load`")
else:
cm = contextlib.nullcontext()

with cm:
pickle.loads(pickle.dumps(transform))

output = transform(input)
assert isinstance(output, type(input))
Expand Down

0 comments on commit 8f9d810

Please sign in to comment.