示例#1
0
 def test_get_set_keys_values_items(self):
     x = DictAttribute(Bunch())
     x['foo'] = 'The quick brown fox'
     assert x['foo'] == 'The quick brown fox'
     assert x['foo'] == x.obj.foo
     assert x.get('foo') == 'The quick brown fox'
     assert x.get('bar') is None
     with pytest.raises(KeyError):
         x['bar']
     x.foo = 'The quick yellow fox'
     assert x['foo'] == 'The quick yellow fox'
     assert ('foo', 'The quick yellow fox') in list(x.items())
     assert 'foo' in list(x.keys())
     assert 'The quick yellow fox' in list(x.values())
示例#2
0
 def test_get_set_keys_values_items(self):
     x = DictAttribute(Bunch())
     x['foo'] = 'The quick brown fox'
     assert x['foo'] == 'The quick brown fox'
     assert x['foo'] == x.obj.foo
     assert x.get('foo') == 'The quick brown fox'
     assert x.get('bar') is None
     with pytest.raises(KeyError):
         x['bar']
     x.foo = 'The quick yellow fox'
     assert x['foo'] == 'The quick yellow fox'
     assert ('foo', 'The quick yellow fox') in list(x.items())
     assert 'foo' in list(x.keys())
     assert 'The quick yellow fox' in list(x.values())
示例#3
0
 def test_get_set_keys_values_items(self):
     x = DictAttribute(Bunch())
     x['foo'] = 'The quick brown fox'
     self.assertEqual(x['foo'], 'The quick brown fox')
     self.assertEqual(x['foo'], x.obj.foo)
     self.assertEqual(x.get('foo'), 'The quick brown fox')
     self.assertIsNone(x.get('bar'))
     with self.assertRaises(KeyError):
         x['bar']
     x.foo = 'The quick yellow fox'
     self.assertEqual(x['foo'], 'The quick yellow fox')
     self.assertIn(
         ('foo', 'The quick yellow fox'),
         list(x.items()),
     )
     self.assertIn('foo', list(x.keys()))
     self.assertIn('The quick yellow fox', list(x.values()))
 def test_get_set_keys_values_items(self):
     x = DictAttribute(Bunch())
     x['foo'] = 'The quick brown fox'
     self.assertEqual(x['foo'], 'The quick brown fox')
     self.assertEqual(x['foo'], x.obj.foo)
     self.assertEqual(x.get('foo'), 'The quick brown fox')
     self.assertIsNone(x.get('bar'))
     with self.assertRaises(KeyError):
         x['bar']
     x.foo = 'The quick yellow fox'
     self.assertEqual(x['foo'], 'The quick yellow fox')
     self.assertIn(
         ('foo', 'The quick yellow fox'),
         list(x.items()),
     )
     self.assertIn('foo', list(x.keys()))
     self.assertIn('The quick yellow fox', list(x.values()))