Skip to content

Commit 33d598a

Browse files
committed
Add inline pytest ids to unittests
1 parent 3e3a2c3 commit 33d598a

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

tests/agent_unittests/test_encoding_utils.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,23 @@ def _generator():
6666

6767

6868
JSON_ENCODE_TESTS = [
69-
(10, "10"),
70-
(10.0, "10.0"),
71-
("my_string", '"my_string"'),
72-
(b"my_bytes", '"my_bytes"'),
73-
({"id": 1, "name": "test", "NoneType": None}, '{"id":1,"name":"test","NoneType":null}'),
74-
(_generator(), "[1,2,3]"),
75-
(tuple(range(4, 7)), "[4,5,6]"),
69+
pytest.param(10, "10", id="int"),
70+
pytest.param(10.0, "10.0", id="float"),
71+
pytest.param("my_string", '"my_string"', id="str"),
72+
pytest.param(b"my_bytes", '"my_bytes"', id="bytes"),
73+
pytest.param({"id": 1, "name": "test", "NoneType": None}, '{"id":1,"name":"test","NoneType":null}', id="dict"),
74+
pytest.param(_generator(), "[1,2,3]", id="generator"),
75+
pytest.param(tuple(range(4, 7)), "[4,5,6]", id="iterable"),
7676
]
7777

7878
# Add a Path object test that's platform dependent
7979
if sys.platform == "win32":
80-
JSON_ENCODE_TESTS.append((Path("test\\path\\file.txt"), '"test\\\\path\\\\file.txt"'))
80+
JSON_ENCODE_TESTS.append(pytest.param(Path("test\\path\\file.txt"), '"test\\\\path\\\\file.txt"', id="Path"))
8181
else:
82-
JSON_ENCODE_TESTS.append((Path("test/path/file.txt"), '"test/path/file.txt"'))
82+
JSON_ENCODE_TESTS.append(pytest.param(Path("test/path/file.txt"), '"test/path/file.txt"', id="Path"))
8383

8484

85-
@pytest.mark.parametrize(
86-
"input_,expected", JSON_ENCODE_TESTS, ids=["int", "float", "str", "bytes", "dict", "generator", "iterable", "Path"]
87-
)
85+
@pytest.mark.parametrize("input_,expected", JSON_ENCODE_TESTS)
8886
def test_json_encode(input_, expected):
8987
output = json_encode(input_)
9088
assert output == expected

0 commit comments

Comments
 (0)