U
    kufe                     @  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_strerr_str r   9/tmp/pip-unpacked-wheel-utpcgctl/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sBt|d|ksNtd|ksZtd|ksft||fS )z/test that `python -m PKG [subcommand] -h` works-mz-hr   	TracebackOptions
--help-allsys
executableextendappendr   AssertionError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sBt|d|ksNtd|ksZtd|ksft||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   	