Пример #1
0
 def test_update(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     b = {"wagwaan": "hotskull", "nba": "hangtime"}
     c = datatype_redis.Dict(a)
     a.update(b)
     c.update(b)
     self.assertEqual(a, c)
Пример #2
0
    def test_del(self):
        a = datatype_redis.Dict({"wagwaan": "popcaan", "flute": "don"})
        del a["wagwaan"]
        self.assertRaises(KeyError, lambda: a["wagwaan"])

        def del_missing():
            del a["hotskull"]

        self.assertRaises(KeyError, del_missing)
Пример #3
0
 def test_get(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     b = datatype_redis.Dict(a)
     self.assertEqual(a["wagwaan"], b["wagwaan"])
     self.assertEqual(a.get("wagwaan"), b.get("wagwaan"))
     self.assertRaises(KeyError, lambda: b["hotskull"])
     self.assertEqual(a.get("hotskull"), b.get("hotskull"))
     self.assertEqual(a.get("hotskull", "don"), b.get("hotskull", "don"))
     self.assertNotEqual(a.get("hotskull", "don"), b.get("hotskull", "x"))
Пример #4
0
 def test_setdefault(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     b = datatype_redis.Dict(a)
     c = "nba"
     d = "hangtime"
     e = b.setdefault(c, d)
     self.assertEqual(e, d)
     self.assertEqual(b[c], d)
     self.assertEqual(a.setdefault(c, d), e)
     e = b.setdefault(c, c)
     self.assertEqual(e, d)
     self.assertEqual(a.setdefault(c, c), e)
Пример #5
0
 def test_clear(self):
     a = datatype_redis.Dict({"wagwaan": "popcaan", "flute": "don"})
     a.clear()
     self.assertEqual(len(a), 0)
Пример #6
0
 def test_copy(self):
     a = datatype_redis.Dict({"wagwaan": "popcaan", "flute": "don"})
     b = a.copy()
     self.assertEqual(type(a), type(b))
     self.assertNotEqual(a.key, b.key)
Пример #7
0
 def test_empty(self):
     self.assertEqual(datatype_redis.Dict(), {})
Пример #8
0
 def test_contains(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     b = datatype_redis.Dict(a)
     self.assertIn("wagwaan", a)
     self.assertNotIn("hotskull", a)
Пример #9
0
 def test_len(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     b = datatype_redis.Dict(a)
     self.assertEqual(len(a), len(b))
Пример #10
0
 def test_set(self):
     a = datatype_redis.Dict({"wagwaan": "popcaan", "flute": "don"})
     a["wagwaan"] = "hotskull"
     self.assertEqual(a["wagwaan"], "hotskull")
Пример #11
0
 def test_value(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     self.assertEqual(datatype_redis.Dict(a), a)
Пример #12
0
 def test_items(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     self.assertItemsEqual(a.items(), datatype_redis.Dict(a).items())
Пример #13
0
 def test_iter(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     self.assertItemsEqual(iter(a), iter(datatype_redis.Dict(a)))