Exemple #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')
Exemple #2
0
 def test_nonexistent_attr(self):
     # object with attr trying to get nonexistent attr
     with pytest.raises(AttributeError):
         obj.popattr(self.o, 'nonexistent')
Exemple #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
Exemple #4
0
 def test_no_attrs(self):
     # object without any attrs
     with pytest.raises(AttributeError):
         obj.popattr(object(), 'nonexistent')
Exemple #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')
Exemple #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
Exemple #7
0
 def test_nonexistent_attr(self):
     # object with attr trying to get nonexistent attr
     with pytest.raises(AttributeError):
         obj.popattr(self.o, 'nonexistent')
Exemple #8
0
 def test_no_attrs(self):
     # object without any attrs
     with pytest.raises(AttributeError):
         obj.popattr(object(), 'nonexistent')