From a63d75cb7f6b9716206d61ad643943a977cd147e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pacheco?= Date: Sat, 28 Sep 2024 13:10:40 -0400 Subject: [PATCH] fix test_utils.py not to xfail (#987) * fix test_utils.py not to xfail * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- tests/test_utils.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index d8d0d6c4..8f199cee 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,3 +1,5 @@ +from contextlib import nullcontext + import pytest from jwt.utils import force_bytes, from_base64url_uint, is_ssh_key, to_base64url_uint @@ -6,17 +8,18 @@ @pytest.mark.parametrize( "inputval,expected", [ - (0, b"AA"), - (1, b"AQ"), - (255, b"_w"), - (65537, b"AQAB"), - (123456789, b"B1vNFQ"), - pytest.param(-1, "", marks=pytest.mark.xfail(raises=ValueError)), + (0, nullcontext(b"AA")), + (1, nullcontext(b"AQ")), + (255, nullcontext(b"_w")), + (65537, nullcontext(b"AQAB")), + (123456789, nullcontext(b"B1vNFQ")), + (-1, pytest.raises(ValueError)), ], ) def test_to_base64url_uint(inputval, expected): - actual = to_base64url_uint(inputval) - assert actual == expected + with expected as e: + actual = to_base64url_uint(inputval) + assert actual == e @pytest.mark.parametrize(