← Back
Editing: testr_command.cpython-38.pyc
U jP�^� � @ s� d Z ddlmZ ddlZddlZddlZddlZddlZe�e �Z G dd� dej�ZG dd� dej�Z zddlmZ d ZeZW n ek r� d Ze ZY nX dS )a� setuptools/distutils command to run testr via setup.py PBR will hook in the Testr class to provide "setup.py test" when .testr.conf is present in the repository (see pbr/hooks/commands.py). If we are activated but testrepository is not installed, we provide a sensible error. You can pass --coverage which will also export PYTHON='coverage run --source <your package>' and automatically combine the coverage from each testr backend test runner after the run completes. � )�cmdNc @ s\ e Zd ZdZdddddddgZd d dgZdd � Zdd� Zdd� Zdd� Z dd� Z dd� ZdS )� TestrRealz&DEPRECATED: Run unit tests using testr)�coverageNzGReplace PYTHON with coverage and merge coverage from each testr worker.)ztestr-args=�tzRun 'testr' with these args)zomit=�oz(Files to omit from coverage calculations)zcoverage-package-name=NzLUse this name to select packages for coverage (one or more, comma-separated))�slowestNz-Show slowest test times after tests complete.)zno-parallelNzRun testr serially)z log-level=�lzLog level (default: info)r r �no_parallelc G s2 t �d|� t�tjd gt|� tjtjtj �S )Nz _run_testr called with args = %rr ) �logger�debug�commandsZrun_argv�sys�argv�list�stdin�stdout�stderr)�self�args� r �3/usr/lib/python3/dist-packages/pbr/testr_command.py� _run_testrH s �zTestrReal._run_testrc C s. d | _ d | _d| _d | _d | _d | _d| _d S )N� �info)� testr_argsr �omitr �coverage_package_namer � log_level�r r r r �initialize_optionsM s zTestrReal.initialize_optionsc C sp t t| j�� tj�| _tj| jd� t�d� | jd kr@g | _n| j� � | _| j r^d| j | _ t�d| j� d S )N)�levelzfinalize_options calledz --omit=%sz$finalize_options: self.__dict__ = %r)�getattr�loggingr �upper�INFOZbasicConfigr r r �splitr �__dict__r r r r �finalize_optionsV s � zTestrReal.finalize_optionsc C s� t �d� t�dt� tj�d�s,| �d� | j r:| � � | jsR| jd| j�� }n| jd| j�� }|rvt j�d| ��| jr�td� | �d � | j r�| �� d S ) z"Set up testr repo, then run testr.z run calledzctestr integration in pbr is deprecated. Please use the 'testr' setup command or call testr directlyz.testrepositoryZinit�run� --parallelztestr failed (%d)z Slowest Testsr N)r( r) )r( )r r �warnings�warn�DeprecationWarning�os�path�isdirr r �_coverage_beforer r � distutils�errorsZDistutilsErrorr �print�_coverage_after)r Z testr_retr r r r( e s( � � z TestrReal.runc C sb t �d� | j�� }|�d�r*|dd � }| jr6| j}d| }d| tjd<