Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python35
/
lib
/
python3.5
/
site-packages
/
joblib
/
__pycache__
/
File Content:
testing.cpython-35.opt-1.pyc
-|�W� � @ s� d Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d � Z y d d l m Z WnJ e k r� y d d l m Z Wn! e k r� d d d � Z Yn XYn Xd d d d d � Z d S) z Helper for testing. � N)�PY3_OR_LATERc s. t j � d d � f d d � } | t _ d S)z& Redirect all warnings to stdout. Nr c s) � | | t j j | � | t j � d S)N)�os�path�basename�sys�stdout)�msg�catZfname�lno�file�line)�showwarning_orig� �/testing.py�showwarning s z'warnings_to_stdout.<locals>.showwarning)�warningsr )r r )r r �warnings_to_stdout s r )�assert_raises_regex)�assert_raises_regexpc O s� d } y | | | � d } Wn_ t k r~ } z? t | � } t j | � j | � sl t d | | f � � WYd d } ~ Xn X| r� t d | | � � � d S)z;Helper function to check for message patterns in exceptionsFTz3Error message should match pattern %r. %r does not.NzShould have raised %r)� Exception�str�re�compile�search�AssertionError)Zexpected_exceptionZexpected_regexpZcallable_obj�args�kwargsZ not_raised�eZ error_messager r r r # s #r � c s7 t j | d t j d t j �� � f d d � } t j | | � } z� | j � � j � \ } } t r� | j � | j � } } � j d k r� d j � j | | � } t | � � | d k r� t j | | � r� t d j | | � � � | d k r$t j | | � r$t d j | | � � � Wd | j � Xd S) z�Runs a command in a subprocess with timeout in seconds. Also checks returncode is zero, stdout if stdout_regex is set, and stderr if stderr_regex is set. r �stderrc s � j � d S)N)�killr )�procr r �kill_process@ s z+check_subprocess_call.<locals>.kill_processr z2Non-zero return code: {0}. Stdout: {1} Stderr: {2}Nz.Unexpected stdout: {0!r} does not match: {1!r}z.Unexpected stderr: {0!r} does not match: {1!r})� subprocess�Popen�PIPE� threading�Timer�start�communicater �decode� returncode�format� ValueErrorr r �cancel) �cmd�timeoutZstdout_regexZstderr_regexr"