Skip to content

Commit 5092f37

Browse files
committed
Add tests for unrepr parse errors and edge cases
1 parent 4a3906e commit 5092f37

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/tests/test_configobj.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,23 @@ def test_with_hash(self):
640640
'key4': [1, 2, 3, 'a mixed list#']
641641
}
642642

643+
def test_empty_value(self):
644+
cfg = ConfigObj(['k = '], unrepr=True)
645+
assert cfg == {'k': ''}
646+
647+
def test_unclosed_quote(self):
648+
with pytest.raises(co.UnreprError) as excinfo:
649+
ConfigObj(['k = "'], unrepr=True)
650+
assert str(excinfo.value) == (
651+
"Parse error from unrepr-ing value at line 1.")
652+
653+
def test_multiline_string_empty(self):
654+
config = ['k = """', '"""']
655+
with pytest.raises(co.UnreprError) as excinfo:
656+
ConfigObj(config, unrepr=True)
657+
assert str(excinfo.value) == (
658+
"Parse error from unrepr-ing multiline value at line 2.")
659+
643660

644661
class TestValueErrors(object):
645662
def test_bool(self, empty_cfg):

0 commit comments

Comments
 (0)