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')
def test_nonexistent_attr(self): # object with attr trying to get nonexistent attr with pytest.raises(AttributeError): obj.popattr(self.o, 'nonexistent')
def test_fallback(self): # object with attr trying to get nonexistent attr using fallback value = obj.popattr(self.o, 'nonexistent', 2) assert value == 2
def test_no_attrs(self): # object without any attrs with pytest.raises(AttributeError): obj.popattr(object(), 'nonexistent')