Skip to content

Commit 56d84d1

Browse files
authored
Merge pull request #2084 from half-duplex/fix-booleanattr-default
config: fix BooleanAttribute default=True
2 parents 269498a + dd87be5 commit 56d84d1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

sopel/config/types.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,6 @@ def parse(self, value):
404404
]
405405
return bool(value)
406406

407-
def _parse(self, value, settings, section):
408-
return self.parse(value)
409-
410407
def __set__(self, instance, value):
411408
if value is None:
412409
instance._parser.remove_option(instance._section_name, self.name)

test/test_config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class FakeConfigSection(types.StaticSection):
7272
valattr = types.ValidatedAttribute('valattr')
7373
listattr = types.ListAttribute('listattr')
7474
choiceattr = types.ChoiceAttribute('choiceattr', ['spam', 'egg', 'bacon'])
75+
booleanattr = types.BooleanAttribute('booleanattr')
76+
booleanattr_true = types.BooleanAttribute('booleanattr', default=True)
7577
af_fileattr = types.FilenameAttribute('af_fileattr', relative=False, directory=False)
7678
ad_fileattr = types.FilenameAttribute('ad_fileattr', relative=False, directory=True)
7779
rf_fileattr = types.FilenameAttribute('rf_fileattr', relative=True, directory=False)
@@ -204,6 +206,11 @@ def test_choiceattribute_when_valid(fakeconfig):
204206
assert fakeconfig.fake.choiceattr == 'bacon'
205207

206208

209+
def test_booleanattribute_default(fakeconfig):
210+
assert fakeconfig.fake.booleanattr is False
211+
assert fakeconfig.fake.booleanattr_true is True
212+
213+
207214
def test_fileattribute_valid_absolute_file_path(fakeconfig):
208215
testfile = os.path.join(fakeconfig.core.homedir, 'test.tmp')
209216
fakeconfig.fake.af_fileattr = testfile

0 commit comments

Comments
 (0)