I'm doing some self-learning on the new python dataclasses.
One of the parameters that can be passed to the dataclass decorator is frozen=True, to make the object immutable.
The documentation (and experience) indicates that a:
dataclasses.FrozenInstanceError
exception will be raised.
When unit testing though (with pytest) the following test passes:
def test_change_page_url_values_raises_error(self, PAGE_URL):
page_url = PageURL(PAGE_URL)
with pytest.raises(AttributeError) as error:
page_url.value = PAGE_URL
where PageURL is a dataclass with the frozen=True parameter.
Any ideas why why pytest indicates that this action (assigning a value to page_url.value) raises an Attribute Error? Does FrozenInstanceError inherit from AttributeError?
Note: If I change the unit test to test for a different exception (ie. TypeError), the test fails as expected.
issubclass(dataclasses.FrozenInstanceError, AttributeError)- warvariucvalueattribute of thatExceptionInfocontext manager, i.e.error.value. - wim