userver: samples/json2yaml/testsuite/test_basic.py
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
samples/json2yaml/testsuite/test_basic.py
1# /// [pytest]
2import subprocess
3
4_EXPECTED_OUTPUT = """key:
5 nested-key:
6 - 1
7 - 2
8 - hello!
9 - key-again: 42
10"""
11
12
13def test_basic(path_to_json2yaml):
14 pipe = subprocess.Popen(
15 [path_to_json2yaml],
16 stdout=subprocess.PIPE,
17 stderr=subprocess.PIPE,
18 stdin=subprocess.PIPE,
19 )
20 stdout, stderr = pipe.communicate(
21 input=b'{"key":{"nested-key": [1, 2.0, "hello!", {"key-again": 42}]}}',
22 )
23 assert stdout.decode('utf-8') == _EXPECTED_OUTPUT, stderr
24 # /// [pytest]