コード例 #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"'
コード例 #2
0
def test_escaping():
    list_filter = ListFilter([
        'a"b',
        'c',
        'd',
    ])
    assert kv_format(f=list_filter) == 'f="a\\\"b",c,d'
コード例 #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'
コード例 #4
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'))
コード例 #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'
コード例 #6
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'))
コード例 #7
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"'))
コード例 #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"'))
コード例 #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')
コード例 #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'))
コード例 #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'))
コード例 #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')
コード例 #13
0
def test_simple_list():
    assert kv_format(l=[6, 2]) == 'l__0=6   l__1=2'
コード例 #14
0
ファイル: test_format_others.py プロジェクト: or/kaviar
def test_datetime():
    assert (kv_format(
        date=datetime(2013, 9, 23, 11, 11, 11)) == 'date="2013-09-23 11:11:11"'
            )
コード例 #15
0
def test_unicode_text_latin1():
    assert kv_format(g='Wörk Wörk') == 'g="Wörk Wörk"'
コード例 #16
0
ファイル: test_filter_list.py プロジェクト: eisensheng/kaviar
def test_force_quotes():
    list_filter = ListFilter(['a', 'b', 'c', ], quotes_on=QUOTE_ALWAYS)
    assert kv_format(f=list_filter) == 'f="a","b","c"'
コード例 #17
0
ファイル: test_filter_list.py プロジェクト: eisensheng/kaviar
def test_escaping_non_latin():
    list_filter = ListFilter(['a', 'こにちは', 'd', ])
    assert kv_format(f=list_filter) == 'f=a,"\\u3053\\u306b\\u3061\\u306f",d'
コード例 #18
0
def test_empty_list():
    assert kv_format(h=[]) == 'h=EMPTY'
コード例 #19
0
ファイル: test_format_others.py プロジェクト: or/kaviar
def test_boolean():
    assert kv_format(success=True, fail=False) == 'fail=False   success=True'
コード例 #20
0
def test_empty_list():
    assert kv_format(h=[]) == 'h=EMPTY'
コード例 #21
0
def test_empty_dict():
    assert kv_format(j={}) == 'j=EMPTY'
コード例 #22
0
def test_return_type_text():
    assert isinstance(kv_format(a='HalloWelt!'), text_type)
コード例 #23
0
ファイル: test_format.py プロジェクト: eisensheng/kaviar
def test_return_type_text():
    assert isinstance(kv_format(a='HalloWelt!'), text_type)
コード例 #24
0
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')
コード例 #25
0
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')
コード例 #26
0
ファイル: test_format_others.py プロジェクト: or/kaviar
def test_decimal():
    assert kv_format(delta=Decimal('4.50')) == 'delta=4.50'
コード例 #27
0
def test_empty_set():
    assert kv_format(n=set()) == 'n=EMPTY'
コード例 #28
0
def test_empty_dict_and_list_in_list():
    assert kv_format(i=[{}, []]) == 'i__0=EMPTY   i__1=EMPTY'
コード例 #29
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')
コード例 #30
0
def test_empty_set():
    assert kv_format(n=set()) == 'n=EMPTY'
コード例 #31
0
def test_supplementary_unicode():
    assert kv_format(f='\U00010392') == 'f="\\U00010392"'
コード例 #32
0
ファイル: test_filter_list.py プロジェクト: eisensheng/kaviar
def test_integers():
    assert kv_format(f=ListFilter([1, 2, 3])) == 'f=1,2,3'
コード例 #33
0
ファイル: test_filter_list.py プロジェクト: eisensheng/kaviar
def test_comma_in_text():
    list_filter = ListFilter(['a', 'b, c', 'd', ])
    assert kv_format(f=list_filter) == 'f=a,"b, c",d'
コード例 #34
0
def test_c1_escape():
    assert kv_format(a='Hallo\u00a0Welt!') == 'a="Hallo\\xa0Welt!"'
コード例 #35
0
ファイル: test_filter_list.py プロジェクト: eisensheng/kaviar
def test_escaping():
    list_filter = ListFilter(['a"b', 'c', 'd', ])
    assert kv_format(f=list_filter) == 'f="a\\\"b",c,d'
コード例 #36
0
def test_c1_not_escape_lower_limit():
    assert kv_format(a='Hi~') == 'a=Hi~'
コード例 #37
0
ファイル: test_filter_list.py プロジェクト: eisensheng/kaviar
def test_text_filter():
    list_filter = ListFilter([1, TextFilter('こにちは', QUOTE_ALWAYS,
                                            plaintext=True), 2])
    assert kv_format(f=list_filter) == 'f=1,"こにちは",2'
コード例 #38
0
def test_string_quoted():
    assert kv_format(a='Hallo "Welt"!') == 'a="Hallo \\"Welt\\"!"'
コード例 #39
0
ファイル: test_filter_list.py プロジェクト: eisensheng/kaviar
def test_text():
    assert kv_format(f=ListFilter(['a', 'b', 'c', ])) == 'f=a,b,c'
コード例 #40
0
def test_integers():
    assert kv_format(f=ListFilter([1, 2, 3])) == 'f=1,2,3'
コード例 #41
0
def test_c1_not_escape_upper_limit():
    assert kv_format(a='H\u00a1') == 'a=H\u00a1'
コード例 #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'
コード例 #43
0
def test_unescaped():
    assert kv_format(a='HalloWelt!') == 'a=HalloWelt!'
コード例 #44
0
def test_text():
    assert kv_format(f=ListFilter([
        'a',
        'b',
        'c',
    ])) == 'f=a,b,c'
コード例 #45
0
def test_random_bytes():
    assert (kv_format(
        c=b'\nJxd\x88\xfaJx;\x116\xe6') == 'c="\\nJxd\\x88\\xfaJx;\\x116\\xe6"'
            )
コード例 #46
0
def test_c1_escape():
    assert kv_format(a='Hallo\u00a0Welt!') == 'a="Hallo\\xa0Welt!"'
コード例 #47
0
def test_unicode_text_non_latin1():
    assert kv_format(g='こにちは') == 'g="\\u3053\\u306b\\u3061\\u306f"'
コード例 #48
0
def test_c1_not_escape_upper_limit():
    assert kv_format(a='H\u00a1') == 'a=H\u00a1'
コード例 #49
0
def test_supplementary_unicode():
    assert kv_format(f='\U00010392') == 'f="\\U00010392"'
コード例 #50
0
def test_c1_not_escape_lower_limit():
    assert kv_format(a='Hi~') == 'a=Hi~'
コード例 #51
0
def test_simple_set():
    assert kv_format(a=set(['a', 'b', ])) == 'a__0=a   a__1=b'
コード例 #52
0
def test_unescaped():
    assert kv_format(a='HalloWelt!') == 'a=HalloWelt!'
コード例 #53
0
def test_empty_dict():
    assert kv_format(j={}) == 'j=EMPTY'
コード例 #54
0
def test_string_quoted():
    assert kv_format(a='Hallo "Welt"!') == 'a="Hallo \\"Welt\\"!"'
コード例 #55
0
def test_empty_dict_and_list_in_list():
    assert kv_format(i=[{}, []]) == 'i__0=EMPTY   i__1=EMPTY'
コード例 #56
0
def test_random_bytes():
    assert (kv_format(c=b'\nJxd\x88\xfaJx;\x116\xe6')
            == 'c="\\nJxd\\x88\\xfaJx;\\x116\\xe6"')
コード例 #57
0
def test_unicode_text_latin1():
    assert kv_format(g='Wörk Wörk') == 'g="Wörk Wörk"'
コード例 #58
0
def test_unicode_text_non_latin1():
    assert kv_format(g='こにちは') == 'g="\\u3053\\u306b\\u3061\\u306f"'
コード例 #59
0
def test_simple_dict():
    assert (kv_format(a={'x': 1, 'y': 2, 'z': 3, })
            == 'a__x=1   a__y=2   a__z=3')
コード例 #60
0
def test_simple_set():
    assert kv_format(a=set([
        'a',
        'b',
    ])) == 'a__0=a   a__1=b'