Пример #1
0
 def test_key_error(self):
     mm = PropMap()
     self.assertTrue('bogus-key' not in mm)
     with self.assertRaises(KeyError):
         mm['bogus-key']
Пример #2
0
 def test_simple_insertion(self):
     mm = PropMap()
     mm['a'] = 'a-value'
     self.assertTrue('a' in mm)
     self.assertEqual(mm['a'], 'a-value')
Пример #3
0
 def test_construct_from_sequence(self):
     test_vec = (('a', 'a'), ('b', 'b'), ('c', 'c'))
     mm = PropMap().load(test_vec)
     self.assertEqual(len(test_vec), len(mm))
     for (k, v) in test_vec:
         self.assertTrue((k, v) in mm.items())
Пример #4
0
 def test_construct_from_dict(self):
     test_dict = {'a': 'a', 'b': 'b', 'c': 'c'}
     mm = PropMap().load(test_dict)
     self.assertEqual(len(test_dict), len(mm))
     for (k, v) in test_dict.items():
         self.assertTrue((k, v) in mm.items())
Пример #5
0
tmap = {
    "k1": "v1",
    "k2": "v2",
    "k3": {
        "k3a": "v3a"
    },
    "k4": {
        "k4a": {
            "k4b": "v3b"
        }
    },
    #         "k5": {"K$5": "v5a"},
    #         "k6.k6a": "v6a",
}

pmap = PropMap(tmap)

#print("tmap: {}".format(tmap))
#print("pmap: {}".format(pmap))

pmap.dump()
print("")

print("pmap is a {}".format(pmap.__class__))
print("pmap[k3] is a {}".format(pmap["k3"].__class__))

pmap["k9.k9a.k9b"] = "v9"

print("index k1: {}".format(pmap["k1"]))
# print("index kk: {}".format(pmap["kk"]))
print("index k3.k3a: {}".format(pmap["k3.k3a"]))