Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tests/test_process_tests.py
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
import os
import re
import sys
import socket

import pytest
Expand All@@ -13,7 +14,7 @@


def test_wait_for_strings():
with TestProcess('python', '-c', 'print("foobar")') as proc:
with TestProcess(sys.executable, '-c', 'print("foobar")') as proc:
wait_for_strings(proc.read, TIMEOUT, 'foobar')
with pytest.raises(AssertionError):
with dump_on_error(proc.read):
Expand All@@ -22,15 +23,15 @@ def test_wait_for_strings():

def test_filebuffer(tmp_path):
with tmp_path.joinpath('stdout').open('wb') as fh:
with TestProcess('python', '-c', 'print("foobar")', stdout=fh) as proc:
with TestProcess(sys.executable, '-c', 'print("foobar")', stdout=fh) as proc:
wait_for_strings(proc.read, TIMEOUT, 'foobar')
with pytest.raises(AssertionError):
with dump_on_error(proc.read):
wait_for_strings(proc.read, 0.1, 'cannot be')


def test_socket():
with TestProcess('python', '-mhttp.server', '0') as proc:
with TestProcess(sys.executable, '-mhttp.server', '0') as proc:
with dump_on_error(proc.read, 'SERVER'):
wait_for_strings(proc.read, TIMEOUT, 'Serving HTTP on')
(port,) = re.match(r'Serving HTTP on .*? port (\d+) ', proc.read()).groups()
Expand Down