File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ # coding=utf-8
2
+ # author@alingse
3
+ # 2016.11.21
4
+
5
+ import unittest
6
+
7
+ from jsoncsv .utils import encode_safe_key , decode_safe_key
8
+
9
+
10
+ class Testescape (unittest .TestCase ):
11
+
12
+ def test_all (self ):
13
+ path = ['A' , 'B' , '..' , '\.\\ ww' ]
14
+
15
+ for sep in 'AB.w' :
16
+ key = encode_safe_key (path , sep )
17
+ _path = decode_safe_key (key , sep )
18
+
19
+ self .assertListEqual (path , _path )
20
+
21
+ def test_encode (self ):
22
+ path = ['A' , 'B' , 'C' , 'www.xxx.com' ]
23
+ sep = '.'
24
+ key = encode_safe_key (path , sep )
25
+
26
+ self .assertEqual (key , 'A\.B\.C\.www.xxx.com' )
27
+
28
+ def test_decode (self ):
29
+ key = 'A\.B\.C\.www.xxx.com'
30
+ sep = '.'
31
+ path = decode_safe_key (key , sep )
32
+
33
+ self .assertEqual (path [0 ], 'A' )
34
+ self .assertEqual (path [1 ], 'B' )
35
+ self .assertEqual (path [2 ], 'C' )
36
+ self .assertEqual (path [3 ], 'www.xxx.com' )
You can’t perform that action at this time.
0 commit comments