def test_should_correctly_represent_field_part(self, enumeration, representation, hexadecimal): part = FieldPart('flags', 20, 6, enumeration, hex=hexadecimal) part.value = 17 assert representation == repr(part)
def test_should_raise_error_when_value_is_not_valid_boundaries( self, value): part = FieldPart('banana', 2, 3) with pytest.raises(ValueError) as exc_info: part.value = value assert f'{part.name} value must be between 0 and 7 but you provided {value}' == str( exc_info.value)
def test_should_raise_error_when_given_value_is_not_of_correct_type( self, value): part = FieldPart('banana', 2, 3) with pytest.raises(TypeError) as exc_info: part.value = value assert f'{part.name} value must be a positive integer but you provided {value}' == str( exc_info.value)
def test_should_set_field_part_value_when_given_value_is_correct(self): part = FieldPart('part', 2, 3) given_value = 6 part.value = given_value assert given_value == part.value