a
    õ£Be_  ã                   @  sp   d dl mZ d dlZd dlmZmZ d dlmZmZ dddœdd	„Z	dd
dddœdd„Z
dd
dddœdd„ZdS )é    )ÚannotationsN)ÚPIPEÚPopen)ÚAnyÚSequencezstr | Sequence[str]ztuple[str, str, Any])ÚcmdÚreturnc                 C  s>   t | ttd�}| ¡ \}}| dd¡}| dd¡}|||jfS )z8Get stdout, stderr, and exit code from running a command)ÚstdoutÚstderrÚutf8Úreplace)r   r   ÚcommunicateÚdecodeÚ
returncode)r   ÚpÚoutÚerrZout_strZerr_str© r   úX/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/traitlets/tests/utils.pyÚget_output_error_code   s
    r   ÚstrzSequence[str] | Noneztuple[str, str])ÚpkgÚ
subcommandr   c                 C  sn   t jd| g}|r| |¡ | d¡ t|ƒ\}}}|dksBJ |ƒ‚d|vsNJ ‚d|v sZJ ‚d|v sfJ ‚||fS )z/test that `python -m PKG [subcommand] -h` worksú-mz-hr   Ú	TracebackÚOptionsú
--help-all©ÚsysÚ
executableÚextendÚappendr   ©r   r   r   r   r   Úrcr   r   r   Úcheck_help_output   s    

r$   c                 C  sn   t jd| g}|r| |¡ | d¡ t|ƒ\}}}|dksBJ |ƒ‚d|vsNJ ‚d|v sZJ ‚d|v sfJ ‚||fS )z*test that `python -m PKG --help-all` worksr   r   r   r   r   zClass optionsr   r"   r   r   r   Úcheck_help_all_output   s    

r%   )N)N)Ú
__future__r   r   Ú
subprocessr   r   Útypingr   r   r   r$   r%   r   r   r   r   Ú<module>   s   	