Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
LinterSchema bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Aug 4, 2017
1 parent 7ec2077 commit 5dddbf5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions badwolf/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _preprocess(self, linter):
if isinstance(linter, dict):
name = linter.pop('name', None)
pattern = linter.pop('pattern', None)
self.__additional_values = linter
self.__additional_values[name] = linter
else:
name = linter
pattern = None
Expand All @@ -136,7 +136,7 @@ def _preprocess(self, linter):

@post_load
def _postprocess(self, data):
data.update(self.__additional_values)
data.update(self.__additional_values.pop(data['name'], {}))
return ObjectDict(data)


Expand Down
7 changes: 5 additions & 2 deletions tests/test_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,13 @@ def test_parse_simple_linter(app):


def test_parse_linter_with_pattern(app):
s = """linter: {name: "flake8", pattern: "*.py", whatever: 123}"""
s = """linter:
- {name: "flake8", pattern: "*.py", whatever: 123}
- {name: "jsonlint", pattern: "*.mapping"}
- yamllint"""
f = io.StringIO(s)
spec = Specification.parse_file(f)
assert len(spec.linters) == 1
assert len(spec.linters) == 3
linter0 = spec.linters[0]
assert linter0.name == 'flake8'
assert linter0.pattern == '*.py'
Expand Down

0 comments on commit 5dddbf5

Please sign in to comment.