Ejemplo n.º 1
0
 def test_removed_attr(self):
     value = obj.popattr(self.o, 'test')
     assert value == 1
     # verify that attr was removed from the object
     with pytest.raises(AttributeError):
         obj.popattr(self.o, 'test')
Ejemplo n.º 2
0
 def test_nonexistent_attr(self):
     # object with attr trying to get nonexistent attr
     with pytest.raises(AttributeError):
         obj.popattr(self.o, 'nonexistent')
Ejemplo n.º 3
0
 def test_fallback(self):
     # object with attr trying to get nonexistent attr using fallback
     value = obj.popattr(self.o, 'nonexistent', 2)
     assert value == 2
Ejemplo n.º 4
0
 def test_no_attrs(self):
     # object without any attrs
     with pytest.raises(AttributeError):
         obj.popattr(object(), 'nonexistent')
Ejemplo n.º 5
0
 def test_removed_attr(self):
     value = obj.popattr(self.o, 'test')
     assert value == 1
     # verify that attr was removed from the object
     with pytest.raises(AttributeError):
         obj.popattr(self.o, 'test')
Ejemplo n.º 6
0
 def test_fallback(self):
     # object with attr trying to get nonexistent attr using fallback
     value = obj.popattr(self.o, 'nonexistent', 2)
     assert value == 2
Ejemplo n.º 7
0
 def test_nonexistent_attr(self):
     # object with attr trying to get nonexistent attr
     with pytest.raises(AttributeError):
         obj.popattr(self.o, 'nonexistent')
Ejemplo n.º 8
0
 def test_no_attrs(self):
     # object without any attrs
     with pytest.raises(AttributeError):
         obj.popattr(object(), 'nonexistent')