def test_initial_None(self): class S8: r""" This is a docstring """ a = 1 b = None sets8 = SettingsAttr(S8) sets8.b = 2.2 assert sets8.b == 2.2 with pytest.raises(Exception): sets8.b = 'str'
def test_inheritance_and_immutability(self): class S2: r""" This is a docstring """ a = 2 b = 3 class S3(S2): r""" Different docstring """ b = 3 c = 4 sets2 = SettingsAttr(S2) sets3 = SettingsAttr(S3) sets3.b = 44 assert sets3._attrs == ['a', 'b', 'c'] assert sets2.b != sets3.b assert "Different docstring" in sets3.__doc__ with pytest.raises(Exception): sets3.b = 'nope'