Coverage for src/engines/pexpect.py: 100.00%
14 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-22 10:53 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-22 10:53 +0000
1#!/usr/bin/env python3
3# Coverage
4# pragma: linux cover file
6# Modules libraries
7from pexpect import EOF, spawn, TIMEOUT # pylint: disable=import-error
9# Components
10from .base import Base
12# Pexpect class
13class Pexpect(Base):
15 # Constructor
16 def __init__(self, command: str) -> None: # pylint: disable=super-init-not-called
18 # Spawn command
19 self._child = spawn('sh', ['-c', command])
21 # Read
22 def _read(self) -> bytes | str:
24 # Acquire output, pylint: disable=duplicate-code
25 assert self._child is not None
26 try:
27 result = self._child.read_nonblocking(size=1024, timeout=1)
28 assert isinstance(result, (bytes, str))
29 return result
30 except (AttributeError, EOF, TIMEOUT):
31 pass
33 # Empty output
34 return ''