Skip to content

Commit

Permalink
Disable pytorch stub tests if version >=2.4 (#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
mauvilsa authored Sep 17, 2024
1 parent 975803f commit 6300b8c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions jsonargparse_tests/test_stubs_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,18 @@ def test_get_params_complex_function_requests_get(parser):


if torch_available:
import torch.optim # pylint: disable=import-error
import torch.optim.lr_scheduler # pylint: disable=import-error
import pkg_resources

if tuple(int(v) for v in torch.__version__.split(".", 2)[:2]) < (2, 1):
torch_version = tuple(int(v) for v in pkg_resources.get_distribution("torch").version.split(".", 2)[:2])

if torch_version < (2, 1) or torch_version >= (2, 4):
torch_available = False
else:
import torch.optim # pylint: disable=import-error
import torch.optim.lr_scheduler # pylint: disable=import-error


@pytest.mark.skipif(not torch_available, reason="torch>=2.1 package is required")
@pytest.mark.skipif(not torch_available, reason="only for torch>=2.1,<2.4")
@pytest.mark.parametrize(
"class_name",
[
Expand All @@ -279,7 +283,7 @@ def test_get_params_torch_optimizer(class_name):
assert any(p.annotation is inspect._empty for p in params)


@pytest.mark.skipif(not torch_available, reason="torch>=2.1 package is required")
@pytest.mark.skipif(not torch_available, reason="only for torch>=2.1,<2.4")
@pytest.mark.parametrize(
"class_name",
[
Expand Down

0 comments on commit 6300b8c

Please sign in to comment.