Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unhelpful error message when nesting invalid. #67

Merged
merged 1 commit into from
Aug 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions configobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,7 @@ def _parse(self, infile):
else:
self._handle_error("Section too nested",
NestingError, infile, cur_index)
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now I'm curious if this was ever there and then omitted

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's strange - all the other error branches seem to have the continue statement.


sect_name = self._unquote(sect_name)
if sect_name in parent:
Expand Down
9 changes: 8 additions & 1 deletion tests/test_validate_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from configobj import ConfigObj, get_extra_values, ParseError
from configobj import ConfigObj, get_extra_values, ParseError, NestingError
from validate import Validator

@pytest.fixture()
Expand Down Expand Up @@ -70,3 +70,10 @@ def test_invalid_lines_with_percents(tmpdir, specpath):
ini.write('extra: %H:%M\n')
with pytest.raises(ParseError):
conf = ConfigObj(str(ini), configspec=specpath, file_error=True)


def test_no_parent(tmpdir, specpath):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray for pull requests that come with tests.

ini = tmpdir.join('config.ini')
ini.write('[[haha]]')
with pytest.raises(NestingError):
conf = ConfigObj(str(ini), configspec=specpath, file_error=True)