@@ -66,25 +66,23 @@ def _generator():
66
66
67
67
68
68
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 " ),
76
76
]
77
77
78
78
# Add a Path object test that's platform dependent
79
79
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" ))
81
81
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" ))
83
83
84
84
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 )
88
86
def test_json_encode (input_ , expected ):
89
87
output = json_encode (input_ )
90
88
assert output == expected
0 commit comments