示例#1
0
 def test_node_encode_decode(self):
     data = {
         '1': 2,
         '2': '3',
         '3': True,
         '4': 4.0,
         '5': [1, 2, 3],
         '6': {
             '11': 11,
             '22': False,
             '33': [True, False, True, 5.5]
         }
     }
     fmt = mpv.Format(mpv.Format.NODE)
     encoded = fmt.encode(data)
     decoded = fmt.decode(encoded)
     assert decoded == data
示例#2
0
 def test_node_bad_key(self):
     fmt = mpv.Format(mpv.Format.NODE)
     data = {1: True}
     with pytest.raises(KeyError):
         fmt.encode(data)
示例#3
0
 def test_node_bad_type(self):
     fmt = mpv.Format(mpv.Format.NODE)
     data = {'1': object()}
     with pytest.raises(TypeError):
         fmt.encode(data)
示例#4
0
 def test_int64_encode(self):
     data = 12345
     fmt = mpv.Format(mpv.Format.INT64)
     encoded = fmt.encode(data)
     decoded = fmt.decode(encoded)
     assert decoded == data
示例#5
0
 def test_string_encode_decode(self):
     data = 'testing'
     fmt = mpv.Format(mpv.Format.STRING)
     encoded = fmt.encode(data)
     decoded = fmt.decode(encoded)
     assert decoded == data
示例#6
0
 def test_none(self):
     data = ''
     fmt = mpv.Format(mpv.Format.NONE)
     decoded = fmt.decode(data)
     assert decoded is None