From 26aa584a4ee4316e8af12c8749591e1d849d2ae7 Mon Sep 17 00:00:00 2001 From: Aneesh Karve Date: Mon, 3 Jun 2024 21:07:55 -0700 Subject: [PATCH] cleaner parameterize and test names --- tests/test_bip32.py | 4 +--- tests/test_bip39.py | 4 +--- tests/test_bip85.py | 8 ++++---- tests/test_cli.py | 7 ++++--- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/test_bip32.py b/tests/test_bip32.py index 1c9fa96..29545cf 100644 --- a/tests/test_bip32.py +++ b/tests/test_bip32.py @@ -14,9 +14,7 @@ @pytest.mark.parametrize( "vector", VECTORS, - ids=[ - f"Vector-{i + 1}-{', '.join(e['chain'].keys())}" for i, e in enumerate(VECTORS) - ], + ids=lambda v: f"Vector-{VECTORS.index(v) + 1}-{' '.join(v['chain'].keys())}", ) def test_vectors_and_parse_ext_key(vector): seed = bytes.fromhex(vector["seed_hex"]) diff --git a/tests/test_bip39.py b/tests/test_bip39.py index 9df7c24..a2f8338 100644 --- a/tests/test_bip39.py +++ b/tests/test_bip39.py @@ -42,9 +42,7 @@ logger = logging.getLogger(LOGGER) -@pytest.mark.parametrize( - "language, vectors", VECTORS.items(), ids=[l for l in VECTORS.keys()] -) +@pytest.mark.parametrize("language, vectors", VECTORS.items(), ids=VECTORS.keys()) def test_vectors(language, vectors): for vector in vectors: entropy_str, mnemonic, seed, xprv = vector diff --git a/tests/test_bip85.py b/tests/test_bip85.py index 8b08f21..7ec19f4 100644 --- a/tests/test_bip85.py +++ b/tests/test_bip85.py @@ -32,7 +32,7 @@ @pytest.mark.parametrize( "vector", EXT_KEY_TO_ENTROPY, - ids=[f"Vector-{i + 1}" for i, e in enumerate(EXT_KEY_TO_ENTROPY)], + ids=[f"ext_ent-{i}" for i in range(len(EXT_KEY_TO_ENTROPY))], ) def test_entropy(vector): master = parse_ext_key(vector["master"]) @@ -80,7 +80,7 @@ def test_pwd_base85(vector): @pytest.mark.parametrize( "vector", BIP_39, - ids=[f"BIP_39-{v['mnemonic_length']}-words" for v in BIP_39], + ids=[f"BIP_39-{v['mnemonic_length']}" for v in BIP_39], ) def test_bip39_application(vector): master = parse_ext_key(vector["master"]) @@ -98,7 +98,7 @@ def test_bip39_application(vector): @pytest.mark.parametrize( "vector", BIP_39, - ids=[f"BIP_39-{v['mnemonic_length']}-words" for v in BIP_39], + ids=[f"BIP_39-{v['mnemonic_length']}" for v in BIP_39], ) def test_bip39_application_languages(vector, lang): n_words = vector["mnemonic_length"] @@ -121,7 +121,7 @@ def test_hex(vector): @pytest.mark.parametrize("vector", XPRV, ids=["XPRV"]) @pytest.mark.xfail(reason="RSA application not implemented", raises=NotImplementedError) -def test_rsa_unsupported(vector): +def test_rsa_unimplemented(vector): """currently no support for RSA application. path format: m/83696968'/828365'/{key_bits}'/{key_index}'""" rsa_path = "m/83696968'/828365'/1024'/0'" diff --git a/tests/test_cli.py b/tests/test_cli.py index 81c63cc..497ef80 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -17,7 +17,7 @@ "xprv": ( "xprv9s21ZrQH143K417dJYmPr6Qmy2t61xrKtDCCL3Cec4NMFFFRZTF" "2jSbtqSXpuCz8UqgsuyrPC5wngx3dk5Gt8zQnbnHVAsMyb7bWtHZ95Jk" - ) + ), } @@ -83,7 +83,7 @@ def test_seed_option_sensitivity(runner, language, vectors): assert result_xprv == xprv -@pytest.mark.parametrize("n", N_WORDS_ALLOWED) +@pytest.mark.parametrize("n", N_WORDS_ALLOWED, ids=lambda n: f"{n}-words") def test_seed_command_from_rand(runner, n): for style in ("--not-pretty", "--pretty"): cmd = ["seed", "-t", "words", "-n", str(n), "-f", "rand"] @@ -145,7 +145,8 @@ def test_seed_bad_to(runner): def test_bipsea_integration(runner): result_seed = runner.invoke( - cli, ["seed", "-f", "words", "-u", MNEMONIC_12["words"], "-n", "12", "-t", "xprv"] + cli, + ["seed", "-f", "words", "-u", MNEMONIC_12["words"], "-n", "12", "-t", "xprv"], ) xprv = result_seed.output.strip() assert xprv == MNEMONIC_12["xprv"]