~ubuntu-branches/debian/sid/pyrlp/sid

« back to all changes in this revision

Viewing changes to tests/test_raw_sedes.py

  • Committer: Package Import Robot
  • Author(s): Ben Finney
  • Date: 2017-07-15 05:25:42 UTC
  • Revision ID: package-import@ubuntu.com-20170715052542-a20zzsypt1qfecq1
Tags: upstream-0.5.1
ImportĀ upstreamĀ versionĀ 0.5.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from __future__ import unicode_literals
 
2
 
 
3
import pytest
 
4
from rlp import encode, decode, SerializationError
 
5
from rlp.sedes import raw
 
6
 
 
7
 
 
8
serializable = (
 
9
    b'',
 
10
    b'asdf',
 
11
    b'fds89032#$@%',
 
12
    b'',
 
13
    b'dfsa',
 
14
    [b'dfsa', b''],
 
15
    [],
 
16
    [b'fdsa', [b'dfs', [b'jfdkl']]],
 
17
)
 
18
 
 
19
 
 
20
not_serializable = (
 
21
    0,
 
22
    32,
 
23
    ['asdf', ['fdsa', [5]]],
 
24
    str
 
25
)
 
26
 
 
27
 
 
28
def test_serializable():
 
29
    for s in serializable:
 
30
        raw.serialize(s)
 
31
        code = encode(s, raw)
 
32
        assert s == decode(code, raw)
 
33
    for s in not_serializable:
 
34
        with pytest.raises(SerializationError):
 
35
            raw.serialize(s)