示例#1
0
 def test_perky_include_nested(self):
     with perky.pushd("include_nested"):
         root = perky.load("main.pky",
                           pragmas={'include': perky.pragma_include()})
     self.assertEqual(
         root, {
             'a': '1',
             'b': {
                 'ba': '1',
                 'bb': '2',
                 'bc': '3',
                 'bd': '4',
                 'nested_dict': {
                     'x': '3',
                     'y': '2',
                     'z': ['1', '2', '3', '4']
                 },
                 'nested_list': ['a', 'b', 'c'],
             },
             'c': '3',
             'd': '4'
         })
示例#2
0
 def test_perky_invalid_pragma(self):
     with self.assertRaises(perky.PerkyFormatError):
         root = perky.loads("a=b\n=include '''\nc=d\n",
                            pragmas={'include': perky.pragma_include()})
示例#3
0
 def test_perky_include_path(self):
     with perky.pushd("include_path"):
         root = perky.load(
             "dir1/main.pky",
             pragmas={'include': perky.pragma_include(['dir1', 'dir2'])})
     self.assertEqual(root, dict(zip("abc", "345")))
示例#4
0
 def test_perky_include_dict(self):
     with perky.pushd("include_dict"):
         root = perky.load("main.pky",
                           pragmas={'include': perky.pragma_include()})
     self.assertEqual(root, dict(zip("abcd", "1234")))
示例#5
0
 def test_perky_include_list(self):
     with perky.pushd("include_list"):
         root = perky.load("main.pky",
                           root=[],
                           pragmas={'include': perky.pragma_include()})
     self.assertEqual(root, list("abcd"))