Always require 4 values for padding.
This commit is contained in:
parent
22ae0c5bca
commit
451477593f
@ -537,12 +537,11 @@ def data(readonly=False):
|
||||
|
||||
('padding',
|
||||
SettingValue(typ.Padding(), '0,0,5,5'),
|
||||
"Padding for tabs (single value or 'top, bottom, left, right')."),
|
||||
"Padding for tabs (top, bottom, left, right)."),
|
||||
|
||||
('indicator-padding',
|
||||
SettingValue(typ.Padding(), '2,2,0,4'),
|
||||
"Padding for indicators (single value or 'top, bottom, left, "
|
||||
"right')."),
|
||||
"Padding for indicators (top, bottom, left, right)."),
|
||||
|
||||
readonly=readonly
|
||||
)),
|
||||
|
@ -1139,7 +1139,7 @@ class Padding(IntList):
|
||||
try:
|
||||
vals = self.transform(value)
|
||||
except (ValueError, TypeError):
|
||||
raise configexc.ValidationError(value, "must be a list of 1 or 4 "
|
||||
raise configexc.ValidationError(value, "must be a list of 4 "
|
||||
"integers!")
|
||||
if None in vals and not self.none_ok:
|
||||
raise configexc.ValidationError(value, "items may not be empty!")
|
||||
@ -1152,10 +1152,6 @@ class Padding(IntList):
|
||||
elems = super().transform(value)
|
||||
if elems is None:
|
||||
return elems
|
||||
if len(elems) == 1:
|
||||
val = elems[0]
|
||||
return PaddingValues(val, val, val, val)
|
||||
else:
|
||||
return PaddingValues(*elems)
|
||||
|
||||
|
||||
|
@ -1559,17 +1559,17 @@ class TestPadding:
|
||||
|
||||
@pytest.mark.parametrize('val', [
|
||||
'',
|
||||
'0',
|
||||
'5',
|
||||
'1,,2,3',
|
||||
'1,2,3,4',
|
||||
'1, 2, 3, 4',
|
||||
'0,0,0,0',
|
||||
])
|
||||
def test_validate_valid(self, klass, val):
|
||||
klass(none_ok=True).validate(val)
|
||||
|
||||
@pytest.mark.parametrize('val', [
|
||||
'',
|
||||
'5',
|
||||
'1,,2,3',
|
||||
'0.5',
|
||||
'-1',
|
||||
@ -1584,7 +1584,6 @@ class TestPadding:
|
||||
|
||||
@pytest.mark.parametrize('val, expected', [
|
||||
('', None),
|
||||
('5', (5, 5, 5, 5)),
|
||||
('1,2,3,4', (1, 2, 3, 4)),
|
||||
])
|
||||
def test_transform(self, klass, val, expected):
|
||||
|
Loading…
Reference in New Issue
Block a user