def test_copy(self): d = SplayDict.fromkeys(['a', 'b'], 1) e = d.copy() self.assertIsNot(d, e) self.assertIn('a', e) self.assertIn('b', e) self.assertEqual(e['a'], 1) self.assertEqual(e['b'], 1)
def test_clear(self): s = "String1235" d = SplayDict.fromkeys(['a', 'b'], 1) d.clear() self.assertEqual(len(d), 0, "Length of a cleared dict should be 0") self.assertIs(d.get('b'), None, "Default return value should be none for .get()") self.assertIs(d.get('b', s), s, "Default kwarg for .get() should be respected")
def test_fromkeys(self): """A splaydict created using fromkeys must contain the keys it was created from.""" d = SplayDict.fromkeys(['a', 'b', 'c'], 1) self.assertIn('a', d) self.assertIn('b', d) self.assertIn('c', d) self.assertEqual(d['a'], 1) self.assertEqual(d['b'], 1) self.assertEqual(d['c'], 1)