File: test_unicode.py

package info (click to toggle)
dpath-python 2.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 256 kB
  • sloc: python: 1,671; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 686 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import dpath


def test_unicode_merge():
    a = {'中': 'zhong'}
    b = {'文': 'wen'}

    dpath.merge(a, b)
    assert len(a.keys()) == 2
    assert a['中'] == 'zhong'
    assert a['文'] == 'wen'


def test_unicode_search():
    a = {'中': 'zhong'}

    results = [[x[0], x[1]] for x in dpath.search(a, '*', yielded=True)]
    assert len(results) == 1
    assert results[0][0] == '中'
    assert results[0][1] == 'zhong'


def test_unicode_str_hybrid():
    a = {'first': u'1'}
    b = {u'second': '2'}

    dpath.merge(a, b)
    assert len(a.keys()) == 2
    assert a[u'second'] == '2'
    assert a['second'] == u'2'
    assert a[u'first'] == '1'
    assert a['first'] == u'1'