How to use the segno.encoder.prepare_data function in segno

To help you get started, we’ve selected a few segno examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heuer / segno / tests / test_encoder.py View on Github external
def check_prepare_data(expected, data, mode, encoding):
    assert expected[1:] == tuple(encoder.prepare_data(data, mode, encoding))[1:]
github heuer / segno / tests / test_encoder.py View on Github external
def test_prepare_data_multiple_int():
    test_data = [1]
    segments = encoder.prepare_data(test_data, None, None)
    assert 1 == len(segments)
    assert 4 == segments.bit_length
    assert (1, consts.MODE_NUMERIC, None) == segments[0][1:]
github heuer / segno / tests / test_encoder.py View on Github external
def test_prepare_data_multiple_override():
    test_data = [(1, consts.MODE_ALPHANUMERIC), 2]
    segments = encoder.prepare_data(test_data, None, None)
    assert 2 == len(segments)
    assert 10 == segments.bit_length
    assert (1, consts.MODE_ALPHANUMERIC, None) == segments[0][1:]
    assert (1, consts.MODE_NUMERIC, None) == segments[1][1:]
github heuer / segno / tests / test_encoder.py View on Github external
def test_prepare_data_multiple_mode_none_encoding():
    test_data = [('Ä', None, consts.DEFAULT_BYTE_ENCODING), ('Ä', None, 'utf-8'),
                 ('Ä', None, None)]
    segments = encoder.prepare_data(test_data, None, None)
    assert 3 == len(segments)
    assert 32 == segments.bit_length
    assert (1, consts.MODE_BYTE, consts.DEFAULT_BYTE_ENCODING) == segments[0][1:]
    assert (2, consts.MODE_BYTE, 'utf-8') == segments[1][1:]
    assert segments[0] == segments[2]  # Encoding detection should produce the same result as 1st tuple
github heuer / segno / tests / test_encoder.py View on Github external
def test_prepare_data_multiple_tuple():
    test_data = ('a', '1')
    segments = encoder.prepare_data(test_data, None, None)
    assert 2 == len(segments)
    assert 12 == segments.bit_length
    assert (1, consts.MODE_BYTE, consts.DEFAULT_BYTE_ENCODING) == segments[0][1:]
    assert (1, consts.MODE_NUMERIC, None) == segments[1][1:]
github heuer / segno / tests / test_encoder.py View on Github external
def test_prepare_data_multiple_mode_none():
    test_data = [(1, None), ('A', None)]
    segments = encoder.prepare_data(test_data, None, None)
    assert 2 == len(segments)
    assert 10 == segments.bit_length
    assert (1, consts.MODE_NUMERIC, None) == segments[0][1:]
    assert (1, consts.MODE_ALPHANUMERIC, None) == segments[1][1:]
github heuer / segno / tests / test_encoder.py View on Github external
def test_prepare_data_multiple():
    test_data = ['a', '1']
    segments = encoder.prepare_data(test_data, None, None)
    assert 2 == len(segments)
    assert 12 == segments.bit_length
    assert (1, consts.MODE_BYTE, consts.DEFAULT_BYTE_ENCODING) == segments[0][1:]
    assert (1, consts.MODE_NUMERIC, None) == segments[1][1:]