Skip to content

Commit

Permalink
Add tests for unrepr parse errors and edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
bz2 committed Mar 17, 2017
1 parent 4a3906e commit 5092f37
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/tests/test_configobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,23 @@ def test_with_hash(self):
'key4': [1, 2, 3, 'a mixed list#']
}

def test_empty_value(self):
cfg = ConfigObj(['k = '], unrepr=True)
assert cfg == {'k': ''}

def test_unclosed_quote(self):
with pytest.raises(co.UnreprError) as excinfo:
ConfigObj(['k = "'], unrepr=True)
assert str(excinfo.value) == (
"Parse error from unrepr-ing value at line 1.")

def test_multiline_string_empty(self):
config = ['k = """', '"""']
with pytest.raises(co.UnreprError) as excinfo:
ConfigObj(config, unrepr=True)
assert str(excinfo.value) == (
"Parse error from unrepr-ing multiline value at line 2.")


class TestValueErrors(object):
def test_bool(self, empty_cfg):
Expand Down

0 comments on commit 5092f37

Please sign in to comment.