Skip to content

Commit a90bb02

Browse files
committed
test: Use pytest.param with explicit ids in compression tests
1 parent ff4f21e commit a90bb02

2 files changed

Lines changed: 53 additions & 8 deletions

File tree

tests/unit/test_http_compressors.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,51 @@ def _affected(name: str) -> bool:
4848
sys.modules.update(saved)
4949

5050

51-
@pytest.mark.parametrize('quality', [1, 9])
51+
@pytest.mark.parametrize(
52+
'quality',
53+
[
54+
pytest.param(1, id='fastest'),
55+
pytest.param(9, id='best'),
56+
],
57+
)
5258
def test_gzip_compressor_round_trips_at_quality(quality: int) -> None:
5359
"""Gzip compressor round-trips data at the boundary quality levels."""
5460
assert gzip.decompress(GzipHttpCompressor(quality=quality).compress(b'payload')) == b'payload'
5561

5662

57-
@pytest.mark.parametrize('quality', [0, 11])
63+
@pytest.mark.parametrize(
64+
'quality',
65+
[
66+
pytest.param(0, id='fastest'),
67+
pytest.param(11, id='best'),
68+
],
69+
)
5870
def test_brotli_compressor_round_trips_at_quality(quality: int) -> None:
5971
"""Brotli compressor round-trips data at the boundary quality levels."""
6072
assert brotli.decompress(BrotliHttpCompressor(quality=quality).compress(b'payload')) == b'payload'
6173

6274

63-
@pytest.mark.parametrize('quality', [0, 10, -1])
75+
@pytest.mark.parametrize(
76+
'quality',
77+
[
78+
pytest.param(0, id='below minimum'),
79+
pytest.param(10, id='above maximum'),
80+
pytest.param(-1, id='negative'),
81+
],
82+
)
6483
def test_gzip_compressor_rejects_out_of_range_quality(quality: int) -> None:
6584
"""Gzip compressor raises `ValueError` at construction for a quality not between `1` and `9`."""
6685
with pytest.raises(ValueError, match='gzip quality must be between 1 and 9'):
6786
GzipHttpCompressor(quality=quality)
6887

6988

70-
@pytest.mark.parametrize('quality', [-1, 12])
89+
@pytest.mark.parametrize(
90+
'quality',
91+
[
92+
pytest.param(-1, id='negative'),
93+
pytest.param(12, id='above maximum'),
94+
],
95+
)
7196
def test_brotli_compressor_rejects_out_of_range_quality(quality: int) -> None:
7297
"""Brotli compressor raises `ValueError` at construction for a quality not between `0` and `11`."""
7398
with pytest.raises(ValueError, match='brotli quality must be between 0 and 11'):

tests/unit/test_run_charge.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,20 @@ def _decode_body(request: Request) -> dict:
2929
return json.loads(raw)
3030

3131

32-
@pytest.mark.parametrize('compression', ['gzip', 'brotli'])
32+
@pytest.mark.parametrize(
33+
'compression',
34+
[
35+
pytest.param('gzip', id='gzip'),
36+
pytest.param('brotli', id='brotli'),
37+
],
38+
)
3339
@pytest.mark.parametrize(
3440
'count',
35-
[0, 1, 5],
41+
[
42+
pytest.param(0, id='zero'),
43+
pytest.param(1, id='one'),
44+
pytest.param(5, id='five'),
45+
],
3646
)
3747
def test_run_charge_preserves_count_sync(
3848
httpserver: HTTPServer,
@@ -58,10 +68,20 @@ def capture_request(request: Request) -> Response:
5868
assert body['count'] == count
5969

6070

61-
@pytest.mark.parametrize('compression', ['gzip', 'brotli'])
71+
@pytest.mark.parametrize(
72+
'compression',
73+
[
74+
pytest.param('gzip', id='gzip'),
75+
pytest.param('brotli', id='brotli'),
76+
],
77+
)
6278
@pytest.mark.parametrize(
6379
'count',
64-
[0, 1, 5],
80+
[
81+
pytest.param(0, id='zero'),
82+
pytest.param(1, id='one'),
83+
pytest.param(5, id='five'),
84+
],
6585
)
6686
async def test_run_charge_preserves_count_async(
6787
httpserver: HTTPServer,

0 commit comments

Comments
 (0)