Skip to content

Commit

Permalink
Merge 490dab3 into fa4602e
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain Ernandez committed May 2, 2021
2 parents fa4602e + 490dab3 commit 72ac3ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions petl/io/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ class DictsView(Table):

def __init__(self, dicts, header=None, sample=1000, missing=None):
self.dicts = dicts
self.header = header
self._header = header
self.sample = sample
self.missing = missing

def __iter__(self):
return iterdicts(self.dicts, self.header, self.sample, self.missing)
return iterdicts(self.dicts, self._header, self.sample, self.missing)


def iterjlines(f, header, missing):
Expand Down
8 changes: 8 additions & 0 deletions petl/test/io/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,11 @@ def test_tojsonarrays():
assert result[1][1] == 2
assert result[2][0] == 'c'
assert result[2][1] == 2


def test_fromdicts_header_does_not_raise():
data = [{'foo': 'a', 'bar': 1},
{'foo': 'b', 'bar': 2},
{'foo': 'c', 'bar': 2}]
actual = fromdicts(data)
assert actual.header() == ("foo", "bar")

0 comments on commit 72ac3ab

Please sign in to comment.