1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
import pytest
def test_immutable_major(version):
with pytest.raises(AttributeError, match="attribute 'major' is readonly"):
version.major = 9
def test_immutable_minor(version):
with pytest.raises(AttributeError, match="attribute 'minor' is readonly"):
version.minor = 9
def test_immutable_patch(version):
with pytest.raises(AttributeError, match="attribute 'patch' is readonly"):
version.patch = 9
def test_immutable_prerelease(version):
with pytest.raises(AttributeError, match="attribute 'prerelease' is readonly"):
version.prerelease = "alpha.9.9"
def test_immutable_build(version):
with pytest.raises(AttributeError, match="attribute 'build' is readonly"):
version.build = "build.99.e0f985a"
def test_immutable_unknown_attribute(version):
with pytest.raises(
AttributeError, match=".* object has no attribute 'new_attribute'"
):
version.new_attribute = "forbidden"
|