Beispiel #1
0
def test_force_quotes():
    list_filter = ListFilter([
        'a',
        'b',
        'c',
    ], quotes_on=QUOTE_ALWAYS)
    assert kv_format(f=list_filter) == 'f="a","b","c"'
Beispiel #2
0
def test_escaping():
    list_filter = ListFilter([
        'a"b',
        'c',
        'd',
    ])
    assert kv_format(f=list_filter) == 'f="a\\\"b",c,d'
Beispiel #3
0
def test_comma_in_text():
    list_filter = ListFilter([
        'a',
        'b, c',
        'd',
    ])
    assert kv_format(f=list_filter) == 'f=a,"b, c",d'
def test_nested_list():
    assert (kv_format(l=[['Nested', 'List'],
                         {'a': 23, 'b': 42, }, ],
                      d={'x': 'Test', 'y': 'String', })
            == ('d__x=Test   d__y=String'
                '   l__0__0=Nested   l__0__1=List'
                '   l__1__a=23   l__1__b=42'))
Beispiel #5
0
def test_escaping_non_latin():
    list_filter = ListFilter([
        'a',
        'こにちは',
        'd',
    ])
    assert kv_format(f=list_filter) == 'f=a,"\\u3053\\u306b\\u3061\\u306f",d'
def test_nested_dict():
    assert (kv_format(v={'z': [1, 2, 3],
                         'y': {'c': 27, 'b': 36, 'a': 96, },
                         'x': [{'u': 27, 'v': 42},
                               {'v': 46, 'u': 49, }, ], })
            == ('v__x__0__u=27   v__x__0__v=42   v__x__1__u=49'
                '   v__x__1__v=46   v__y__a=96   v__y__b=36'
                '   v__y__c=27   v__z__0=1   v__z__1=2   v__z__2=3'))
def test_lower_unicode_signs():
    assert (kv_format(a=('\x00\x01\x02\x03\x04\x05\x06\x07'
                         '\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'
                         '\x10\x11\x12\x13\x14\x15\x16\x17'
                         '\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'))
            == ('a="\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\b'
                '\\t\\n\\x0b\\f\\r\\x0e\\x0f\\x10\\x11\\x12\\x13'
                '\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c'
                '\\x1d\\x1e\\x1f"'))
Beispiel #8
0
def test_lower_unicode_signs():
    assert (kv_format(a=('\x00\x01\x02\x03\x04\x05\x06\x07'
                         '\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'
                         '\x10\x11\x12\x13\x14\x15\x16\x17'
                         '\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f')) == (
                             'a="\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\b'
                             '\\t\\n\\x0b\\f\\r\\x0e\\x0f\\x10\\x11\\x12\\x13'
                             '\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c'
                             '\\x1d\\x1e\\x1f"'))
Beispiel #9
0
def test_ordered_dict():
    ordered_dict = OrderedDict([
        ('z', 26),
        ('y', 25),
        ('x', 24),
        ('w', 23),
        ('v', 22),
        ('u', 21),
        ('t', 20),
    ])
    assert (kv_format(ordered_dict) ==
            'z=26   y=25   x=24   w=23   v=22   u=21   t=20')
Beispiel #10
0
def test_nested_list():
    assert (kv_format(l=[
        ['Nested', 'List'],
        {
            'a': 23,
            'b': 42,
        },
    ],
                      d={
                          'x': 'Test',
                          'y': 'String',
                      }) == ('d__x=Test   d__y=String'
                             '   l__0__0=Nested   l__0__1=List'
                             '   l__1__a=23   l__1__b=42'))
Beispiel #11
0
def test_nested_dict():
    assert (kv_format(
        v={
            'z': [1, 2, 3],
            'y': {
                'c': 27,
                'b': 36,
                'a': 96,
            },
            'x': [
                {
                    'u': 27,
                    'v': 42
                },
                {
                    'v': 46,
                    'u': 49,
                },
            ],
        }) == ('v__x__0__u=27   v__x__0__v=42   v__x__1__u=49'
               '   v__x__1__v=46   v__y__a=96   v__y__b=36'
               '   v__y__c=27   v__z__0=1   v__z__1=2   v__z__2=3'))
Beispiel #12
0
def test_simple_dict():
    assert (kv_format(a={
        'x': 1,
        'y': 2,
        'z': 3,
    }) == 'a__x=1   a__y=2   a__z=3')
def test_simple_list():
    assert kv_format(l=[6, 2]) == 'l__0=6   l__1=2'
Beispiel #14
0
def test_datetime():
    assert (kv_format(
        date=datetime(2013, 9, 23, 11, 11, 11)) == 'date="2013-09-23 11:11:11"'
            )
Beispiel #15
0
def test_unicode_text_latin1():
    assert kv_format(g='Wörk Wörk') == 'g="Wörk Wörk"'
Beispiel #16
0
def test_force_quotes():
    list_filter = ListFilter(['a', 'b', 'c', ], quotes_on=QUOTE_ALWAYS)
    assert kv_format(f=list_filter) == 'f="a","b","c"'
Beispiel #17
0
def test_escaping_non_latin():
    list_filter = ListFilter(['a', 'こにちは', 'd', ])
    assert kv_format(f=list_filter) == 'f=a,"\\u3053\\u306b\\u3061\\u306f",d'
Beispiel #18
0
def test_empty_list():
    assert kv_format(h=[]) == 'h=EMPTY'
Beispiel #19
0
def test_boolean():
    assert kv_format(success=True, fail=False) == 'fail=False   success=True'
def test_empty_list():
    assert kv_format(h=[]) == 'h=EMPTY'
Beispiel #21
0
def test_empty_dict():
    assert kv_format(j={}) == 'j=EMPTY'
Beispiel #22
0
def test_return_type_text():
    assert isinstance(kv_format(a='HalloWelt!'), text_type)
Beispiel #23
0
def test_return_type_text():
    assert isinstance(kv_format(a='HalloWelt!'), text_type)
def test_named_list():
    n_list = nl_namedlist('NamedList', 'a b')
    assert (kv_format(f=NamedTupleFilter(n_list(24, 23)))
            == 'f__a=24   f__b=23')
def test_named_list_tuple():
    n_tuple = nl_namedtuple('TestTuple', 'a b')
    assert (kv_format(f=NamedTupleFilter(n_tuple(24, 23)))
            == 'f__a=24   f__b=23')
Beispiel #26
0
def test_decimal():
    assert kv_format(delta=Decimal('4.50')) == 'delta=4.50'
def test_empty_set():
    assert kv_format(n=set()) == 'n=EMPTY'
Beispiel #28
0
def test_empty_dict_and_list_in_list():
    assert kv_format(i=[{}, []]) == 'i__0=EMPTY   i__1=EMPTY'
def test_ordered_dict():
    ordered_dict = OrderedDict([('z', 26), ('y', 25), ('x', 24), ('w', 23),
                                ('v', 22), ('u', 21), ('t', 20), ])
    assert (kv_format(ordered_dict)
            == 'z=26   y=25   x=24   w=23   v=22   u=21   t=20')
Beispiel #30
0
def test_empty_set():
    assert kv_format(n=set()) == 'n=EMPTY'
def test_supplementary_unicode():
    assert kv_format(f='\U00010392') == 'f="\\U00010392"'
Beispiel #32
0
def test_integers():
    assert kv_format(f=ListFilter([1, 2, 3])) == 'f=1,2,3'
Beispiel #33
0
def test_comma_in_text():
    list_filter = ListFilter(['a', 'b, c', 'd', ])
    assert kv_format(f=list_filter) == 'f=a,"b, c",d'
Beispiel #34
0
def test_c1_escape():
    assert kv_format(a='Hallo\u00a0Welt!') == 'a="Hallo\\xa0Welt!"'
Beispiel #35
0
def test_escaping():
    list_filter = ListFilter(['a"b', 'c', 'd', ])
    assert kv_format(f=list_filter) == 'f="a\\\"b",c,d'
Beispiel #36
0
def test_c1_not_escape_lower_limit():
    assert kv_format(a='Hi~') == 'a=Hi~'
Beispiel #37
0
def test_text_filter():
    list_filter = ListFilter([1, TextFilter('こにちは', QUOTE_ALWAYS,
                                            plaintext=True), 2])
    assert kv_format(f=list_filter) == 'f=1,"こにちは",2'
Beispiel #38
0
def test_string_quoted():
    assert kv_format(a='Hallo "Welt"!') == 'a="Hallo \\"Welt\\"!"'
Beispiel #39
0
def test_text():
    assert kv_format(f=ListFilter(['a', 'b', 'c', ])) == 'f=a,b,c'
Beispiel #40
0
def test_integers():
    assert kv_format(f=ListFilter([1, 2, 3])) == 'f=1,2,3'
Beispiel #41
0
def test_c1_not_escape_upper_limit():
    assert kv_format(a='H\u00a1') == 'a=H\u00a1'
Beispiel #42
0
def test_text_filter():
    list_filter = ListFilter(
        [1, TextFilter('こにちは', QUOTE_ALWAYS, plaintext=True), 2])
    assert kv_format(f=list_filter) == 'f=1,"こにちは",2'
Beispiel #43
0
def test_unescaped():
    assert kv_format(a='HalloWelt!') == 'a=HalloWelt!'
Beispiel #44
0
def test_text():
    assert kv_format(f=ListFilter([
        'a',
        'b',
        'c',
    ])) == 'f=a,b,c'
Beispiel #45
0
def test_random_bytes():
    assert (kv_format(
        c=b'\nJxd\x88\xfaJx;\x116\xe6') == 'c="\\nJxd\\x88\\xfaJx;\\x116\\xe6"'
            )
def test_c1_escape():
    assert kv_format(a='Hallo\u00a0Welt!') == 'a="Hallo\\xa0Welt!"'
Beispiel #47
0
def test_unicode_text_non_latin1():
    assert kv_format(g='こにちは') == 'g="\\u3053\\u306b\\u3061\\u306f"'
def test_c1_not_escape_upper_limit():
    assert kv_format(a='H\u00a1') == 'a=H\u00a1'
Beispiel #49
0
def test_supplementary_unicode():
    assert kv_format(f='\U00010392') == 'f="\\U00010392"'
def test_c1_not_escape_lower_limit():
    assert kv_format(a='Hi~') == 'a=Hi~'
def test_simple_set():
    assert kv_format(a=set(['a', 'b', ])) == 'a__0=a   a__1=b'
def test_unescaped():
    assert kv_format(a='HalloWelt!') == 'a=HalloWelt!'
def test_empty_dict():
    assert kv_format(j={}) == 'j=EMPTY'
def test_string_quoted():
    assert kv_format(a='Hallo "Welt"!') == 'a="Hallo \\"Welt\\"!"'
def test_empty_dict_and_list_in_list():
    assert kv_format(i=[{}, []]) == 'i__0=EMPTY   i__1=EMPTY'
def test_random_bytes():
    assert (kv_format(c=b'\nJxd\x88\xfaJx;\x116\xe6')
            == 'c="\\nJxd\\x88\\xfaJx;\\x116\\xe6"')
def test_unicode_text_latin1():
    assert kv_format(g='Wörk Wörk') == 'g="Wörk Wörk"'
def test_unicode_text_non_latin1():
    assert kv_format(g='こにちは') == 'g="\\u3053\\u306b\\u3061\\u306f"'
def test_simple_dict():
    assert (kv_format(a={'x': 1, 'y': 2, 'z': 3, })
            == 'a__x=1   a__y=2   a__z=3')
Beispiel #60
0
def test_simple_set():
    assert kv_format(a=set([
        'a',
        'b',
    ])) == 'a__0=a   a__1=b'