Skip to content

Commit

Permalink
Boolean values should be output as bool in JSON. (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Prescod authored May 12, 2022
1 parent fff7c66 commit 4a51f8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions snowfakery/output_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ class JSONOutputStream(FileOutputStream):
**OutputStream.encoders,
datetime.date: str,
datetime.datetime: str,
bool: bool,
}
is_text = True

Expand Down
9 changes: 9 additions & 0 deletions tests/test_output_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ def test_error_generates_empty_string(self):
output_stream.close()
assert s.getvalue() == ""

def test_bool(self):
yaml = """
- object: foo
fields:
is_true: True
"""
values = self.do_output(yaml)["foo"][0]
assert values["is_true"] is True


class TestCSVOutputStream(OutputCommonTests):
def do_output(self, yaml):
Expand Down

0 comments on commit 4a51f8f

Please sign in to comment.