add test for valid json-output

This commit is contained in:
Roman v. Gemmeren
2020-03-31 13:10:46 +02:00
parent 648b578abd
commit d167f4556e

View File

@@ -25,6 +25,7 @@ import pty
import shutil import shutil
import sys import sys
import unittest import unittest
import json
from tests.common import build_temp_workspace from tests.common import build_temp_workspace
@@ -517,3 +518,11 @@ class CommandLineTestCase(unittest.TestCase):
'\n' % path) '\n' % path)
self.assertEqual( self.assertEqual(
(ctx.returncode, ctx.stdout, ctx.stderr), (1, expected_out, '')) (ctx.returncode, ctx.stdout, ctx.stderr), (1, expected_out, ''))
def test_json_output(self):
path = os.path.join(self.wd, 'a.yaml')
with RunContext(self) as ctx:
cli.run(('-f', 'json', path))
print (ctx.stdout)
self.assertTrue(json.loads(ctx.stdout))