Пример #1
0
 def test_attrerror(self):
     d = Dict()
     with self.assertRaises(AttributeError):
         value = d.empty
Пример #2
0
 def test_attr(self):
     d = Dict()
     d['key'] = 'value'
     self.assertTrue('key' in d)
     self.assertEqual(d['key'], 'value')
Пример #3
0
 def test_keyerror(self):
     d = Dict()
     with self.assertRaises(KeyError):
         value = d['empty']
Пример #4
0
 def test_init(self):
     d = Dict(a=1, b='test')
     self.assertEqual(d.a, 1)  # 测试key是否正确
     self.assertEqual(d.b, 'test')  # 测试value是否正确
     self.assertTrue(isinstance(d, dict))  #测试d对象是否是dict
Пример #5
0
 def test_key(self):
     d = Dict()
     d['key'] = 'value'
     self.assertEqual(d.key, 'value')
Пример #6
0
 def test_key(self):
     d = Dict()
     d['hong'] = 1
     self.assertEqual(d.hong,1)
Пример #7
0
 def test_init(self):
     d = Dict(a=1, b='test')
     self.assertEquals(d.a, 1)
     self.assertEquals(d.b, 'test')
     self.assertTrue(isinstance(d, dict))
Пример #8
0
 def test_attr(self):
     d = Dict()
     d.fox = 'fox'
     self.assertEqual(d['fox'],'fox')
Пример #9
0
 def test_keyerror(self):
     d = Dict()
     with self.assertRaises(KeyError):
         value = d['none']
     with self.assertRaises(AttributeError):
         value = d.none
Пример #10
0
 def test_init(self):
     d = Dict(a=1, b='test')
     # 断言assertEqual() 断言函数返回的结果与1相等
     self.assertEqual(d.a, 1)
     self.assertEqual(d.b, 'test')
     self.assertTrue(isinstance(d, dict))
Пример #11
0
 def test_init(self):
     a, b = 1, 'test'
     d = Dict(a=a, b=b)
     self.assertEqual(d.a, a, ('value is err,d.a not equal %s', a))
     self.assertEqual(d.b, 'test', ('value is err,d.a not equal %s', a))
     self.assertTrue(isinstance(d, Dict))
Пример #12
0
 def test_attr_error(self):
     d = Dict()
     with self.assertRaises(AttributeError):
         value = d.notExistKey
Пример #13
0
 def test_key_error(self):
     d = Dict()
     with self.assertRaises(KeyError):
         value = d['notExistKey']
Пример #14
0
 def test_init(self):
     d = Dict(a=1, b="test")
     self.assertEqual(d.a, 1)
     self.assertEqual(d.b, "test")
     self.assertTrue(isinstance(d, Dict))