ui: write_json: don't forget json kwargs (#6810)

Regression from #6743

Fixes #6803
This commit is contained in:
Ruslan Kuprieiev
2021-10-15 01:30:22 +03:00
committed by GitHub
parent 259d590527
commit 7f5c53c10e
2 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -98,7 +98,7 @@ class Console:
text.overflow = None
return self.write(text, styled=True)
return self.write(json.dumps(data))
return self.write(json.dumps(data, default=default))
def write(
self,
+6 -4
View File
@@ -1,3 +1,4 @@
import datetime
import textwrap
import pytest
@@ -27,7 +28,8 @@ def test_write(capsys: CaptureFixture[str]):
textwrap.dedent(
"""\
{
"hello": "world"
"hello": "world",
"date": "1970-01-01 00:00:00"
}
"""
),
@@ -36,7 +38,7 @@ def test_write(capsys: CaptureFixture[str]):
False,
textwrap.dedent(
"""\
{"hello": "world"}
{"hello": "world", "date": "1970-01-01 00:00:00"}
"""
),
),
@@ -49,8 +51,8 @@ def test_write_json(
console = Console(enable=True)
mocker.patch.object(console, "isatty", return_value=isatty)
message = {"hello": "world"}
console.write_json(message)
message = {"hello": "world", "date": datetime.datetime(1970, 1, 1)}
console.write_json(message, default=str)
captured = capsys.readouterr()
assert captured.out == expected_output