Skip to content

Commit

Permalink
Add test for #66.
Browse files Browse the repository at this point in the history
  • Loading branch information
ionelmc committed Dec 18, 2023
1 parent f4adf45 commit b191bf9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ def cleanup():
manhole.install(oneshot_on='USR2')
manhole.install(strict=False)
time.sleep(TIMEOUT)
elif test_name == 'test_unbuffered':
manhole.install(verbose=True)
print(os.getpid())
for i in range(5):
time.sleep(1)
print(f'line{i}')
sys.stdout.flush()
elif test_name == 'test_log_fd':
manhole.install(verbose=True, verbose_destination=2)
manhole._LOG('whatever-1')
Expand Down
12 changes: 11 additions & 1 deletion tests/test_manhole_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_help(testdir):
'Connect to a manhole.',
'positional arguments:',
' PID A numerical process id, or a path in the form:*',
'optional arguments:',
'options:',
' -h, --help show this help message and exit',
' -t TIMEOUT, --timeout TIMEOUT',
' Timeout to use. Default: 1 seconds.',
Expand Down Expand Up @@ -125,3 +125,13 @@ def test_sig_usr2_number():
wait_for_strings(client.read, TIMEOUT, '(ManholeConsole)', '>>>')
client.proc.stdin.write('1234+2345\n')
wait_for_strings(client.read, TIMEOUT, '3579')


def test_unbuffered():
with TestProcess(sys.executable, '-u', HELPER, 'test_unbuffered') as service:
with dump_on_error(service.read):
with TestProcess('manhole-cli', str(service.proc.pid), bufsize=0, stdin=subprocess.PIPE) as client:
with dump_on_error(client.read):
wait_for_strings(client.read, TIMEOUT, '(ManholeConsole)', '>>>')
for i in range(5):
wait_for_strings(client.read, 1, f'line{i}')

0 comments on commit b191bf9

Please sign in to comment.