Commit 455c8d12 authored by Robin Obůrka's avatar Robin Obůrka

tests: Use better name for dictionary fixture

parent f3667fbc
......@@ -36,7 +36,7 @@ def bad_types(request):
return request.param
@pytest.fixture
def good_dict():
def good_payload():
return {
"key1": "val1",
"key2": 2,
......@@ -45,17 +45,17 @@ def good_dict():
}
@pytest.fixture
def good_msg(good_type, good_dict):
def good_msg(good_type, good_payload):
t = bytes(good_type, encoding="UTF-8")
p = msgpack.packb(good_dict, encoding="UTF-8")
p = msgpack.packb(good_payload, encoding="UTF-8")
return (t, p)
@pytest.fixture
def good_long(good_type, good_dict):
def good_long(good_type, good_payload):
t = bytes(good_type, encoding="UTF-8")
p = msgpack.packb(good_dict, encoding="UTF-8")
x = msgpack.packb(good_dict, encoding="UTF-8")
p = msgpack.packb(good_payload, encoding="UTF-8")
x = msgpack.packb(good_payload, encoding="UTF-8")
return (t, p, x)
......
import sn
def test_encoding(good_type, good_dict, good_msg):
encoded = sn.encode_msg(good_type, good_dict)
def test_encoding(good_type, good_payload, good_msg):
encoded = sn.encode_msg(good_type, good_payload)
assert encoded == good_msg
......@@ -2,15 +2,15 @@ import pytest
import sn
def test_parse(good_type, good_dict, good_msg):
def test_parse(good_type, good_payload, good_msg):
(t, p) = sn.parse_msg(good_msg)
assert t == good_type
assert p == good_dict
assert p == good_payload
def test_longer(good_type, good_dict, good_long):
def test_longer(good_type, good_payload, good_long):
(t, p) = sn.parse_msg(good_long)
assert t == good_type
assert p == good_dict
assert p == good_payload
def test_missing_type(good_msg):
with pytest.raises(sn.InvalidMsgError):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment