a
    Wa1                     @   sL   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ G dd deZdS )    N)SambaToolCmdTest)BlackboxProcessError)check_help_consistency)
get_stringc                   @   s    e Zd ZdZdd Zdd ZdS )HelpTestCasezVTests for samba-tool help and --help

    We test for consistency and lack of crashes.c                 C   s   | j |  d S )N)Zruncmd)selfargs r	   =/usr/lib/python3/dist-packages/samba/tests/samba_tool/help.py_find_sub_commands    s    zHelpTestCase._find_sub_commandsc                 C   sx  g g}g }t dD ]R}g }|D ]2}ddg| dg }z| |}W n4 ty~ } z|j}|| W Y d }~n
d }~0 0 t|}|dd }	t	d|	tj
}
|
D ]}|||g  qdddg| }z| |}W n6 ty } z|j}|| W Y d }~n
d }~0 0 t|}| || t|d	dd
}|d ur | d||f  q |sb qh|}q| |g  d S )N    z
samba-toolz--helpzAvailable subcommands:   z^\s*([\w-]+)\s+-helpzOptions:)Zoptions_startZoptions_endzconsistency error with %s:
%s)rangejoinZcheck_outputr   stdoutappendr   	partitionrefindall	MULTILINEZassertEqualr   Zfail)r   Zknown_commandsZfailed_commandsiZnew_commandsclineoutputetailZsubcommandssZoutput2errr	   r	   r
   test_help_tree#   sH    
  zHelpTestCase.test_help_treeN)__name__
__module____qualname____doc__r   r    r	   r	   r	   r
   r      s   r   )	r   Zsamba.tests.samba_tool.baser   Zsamba.testsr   r   Zsamba.compatr   r   r	   r	   r	   r
   <module>   s
   