Make JSON reading test a bit more robust

This commit is contained in:
Kovid Goyal 2022-07-13 19:14:59 +05:30
parent cb0d23bae8
commit 94551623ec
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -47,7 +47,6 @@ def report_screen_size_change(*a):
'font_family': get_options().font_family,
'cols': read_screen_size(fd=sys.stderr.fileno()).cols,
'stdin_data': sys.stdin.read(),
'done': 'hello',
}
print(json.dumps(output, indent=2), file=sys.stderr, flush=True)
@ -114,7 +113,12 @@ def wait_for_death(exit_code, timeout=5):
stdin_data = 'testing--stdin-read'
with open(stdin_w, 'w') as f:
f.write(stdin_data)
pty.wait_till(lambda: 'hello' in pty.screen_contents())
def has_json():
s = pty.screen_contents().strip()
return 'hello' in s and s.endswith('}')
pty.wait_till(has_json)
wait_for_death(exit_code)
output = json.loads(pty.screen_contents().strip())
self.assertEqual(output['test_env'], env['TEST_ENV_PASS'])