Skip to content

Commit 86bf8b5

Browse files
crazydemoRansiki
authored andcommitted
tests: only get timeout value from pytest marker (NVIDIA#6287)
Signed-off-by: Ivy Zhang <[email protected]> Signed-off-by: Ransiki Zhang <[email protected]>
1 parent 6efa1b5 commit 86bf8b5

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

tests/integration/defs/trt_test_alternative.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ def call(*popenargs,
208208
poll_procs = poll_procs or []
209209
if not suppress_output_info:
210210
print(f"Start subprocess with call({popenargs}, {kwargs})")
211-
actual_timeout = get_pytest_timeout(timeout)
212211
with popen(*popenargs,
213212
start_new_session=start_new_session,
214213
suppress_output_info=True,
@@ -219,7 +218,7 @@ def call(*popenargs,
219218
return p.wait(timeout=spin_time)
220219
except subprocess.TimeoutExpired:
221220
elapsed_time += spin_time
222-
if actual_timeout is not None and elapsed_time >= actual_timeout:
221+
if timeout is not None and elapsed_time >= timeout:
223222
raise
224223
for p_poll in poll_procs:
225224
if p_poll.poll() is None:
@@ -240,13 +239,12 @@ def check_call(*popenargs, **kwargs):
240239

241240
def check_output(*popenargs, timeout=None, start_new_session=True, **kwargs):
242241
print(f"Start subprocess with check_output({popenargs}, {kwargs})")
243-
actual_timeout = get_pytest_timeout(timeout)
244242
with Popen(*popenargs,
245243
stdout=subprocess.PIPE,
246244
start_new_session=start_new_session,
247245
**kwargs) as process:
248246
try:
249-
stdout, stderr = process.communicate(None, timeout=actual_timeout)
247+
stdout, stderr = process.communicate(None, timeout=timeout)
250248
except subprocess.TimeoutExpired as exc:
251249
cleanup_process_tree(process, start_new_session)
252250
if is_windows():
@@ -321,26 +319,3 @@ def check_call_negative_test(*popenargs, **kwargs):
321319
f"Subprocess expected to fail with check_call_negative_test({popenargs}, {kwargs}), but passed."
322320
)
323321
raise subprocess.CalledProcessError(1, cmd)
324-
325-
326-
def get_pytest_timeout(timeout=None):
327-
try:
328-
import pytest
329-
marks = None
330-
try:
331-
current_item = pytest.current_test
332-
if hasattr(current_item, 'iter_markers'):
333-
marks = list(current_item.iter_markers('timeout'))
334-
except (AttributeError, NameError):
335-
pass
336-
337-
if marks and len(marks) > 0:
338-
timeout_mark = marks[0]
339-
timeout_pytest = timeout_mark.args[0] if timeout_mark.args else None
340-
if timeout_pytest and isinstance(timeout_pytest, (int, float)):
341-
return max(30, int(timeout_pytest * 0.9))
342-
343-
except (ImportError, Exception) as e:
344-
print(f"Error getting pytest timeout: {e}")
345-
346-
return timeout

0 commit comments

Comments
 (0)