Example #1
0
 def testinit(self):
     """
     this test case check different kinds of bag's instantiation:
     - from a list of tuples
     - from a dictionary
     - empty bag
     """
     firstbag = Bag({"a": 1})  # bag from a dict
     secondbag = Bag([("a", 1)])  # bag from list of tuple
     thirdbag = Bag()
     thirdbag.setItem("a", 1)  # empty bag filled
     bagstring = "0 - (int) a: 1  "  # bag as string
     self.failUnless(firstbag.asString() == secondbag.asString() == thirdbag.asString() == bagstring)
Example #2
0
 def testinit(self):
     """
     this test case check different kinds of bag's instantiation:
     - from a list of tuples
     - from a dictionary
     - empty bag
     """
     firstbag = Bag({'a': 1})  #bag from a dict
     secondbag = Bag([('a', 1)])  #bag from list of tuple
     thirdbag = Bag()
     thirdbag.setItem('a', 1)  #empty bag filled
     bagstring = '0 - (int) a: 1  '  #bag as string
     self.failUnless(firstbag.asString() == secondbag.asString() ==
                     thirdbag.asString() == bagstring)
Example #3
0
 def testfromToXml(self):
     self.fullbag["relatives.Karla.birthday"] = datetime.date(1952, 12, 10)
     self.fullbag["relatives.Karla.pierciengs"] = 0
     self.fullbag["relatives.Karla.dogname"] = ""
     self.fullbag.setAttr("relatives.Karla", age=54)
     self.fullbag.toXml("mybag.xml")
     x = self.fullbag["relatives"].toXml()
     b = Bag(x)
     self.assertEqual(b.asString(), self.fullbag["relatives"].asString())
Example #4
0
 def testfromToXml(self):
     self.fullbag['relatives.Karla.birthday'] = datetime.date(1952, 12, 10)
     self.fullbag['relatives.Karla.pierciengs'] = 0
     self.fullbag['relatives.Karla.dogname'] = ''
     self.fullbag.setAttr('relatives.Karla', age=54)
     self.fullbag.toXml('mybag.xml')
     x = self.fullbag['relatives'].toXml()
     b = Bag(x)
     self.assertEqual(b.asString(), self.fullbag['relatives'].asString())