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
29 changes: 2 additions & 27 deletions tests/integration/defs/trt_test_alternative.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ def call(*popenargs,
poll_procs = poll_procs or []
if not suppress_output_info:
print(f"Start subprocess with call({popenargs}, {kwargs})")
actual_timeout = get_pytest_timeout(timeout)
with popen(*popenargs,
start_new_session=start_new_session,
suppress_output_info=True,
Expand All @@ -219,7 +218,7 @@ def call(*popenargs,
return p.wait(timeout=spin_time)
except subprocess.TimeoutExpired:
elapsed_time += spin_time
if actual_timeout is not None and elapsed_time >= actual_timeout:
if timeout is not None and elapsed_time >= timeout:
raise
for p_poll in poll_procs:
if p_poll.poll() is None:
Expand All @@ -240,13 +239,12 @@ def check_call(*popenargs, **kwargs):

def check_output(*popenargs, timeout=None, start_new_session=True, **kwargs):
print(f"Start subprocess with check_output({popenargs}, {kwargs})")
actual_timeout = get_pytest_timeout(timeout)
with Popen(*popenargs,
stdout=subprocess.PIPE,
start_new_session=start_new_session,
**kwargs) as process:
try:
stdout, stderr = process.communicate(None, timeout=actual_timeout)
stdout, stderr = process.communicate(None, timeout=timeout)
except subprocess.TimeoutExpired as exc:
cleanup_process_tree(process, start_new_session)
if is_windows():
Expand Down Expand Up @@ -321,26 +319,3 @@ def check_call_negative_test(*popenargs, **kwargs):
f"Subprocess expected to fail with check_call_negative_test({popenargs}, {kwargs}), but passed."
)
raise subprocess.CalledProcessError(1, cmd)


def get_pytest_timeout(timeout=None):
try:
import pytest
marks = None
try:
current_item = pytest.current_test
if hasattr(current_item, 'iter_markers'):
marks = list(current_item.iter_markers('timeout'))
except (AttributeError, NameError):
pass

if marks and len(marks) > 0:
timeout_mark = marks[0]
timeout_pytest = timeout_mark.args[0] if timeout_mark.args else None
if timeout_pytest and isinstance(timeout_pytest, (int, float)):
return max(30, int(timeout_pytest * 0.9))

except (ImportError, Exception) as e:
print(f"Error getting pytest timeout: {e}")

return timeout