示例#1
0
 def test_add_multiple_dicts(self):
     p = Params()
     d1 = {"a": 1, "b": 2}
     d2 = {"c": 3, "d": 4}
     p.add(d1, d2)
     self.assertEqual(p.get("a"), 1)
     self.assertEqual(p.get("b"), 2)
     self.assertEqual(p.get("c"), 3)
     self.assertEqual(p.get("d"), 4)
示例#2
0
    def test_add_both_simultaneously(self):
        p = Params()
        v = "some_value"
        d = {"a": 1, "b": 2}

        p.add(d, key=v)

        self.assertEqual(p.get("a"), 1)
        self.assertEqual(p.get("b"), 2)
        self.assertEqual(p.get("key"), v)
示例#3
0
    def test_shorthand_addition_of_param_objects(self):
        """
		This tests the operator overload of '+'
		"""
        p1 = Params()
        p1.add(a=1, b=2)
        p2 = Params()
        p2.add(c=3, d=4)

        p1 += p2
        self.assertEqual(p1.get("a"), 1)
        self.assertEqual(p1.get("b"), 2)
        self.assertEqual(p1.get("c"), 3)
        self.assertEqual(p1.get("d"), 4)
示例#4
0
 def test_add_multiple_key_value_pairs(self):
     p = Params()
     v1 = "some_value"
     v2 = "other_value"
     p.add(key1=v1, key2=v2)
     self.assertEqual(p.get("key1"), v1)
     self.assertEqual(p.get("key2"), v2)
示例#5
0
 def test_reset_param(self):
     p = Params()
     v = "some_value"
     p.add(key=v)
     p.reset_param('key', 'new_value')
     self.assertEqual(p.get('key'), 'new_value')
示例#6
0
 def test_add_dict(self):
     p = Params()
     d = {"a": 1, "b": 2}
     p.add(d)
     self.assertEqual(p.get("a"), 1)
     self.assertEqual(p.get("b"), 2)
示例#7
0
 def test_add_key_value_pair(self):
     p = Params()
     v = "some_value"
     p.add(key=v)
     self.assertEqual(p.get("key"), v)