KeyInfo: prevent read_only usage with can_disable, remove_value, absent_value, default, or required (#265)

* Prevent read_only usage with can_disable, remove_value, absent_value, default, or required.

* Add test.
This commit is contained in:
Felix Fontein 2024-03-03 09:03:25 +01:00 committed by GitHub
parent 84009262d0
commit 2ea1fef535
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View file

@ -103,6 +103,10 @@ def test_key_info_errors():
KeyInfo(read_only=True, write_only=True)
assert exc.value.args[0] == 'read_only and write_only cannot be used at the same time'
with pytest.raises(ValueError) as exc:
KeyInfo(read_only=True, default=0)
assert exc.value.args[0] == 'read_only can not be combined with can_disable, remove_value, absent_value, default, or required'
SPLIT_PATHS = [
('', [], ''),