esptest.adapter.dut.dut_base module

class esptest.adapter.dut.dut_base.DutConfig(name: str = '', device: str = '', baudrate: int = 0, baudrate_from_bin_path: bool = True, serial_configs: Dict[str, Any] | None = None, support_esptool: bool = False, esptool_stub: bool = True, esptool_chip: str = 'auto', create_redirect_thread: bool = True, opened_port: Any = None, bin_path: str | pathlib.Path = '', use_esptool: str = '', download_device: str = '', download_baudrate: int = 0, log_path: str | pathlib.Path = '', log_file: str = '', rx_log_formater: logging.Formatter | None = None, tx_log_formater: logging.Formatter | None = None, logger: logging.Logger | None = None, tx_log_callback: Callable[[str, bytes, str], NoneType] | None = None, rx_log_callback: Callable[[str, bytes, str], NoneType] | None = None, monitors: object | None = None, pexpect_timeout: float = 30, kwargs: Dict[str, Any] | None = None)[source]

Bases: object

Parameters:
name: str = ''
device: str = ''
baudrate: int = 0
baudrate_from_bin_path: bool = True
serial_configs: Dict[str, Any] | None = None
support_esptool: bool = False
esptool_stub: bool = True
esptool_chip: str = 'auto'
create_redirect_thread: bool = True
opened_port: Any = None
bin_path: str | Path = ''
use_esptool: str = ''
download_device: str = ''
download_baudrate: int = 0
log_path: str | Path = ''
log_file: str = ''
rx_log_formater: Formatter | None = None
tx_log_formater: Formatter | None = None
logger: Logger | None = None
tx_log_callback: Callable[[str, bytes, str], None] | None = None
rx_log_callback: Callable[[str, bytes, str], None] | None = None
monitors: object | None = None
pexpect_timeout: float = 30
kwargs: Dict[str, Any] | None = None
property serial_read_timeout: float
class esptest.adapter.dut.dut_base.VariablesMixin(*args, **kwargs)[source]

Bases: object

Parameters:
get_variable_by_name(name, default=None)[source]
Parameters:
Return type:

Any

add_variable(name, value)[source]
Parameters:
Return type:

None

remove_variable(name)[source]
Parameters:

name (str)

Return type:

None

add_dynamic_variable(name, value)[source]
Parameters:
Return type:

None

remove_dynamic_variable(name)[source]
Parameters:

name (str)

Return type:

None

class esptest.adapter.dut.dut_base.DutBase(*, dut_config, **kwargs)[source]

Bases: VariablesMixin, DataMonitorMixin, _DutBase

A base Dut class

Parameters:
BASE_PORT_PROXY_METHODS = ['data_cache', 'read_all_data', '__enter__', 'flush_data', 'write', 'read_all_bytes', 'clear_monitors', 'raw_port', 'expect', '__exit__', 'remove_monitor', 'close', 'write_line', 'set_rx_log_callback', 'add_monitor', 'name']
setup_dut()[source]

Flash / hard reset

Return type:

None

property dut_config: DutConfig
property dut_logger: Logger
property target: str
property esp: ESPLoader

Not all Dut support this method

close()[source]
Return type:

None

property bin_path: str | Path
property sdkconfig: Dict[str, Any]
hard_reset()[source]
Return type:

None

flash(erase_nvs=True)[source]
Parameters:

erase_nvs (bool)

Return type:

None

flash_partition(part, bin_file='')[source]
Parameters:
Return type:

None

dump_flash(part, bin_file, size=0)[source]
Parameters:
Return type:

None

property raw_port: Any
property log_file: Any
property rx_log_callback: Callable[[str, bytes], None] | None

Get Current dut log file.

set_rx_log_callback(new_callback)[source]
Parameters:

new_callback (Callable[[str, bytes], None] | None)

Return type:

None

property monitors: List[DataMonitor]
property name: Any
write(data)[source]
Parameters:

data (AnyStr)

Return type:

None

write_line(data, end='\n')[source]
Parameters:
  • data (AnyStr)

  • end (str)

Return type:

None

expect(pattern: str, timeout: float = 30) None[source]
expect(pattern: bytes, timeout: float = 30) None
expect(pattern: Pattern[str], timeout: float = 30) Match[str]
expect(pattern: Pattern[bytes], timeout: float = 30) Match[bytes]
property data_cache: str
flush_data()[source]
Return type:

str

read_all_data(flush=True)[source]
Parameters:

flush (bool)

Return type:

str

read_all_bytes(flush=False)[source]
Parameters:

flush (bool)

Return type:

bytes

start_redirect_thread()[source]

Start a new thread to read data from port and save to data cache.

Return type:

None

stop_redirect_thread()[source]

Stop the redirect thread and pexpect process.

Return type:

bool

disable_redirect_thread()[source]
Return type:

Generator[None, None, None]