Exemplo n.º 1
0
 class Something:
     a: N(10)
     b: AN(20)
     other: Other
     others: List[Other]
     c: N(5)
     d: AN(10)
Exemplo n.º 2
0
def test_AN_to_bytes_with_unicode_error_replace():
    assert (AN(16, errors=UnicodeErrorHandler.REPLACE).to_bytes("동아・한신아파트") ==
            b"\xb5\xbf\xbe\xc6?\xc7\xd1\xbd\xc5\xbe\xc6\xc6\xc4\xc6\xae ")
Exemplo n.º 3
0
def test_AN_to_bytes_with_unicode_error_ignore():
    assert (AN(16, errors=UnicodeErrorHandler.IGNORE).to_bytes("동아・한신아파트") ==
            b"\xb5\xbf\xbe\xc6\xc7\xd1\xbd\xc5\xbe\xc6\xc6\xc4\xc6\xae  ")
Exemplo n.º 4
0
def test_AN_to_bytes_with_unicode_error_strict():
    with pytest.raises(UnsupportedUnicodeError) as e:
        AN(30, errors=UnicodeErrorHandler.STRICT).to_bytes("동아・한신아파트")
    assert "codec can't encode character" in str(e.value)
Exemplo n.º 5
0
def test_AN_to_bytes_with_invalid_length():
    with pytest.raises(InvalidLengthError) as e:
        assert AN(5).to_bytes(date(2018, 9, 9))
    assert 'Invalid length of value is given' in str(e.value)
Exemplo n.º 6
0
def test_AN_to_bytes(length, value, expected):
    assert AN(length).to_bytes(value) == expected
Exemplo n.º 7
0
 class Other:
     an: AN(10)
     n: N(5)
Exemplo n.º 8
0
 class Other:
     n: N(5)
     an: AN(10)
Exemplo n.º 9
0
 class Something:
     n: N(10)
     an: AN(20)
     other: Other
     others: List[Other]
     filler: AN(100)
Exemplo n.º 10
0
 class One:
     an: AN(10)
     n: int