Skip to content

Commit

Permalink
cleaner parameterize and test names
Browse files Browse the repository at this point in the history
  • Loading branch information
akarve committed Jun 4, 2024
1 parent 0639ebc commit 26aa584
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
4 changes: 1 addition & 3 deletions tests/test_bip32.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
4 changes: 1 addition & 3 deletions tests/test_bip39.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/test_bip85.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down Expand Up @@ -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"])
Expand All @@ -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"]
Expand All @@ -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'"
Expand Down
7 changes: 4 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"xprv": (
"xprv9s21ZrQH143K417dJYmPr6Qmy2t61xrKtDCCL3Cec4NMFFFRZTF"
"2jSbtqSXpuCz8UqgsuyrPC5wngx3dk5Gt8zQnbnHVAsMyb7bWtHZ95Jk"
)
),
}


Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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"]
Expand Down

0 comments on commit 26aa584

Please sign in to comment.