Exemple #1
0
 def test_lookup_with_slots(self):
     s = Slots()
     s.s1 = "s1"
     self.assertEquals(safe_get_attribute(s, "s1"), "s1")
     self.assertIsInstance(safe_get_attribute_new_style(s, "s1"), member_descriptor)
     with self.assertRaises(AttributeError):
         safe_get_attribute(s, "s2")
     self.assertIsInstance(safe_get_attribute_new_style(s, "s2"), member_descriptor)
 def test_lookup_with_slots(self):
     s = Slots()
     s.s1 = 's1'
     self.assertEquals(safe_get_attribute(s, 's1'), 's1')
     self.assertIsInstance(safe_get_attribute_new_style(s, 's1'),
                           member_descriptor)
     with self.assertRaises(AttributeError):
         safe_get_attribute(s, 's2')
     self.assertIsInstance(safe_get_attribute_new_style(s, 's2'),
                           member_descriptor)
 def test_lookup_with_slots(self):
     s = Slots()
     s.s1 = "s1"
     self.assertEqual(safe_get_attribute(s, "s1"), "s1")
     self.assertIsInstance(safe_get_attribute_new_style(s, "s1"),
                           member_descriptor)
     with self.assertRaises(AttributeError):
         safe_get_attribute(s, "s2")
     self.assertIsInstance(safe_get_attribute_new_style(s, "s2"),
                           member_descriptor)
Exemple #4
0
 def test_lookup_with_property_and_slots(self):
     sga = safe_get_attribute
     s = SlotsSubclass()
     self.assertIsInstance(sga(Slots, 's3'), property)
     self.assertEquals(safe_get_attribute(s, 's3'),
                       Slots.__dict__['s3'])
     self.assertIsInstance(sga(SlotsSubclass, 's3'), property)
 def test_lookup_with_property_and_slots(self):
     sga = safe_get_attribute
     s = SlotsSubclass()
     self.assertIsInstance(sga(Slots, 's3'), property)
     self.assertEquals(safe_get_attribute(s, 's3'),
                       Slots.__dict__['s3'])
     self.assertIsInstance(sga(SlotsSubclass, 's3'), property)