Skip to content

Commit 91b7950

Browse files
authored
refactor(tests): Use pytest params with ids (leanEthereum#31)
- Don't parametrize descriptions, instead use ``pytest.param`` with ``id`` to describe the test case.
1 parent d74fdc9 commit 91b7950

2 files changed

Lines changed: 15 additions & 18 deletions

File tree

tests/lean_spec/subspecs/xmss/test_interface.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,15 @@ def _test_correctness_roundtrip(
5757

5858

5959
@pytest.mark.parametrize(
60-
"activation_epoch, num_active_epochs, description",
60+
"activation_epoch, num_active_epochs",
6161
[
62-
(10, 4, "Standard case with a short, active lifetime"),
63-
(0, 8, "Lifetime starting at epoch 0"),
64-
(20, 1, "Lifetime with only a single active epoch"),
65-
(7, 5, "Lifetime starting at an odd-numbered epoch"),
62+
pytest.param(10, 4, id="Standard case with a short, active lifetime"),
63+
pytest.param(0, 8, id="Lifetime starting at epoch 0"),
64+
pytest.param(20, 1, id="Lifetime with only a single active epoch"),
65+
pytest.param(7, 5, id="Lifetime starting at an odd-numbered epoch"),
6666
],
6767
)
68-
def test_signature_scheme_correctness(
69-
activation_epoch: int, num_active_epochs: int, description: str
70-
) -> None:
68+
def test_signature_scheme_correctness(activation_epoch: int, num_active_epochs: int) -> None:
7169
"""Runs an end-to-end test of the signature scheme."""
7270
_test_correctness_roundtrip(
7371
scheme=TEST_SIGNATURE_SCHEME,

tests/lean_spec/subspecs/xmss/test_merkle_tree.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,23 @@ def _run_commit_open_verify_roundtrip(
6363

6464

6565
@pytest.mark.parametrize(
66-
"num_leaves, depth, start_index, leaf_parts_len, description",
66+
"num_leaves, depth, start_index, leaf_parts_len",
6767
[
68-
(16, 4, 0, 3, "Full tree (depth 4)"),
69-
(12, 5, 0, 5, "Half tree, left-aligned (depth 5)"),
70-
(16, 5, 16, 2, "Half tree, right-aligned (depth 5)"),
71-
(22, 6, 13, 3, "Sparse, non-aligned tree (depth 6)"),
72-
(2, 2, 2, 6, "Half tree, right-aligned (small)"),
73-
(1, 1, 0, 1, "Tree with a single leaf at the start"),
74-
(1, 1, 1, 1, "Tree with a single leaf at an odd index"),
75-
(16, 5, 7, 2, "Small sparse tree starting at an odd index"),
68+
pytest.param(16, 4, 0, 3, id="Full tree (depth 4)"),
69+
pytest.param(12, 5, 0, 5, id="Half tree, left-aligned (depth 5)"),
70+
pytest.param(16, 5, 16, 2, id="Half tree, right-aligned (depth 5)"),
71+
pytest.param(22, 6, 13, 3, id="Sparse, non-aligned tree (depth 6)"),
72+
pytest.param(2, 2, 2, 6, id="Half tree, right-aligned (small)"),
73+
pytest.param(1, 1, 0, 1, id="Tree with a single leaf at the start"),
74+
pytest.param(1, 1, 1, 1, id="Tree with a single leaf at an odd index"),
75+
pytest.param(16, 5, 7, 2, id="Small sparse tree starting at an odd index"),
7676
],
7777
)
7878
def test_commit_open_verify_roundtrip(
7979
num_leaves: int,
8080
depth: int,
8181
start_index: int,
8282
leaf_parts_len: int,
83-
description: str,
8483
) -> None:
8584
"""Tests the Merkle tree logic for various configurations."""
8685
# Ensure the test case parameters are valid for the specified tree depth.

0 commit comments

Comments
 (0)