/home/fresvfqn/waterdamagerestorationandrepairsmithtown.com/Compressed/test.tar
script_helper.py000064400000000051150532427410007760 0ustar00from test.support.script_helper import *
test_support.pyc000064400000000401150532427410010032 0ustar00�
zfc@s,ddlZddlZejejd<dS(i����Nstest.test_support(tsysttest.supportttesttsupporttmodules(((s)/usr/lib64/python2.7/test/test_support.pyt<module>ssupport/script_helper.py000064400000013263150532427410011505 0ustar00# Common utility functions used by various script execution tests
#  e.g. test_cmd_line, test_cmd_line_script and test_runpy

import sys
import os
import re
import os.path
import tempfile
import subprocess
import py_compile
import contextlib
import shutil
try:
    import zipfile
except ImportError:
    # If Python is build without Unicode support, importing _io will
    # fail, which, in turn, means that zipfile cannot be imported
    # Most of this module can then still be used.
    pass

from test.support import strip_python_stderr

# Executing the interpreter in a subprocess
def _assert_python(expected_success, *args, **env_vars):
    cmd_line = [sys.executable]
    if not env_vars:
        cmd_line.append('-E')
    cmd_line.extend(args)
    # Need to preserve the original environment, for in-place testing of
    # shared library builds.
    env = os.environ.copy()
    env.update(env_vars)
    p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                         env=env)
    try:
        out, err = p.communicate()
    finally:
        subprocess._cleanup()
        p.stdout.close()
        p.stderr.close()
    rc = p.returncode
    err =  strip_python_stderr(err)
    if (rc and expected_success) or (not rc and not expected_success):
        raise AssertionError(
            "Process return code is %d, "
            "stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore')))
    return rc, out, err

def assert_python_ok(*args, **env_vars):
    """
    Assert that running the interpreter with `args` and optional environment
    variables `env_vars` is ok and return a (return code, stdout, stderr) tuple.
    """
    return _assert_python(True, *args, **env_vars)

def assert_python_failure(*args, **env_vars):
    """
    Assert that running the interpreter with `args` and optional environment
    variables `env_vars` fails and return a (return code, stdout, stderr) tuple.
    """
    return _assert_python(False, *args, **env_vars)

def python_exit_code(*args):
    cmd_line = [sys.executable, '-E']
    cmd_line.extend(args)
    with open(os.devnull, 'w') as devnull:
        return subprocess.call(cmd_line, stdout=devnull,
                                stderr=subprocess.STDOUT)

def spawn_python(*args, **kwargs):
    cmd_line = [sys.executable, '-E']
    cmd_line.extend(args)
    return subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                            **kwargs)

def kill_python(p):
    p.stdin.close()
    data = p.stdout.read()
    p.stdout.close()
    # try to cleanup the child so we don't appear to leak when running
    # with regrtest -R.
    p.wait()
    subprocess._cleanup()
    return data

def run_python(*args, **kwargs):
    if __debug__:
        p = spawn_python(*args, **kwargs)
    else:
        p = spawn_python('-O', *args, **kwargs)
    stdout_data = kill_python(p)
    return p.wait(), stdout_data

# Script creation utilities
@contextlib.contextmanager
def temp_dir():
    dirname = tempfile.mkdtemp()
    dirname = os.path.realpath(dirname)
    try:
        yield dirname
    finally:
        shutil.rmtree(dirname)

def make_script(script_dir, script_basename, source):
    script_filename = script_basename+os.extsep+'py'
    script_name = os.path.join(script_dir, script_filename)
    script_file = open(script_name, 'w')
    script_file.write(source)
    script_file.close()
    return script_name

def compile_script(script_name):
    py_compile.compile(script_name, doraise=True)
    if __debug__:
        compiled_name = script_name + 'c'
    else:
        compiled_name = script_name + 'o'
    return compiled_name

def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None):
    zip_filename = zip_basename+os.extsep+'zip'
    zip_name = os.path.join(zip_dir, zip_filename)
    zip_file = zipfile.ZipFile(zip_name, 'w')
    if name_in_zip is None:
        name_in_zip = os.path.basename(script_name)
    zip_file.write(script_name, name_in_zip)
    zip_file.close()
    #if test.test_support.verbose:
    #    zip_file = zipfile.ZipFile(zip_name, 'r')
    #    print 'Contents of %r:' % zip_name
    #    zip_file.printdir()
    #    zip_file.close()
    return zip_name, os.path.join(zip_name, name_in_zip)

def make_pkg(pkg_dir, init_source=''):
    os.mkdir(pkg_dir)
    make_script(pkg_dir, '__init__', init_source)

def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
                 source, depth=1, compiled=False):
    unlink = []
    init_name = make_script(zip_dir, '__init__', '')
    unlink.append(init_name)
    init_basename = os.path.basename(init_name)
    script_name = make_script(zip_dir, script_basename, source)
    unlink.append(script_name)
    if compiled:
        init_name = compile_script(init_name)
        script_name = compile_script(script_name)
        unlink.extend((init_name, script_name))
    pkg_names = [os.sep.join([pkg_name]*i) for i in range(1, depth+1)]
    script_name_in_zip = os.path.join(pkg_names[-1], os.path.basename(script_name))
    zip_filename = zip_basename+os.extsep+'zip'
    zip_name = os.path.join(zip_dir, zip_filename)
    zip_file = zipfile.ZipFile(zip_name, 'w')
    for name in pkg_names:
        init_name_in_zip = os.path.join(name, init_basename)
        zip_file.write(init_name, init_name_in_zip)
    zip_file.write(script_name, script_name_in_zip)
    zip_file.close()
    for name in unlink:
        os.unlink(name)
    #if test.test_support.verbose:
    #    zip_file = zipfile.ZipFile(zip_name, 'r')
    #    print 'Contents of %r:' % zip_name
    #    zip_file.printdir()
    #    zip_file.close()
    return zip_name, os.path.join(zip_name, script_name_in_zip)
support/script_helper.pyc000064400000013431150532427410011645 0ustar00�
{fc@s.ddlZddlZddlZddlZddlZddlZddlZddlZddlZyddl	Z	Wne
k
r�nXddlmZd�Z
d�Zd�Zd�Zd�Zd�Zd	�Zejd
��Zd�Zd�Zdd
�Zdd�Zded�ZdS(i����N(tstrip_python_stderrc	
Ostjg}|s"|jd�n|j|�tjj�}|j|�tj	|dtj
dtj
dtj
d|�}z|j�\}}Wdtj�|j
j�|jj�X|j}t|�}|r�|s�|r
|r
td||jdd�f��n|||fS(	Ns-Etstdintstdouttstderrtenvs-Process return code is %d, stderr follows:
%stasciitignore(tsyst
executabletappendtextendtostenvirontcopytupdatet
subprocesstPopentPIPEtcommunicatet_cleanupRtcloseRt
returncodeRtAssertionErrortdecode(	texpected_successtargstenv_varstcmd_lineRtptoutterrtrc((s2/usr/lib64/python2.7/test/support/script_helper.pyt_assert_pythons*

	

	cOstt||�S(s�
    Assert that running the interpreter with `args` and optional environment
    variables `env_vars` is ok and return a (return code, stdout, stderr) tuple.
    (R tTrue(RR((s2/usr/lib64/python2.7/test/support/script_helper.pytassert_python_ok2scOstt||�S(s�
    Assert that running the interpreter with `args` and optional environment
    variables `env_vars` fails and return a (return code, stdout, stderr) tuple.
    (R tFalse(RR((s2/usr/lib64/python2.7/test/support/script_helper.pytassert_python_failure9sc
GsWtjdg}|j|�ttjd��#}tj|d|dtj�SWdQXdS(Ns-EtwRR(	RRR
topenRtdevnullRtcalltSTDOUT(RRR'((s2/usr/lib64/python2.7/test/support/script_helper.pytpython_exit_code@s

c	OsGtjdg}|j|�tj|dtjdtjdtj|�S(Ns-ERRR(RRR
RRRR)(RtkwargsR((s2/usr/lib64/python2.7/test/support/script_helper.pytspawn_pythonGs

cCsA|jj�|jj�}|jj�|j�tj�|S(N(RRRtreadtwaitRR(Rtdata((s2/usr/lib64/python2.7/test/support/script_helper.pytkill_pythonNs



cOs+t||�}t|�}|j�|fS(N(R,R0R.(RR+Rtstdout_data((s2/usr/lib64/python2.7/test/support/script_helper.pyt
run_pythonXsccs<tj�}tjj|�}z	|VWdtj|�XdS(N(ttempfiletmkdtempRtpathtrealpathtshutiltrmtree(tdirname((s2/usr/lib64/python2.7/test/support/script_helper.pyttemp_diras
	cCsP|tjd}tjj||�}t|d�}|j|�|j�|S(NtpyR%(RtextsepR5tjoinR&twriteR(t
script_dirtscript_basenametsourcetscript_filenametscript_nametscript_file((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_scriptjs

cCs!tj|dt�|d}|S(Ntdoraisetc(t
py_compiletcompileR!(RCt
compiled_name((s2/usr/lib64/python2.7/test/support/script_helper.pytcompile_scriptrs
cCs�|tjd}tjj||�}tj|d�}|dkrYtjj|�}n|j||�|j	�|tjj||�fS(NtzipR%(
RR<R5R=tzipfiletZipFiletNonetbasenameR>R(tzip_dirtzip_basenameRCtname_in_ziptzip_filenametzip_nametzip_file((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_zip_scriptzs
tcCs!tj|�t|d|�dS(Nt__init__(RtmkdirRE(tpkg_dirtinit_source((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_pkg�s
icCs�g}t|dd�}|j|�tjj|�}	t|||�}
|j|
�|r�t|�}t|
�}
|j||
f�ngtd|d�D]}tjj	|g|�^q�}tjj	|dtjj|
��}
|tj
d}tjj	||�}tj|d�}x3|D]+}tjj	||	�}|j
||�q'W|j
|
|
�|j�x|D]}tj|�qwW|tjj	||
�fS(NRYRXii����RLR%(RER	RR5RPRKR
trangetsepR=R<RMRNR>Rtunlink(RQRRtpkg_nameR@RAtdepthtcompiledR`t	init_namet
init_basenameRCtit	pkg_namestscript_name_in_zipRTRURVtnametinit_name_in_zip((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_zip_pkg�s.

9%


(RRtretos.pathR3RRHt
contextlibR7RMtImportErrorttest.supportRR R"R$R*R,R0R2tcontextmanagerR:RERKRORWR]R#Rk(((s2/usr/lib64/python2.7/test/support/script_helper.pyt<module>s4
						
					support/script_helper.pyo000064400000013443150532427410011664 0ustar00�
{fc@s.ddlZddlZddlZddlZddlZddlZddlZddlZddlZyddl	Z	Wne
k
r�nXddlmZd�Z
d�Zd�Zd�Zd�Zd�Zd	�Zejd
��Zd�Zd�Zdd
�Zdd�Zded�ZdS(i����N(tstrip_python_stderrc	
Ostjg}|s"|jd�n|j|�tjj�}|j|�tj	|dtj
dtj
dtj
d|�}z|j�\}}Wdtj�|j
j�|jj�X|j}t|�}|r�|s�|r
|r
td||jdd�f��n|||fS(	Ns-Etstdintstdouttstderrtenvs-Process return code is %d, stderr follows:
%stasciitignore(tsyst
executabletappendtextendtostenvirontcopytupdatet
subprocesstPopentPIPEtcommunicatet_cleanupRtcloseRt
returncodeRtAssertionErrortdecode(	texpected_successtargstenv_varstcmd_lineRtptoutterrtrc((s2/usr/lib64/python2.7/test/support/script_helper.pyt_assert_pythons*

	

	cOstt||�S(s�
    Assert that running the interpreter with `args` and optional environment
    variables `env_vars` is ok and return a (return code, stdout, stderr) tuple.
    (R tTrue(RR((s2/usr/lib64/python2.7/test/support/script_helper.pytassert_python_ok2scOstt||�S(s�
    Assert that running the interpreter with `args` and optional environment
    variables `env_vars` fails and return a (return code, stdout, stderr) tuple.
    (R tFalse(RR((s2/usr/lib64/python2.7/test/support/script_helper.pytassert_python_failure9sc
GsWtjdg}|j|�ttjd��#}tj|d|dtj�SWdQXdS(Ns-EtwRR(	RRR
topenRtdevnullRtcalltSTDOUT(RRR'((s2/usr/lib64/python2.7/test/support/script_helper.pytpython_exit_code@s

c	OsGtjdg}|j|�tj|dtjdtjdtj|�S(Ns-ERRR(RRR
RRRR)(RtkwargsR((s2/usr/lib64/python2.7/test/support/script_helper.pytspawn_pythonGs

cCsA|jj�|jj�}|jj�|j�tj�|S(N(RRRtreadtwaitRR(Rtdata((s2/usr/lib64/python2.7/test/support/script_helper.pytkill_pythonNs



cOs.td||�}t|�}|j�|fS(Ns-O(R,R0R.(RR+Rtstdout_data((s2/usr/lib64/python2.7/test/support/script_helper.pyt
run_pythonXsccs<tj�}tjj|�}z	|VWdtj|�XdS(N(ttempfiletmkdtempRtpathtrealpathtshutiltrmtree(tdirname((s2/usr/lib64/python2.7/test/support/script_helper.pyttemp_diras
	cCsP|tjd}tjj||�}t|d�}|j|�|j�|S(NtpyR%(RtextsepR5tjoinR&twriteR(t
script_dirtscript_basenametsourcetscript_filenametscript_nametscript_file((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_scriptjs

cCs!tj|dt�|d}|S(Ntdoraiseto(t
py_compiletcompileR!(RCt
compiled_name((s2/usr/lib64/python2.7/test/support/script_helper.pytcompile_scriptrs
cCs�|tjd}tjj||�}tj|d�}|dkrYtjj|�}n|j||�|j	�|tjj||�fS(NtzipR%(
RR<R5R=tzipfiletZipFiletNonetbasenameR>R(tzip_dirtzip_basenameRCtname_in_ziptzip_filenametzip_nametzip_file((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_zip_scriptzs
tcCs!tj|�t|d|�dS(Nt__init__(RtmkdirRE(tpkg_dirtinit_source((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_pkg�s
icCs�g}t|dd�}|j|�tjj|�}	t|||�}
|j|
�|r�t|�}t|
�}
|j||
f�ngtd|d�D]}tjj	|g|�^q�}tjj	|dtjj|
��}
|tj
d}tjj	||�}tj|d�}x3|D]+}tjj	||	�}|j
||�q'W|j
|
|
�|j�x|D]}tj|�qwW|tjj	||
�fS(NRYRXii����RLR%(RER	RR5RPRKR
trangetsepR=R<RMRNR>Rtunlink(RQRRtpkg_nameR@RAtdepthtcompiledR`t	init_namet
init_basenameRCtit	pkg_namestscript_name_in_zipRTRURVtnametinit_name_in_zip((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_zip_pkg�s.

9%


(RRtretos.pathR3RRHt
contextlibR7RMtImportErrorttest.supportRR R"R$R*R,R0R2tcontextmanagerR:RERKRORWR]R#Rk(((s2/usr/lib64/python2.7/test/support/script_helper.pyt<module>s4
						
					support/__init__.pyo000064400000211541150532427410010557 0ustar00�
{fc=@s�
dZedkr!ed��nddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZyddlZWnek
r:dZnXddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d4d<d=d>d?d@g=ZdAZdefdB��YZdefdC��YZdefdD��YZdejfdE��YZ ej!e"dF��Z#e$dG�Z%dH�Z&dI�Z'd�d�e$dJ�Z(dK�Z)dLZ*dZ+dMa,dMa-e$Z.da/dN�Z0dO�Z1dP�Z2dQ�Z3e
jj4dR�r+e$dS�Z5dT�Z6dU�Z7dV�Z8nej9Z6ej:Z7dW�Z8dX�Z9dY�Z:dZ�Z;d[�Z<d\�Z=d]�Z>dd^�Z?d_�Z@d`ZAdaZBejCejDdb�ZEeAdc�ZFdd�ZGeG�ZHde�ZIdfZJdg�ZKd�ZLd�ZMe
jj4dk�ZNyeOe"ZPWneQk
r-e$ZPnXejRePdl�ZSdm�ZTdZUePrx�eVdn�eVdo�eVdp�eVdq�eVdr�eVds�eVdt�eVdu�eVdv�eVdw�eVdx�fD]XZWy7eWjXe
jY��jZe
jY��eWkr�e[�nWne[k
rq�XeWZUPq�Wnej\dkkr6dyZ]n�ej\dzkrNd{Z]n�d|Z]ePr�e^d}eO�rrd~Z_neOd~d�Z_e
jY�Z`eae
d��s�e
jb�d�d�kr�dZcq�edd��ZcyecjXd��Wneek
r�q�Xd�ecGHnd�jfe]ejg��Z]d�Zheji�Zjej!de$d���Zkej!e$d���Zlej!d�e$d���Zmejnjoejnjpeq��Zrejnjoer�Zsejnjtesd��Zudd��Zvd��Zwd��Zxd}ddd��Zydd��Zzd�e{fd���YZ|e$d��Z}ej!d���Z~ej!d���Zd&e{fd���YZ�d'ej�fd���YZ�d�e{fd���YZ�d*e{fd���YZ�ej!dAd�d���Z�ej!d���Z�d��Z�d��Z�d��Z�d��Z�d�Z�eae
d��r�d�e�Z�ne�d�Z�d��Z�d��Z�d�Z�d�Z�d��Z�d��Z�d��Z�d�Z�die�Z�d�e�Z�dhe�Z�e
j�Z�d��Z�d�e�d��Z�d�e�e"d��Z�d��Z�d0d�d���YZ�d��Z�d��Z�d��Z�dd��Z�d��Z�d��Z�d��Z�d��Z�da�da�d��Z�d��Z�d��Z�d��Z�e�d�e$�pW	e
jd�kpW	ej�d��Z�ejRe�d��Z�dd��Z�e$Z�d��Z�d��Z�d��Z�ej!d�d���Z�d��Z�ej!dd���Z�ej!d���Z�ej!d���Z�d��Z�ej�eae
d��d��Z�d��Z�d��Z�d�d��Z�ej!d���Z�d��Z�d@d�d���YZ�d��Z�d��Z�d�d�d���YZ�dS(�s7Supporting definitions for the Python regression tests.stest.supports3test.support must be imported from the test packagei����NtErrort
TestFailedt
TestDidNotRuntResourceDeniedt
import_moduletverboset
use_resourcest
max_memusetrecord_original_stdouttget_original_stdouttunloadtunlinktrmtreetforgettis_resource_enabledtrequirestrequires_mac_vertfind_unused_portt	bind_porttfcmpthave_unicodet	is_jythontTESTFNtHOSTtFUZZtSAVEDCWDttemp_cwdtfindfiletsortdicttcheck_syntax_errortopen_urlresourcetcheck_warningstcheck_py3k_warningstCleanImporttEnvironmentVarGuardtcaptured_outputtcaptured_stdouttTransientResourcettransient_internettrun_with_localetset_memlimitt
bigmemtesttbigaddrspacetesttBasicTestRunnertrun_unittesttrun_doctesttthreading_setuptthreading_cleanuptreap_threadst
start_threadstcpython_onlytcheck_impl_detailt
get_attributet
py3k_bytestimport_fresh_modulet
reap_childrentstrip_python_stderrtIPV6_ENABLEDtrun_with_tztSuppressCrashReportg>@cBseZdZRS(s*Base class for regression test exceptions.(t__name__t
__module__t__doc__(((s-/usr/lib64/python2.7/test/support/__init__.pyR4scBseZdZRS(sTest failed.(R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR7scBseZdZRS(sTest did not run any subtests.(R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR:scBseZdZRS(s�Test skipped because it requested a disallowed resource.

    This is raised when a test calls requires() for a resource that
    has not been enabled.  It is used to distinguish between expected
    and unexpected skips.
    (R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR=sccs=|r4tj��tjddt�dVWdQXndVdS(s�Context manager to suppress package and module deprecation
    warnings when importing them.

    If ignore is False, this context manager has no effect.tignores.+ (module|package)N(twarningstcatch_warningstfilterwarningstDeprecationWarning(R?((s-/usr/lib64/python2.7/test/support/__init__.pyt_ignore_deprecated_importsEs
c	CsSt|��Aytj|�SWn(tk
rH}tjt|���nXWdQXdS(s�Import and return the module to be tested, raising SkipTest if
    it is not available.

    If deprecated is True, any module or package deprecation messages
    will be suppressed.N(RDt	importlibRtImportErrortunittesttSkipTesttstr(tnamet
deprecatedtmsg((s-/usr/lib64/python2.7/test/support/__init__.pyRTs

cCs�|tjkr&t|�tj|=nxTttj�D]C}||ks[|j|d�r6tj|||<tj|=q6q6WdS(swHelper function to save and remove a module from sys.modules

       Raise ImportError if the module can't be imported.t.N(tsystmodulest
__import__tlistt
startswith(RJtorig_modulestmodname((s-/usr/lib64/python2.7/test/support/__init__.pyt_save_and_remove_moduleas

cCsFt}ytj|||<Wntk
r4t}nXdtj|<|S(s�Helper function to save and block a module in sys.modules

       Return True if the module was in sys.modules, False otherwise.N(tTrueRNROtKeyErrortFalsetNone(RJRStsaved((s-/usr/lib64/python2.7/test/support/__init__.pyt_save_and_block_modulens


cCs�t|���i}g}t||�zyax|D]}t||�q3Wx-|D]%}t||�sQ|j|�qQqQWtj|�}Wntk
r�d}nXWdx'|j�D]\}	}
|
t	j
|	<q�Wx|D]}t	j
|=q�WX|SWdQXdS(sImports and returns a module, deliberately bypassing the sys.modules cache
    and importing a fresh copy of the module. Once the import is complete,
    the sys.modules cache is restored to its original state.

    Modules named in fresh are also imported anew if needed by the import.
    If one of these modules can't be imported, None is returned.

    Importing of modules named in blocked is prevented while the fresh import
    takes place.

    If deprecated is True, any module or package deprecation messages
    will be suppressed.N(RDRUR[tappendRERRFRYtitemsRNRO(RJtfreshtblockedRKRStnames_to_removet
fresh_nametblocked_nametfresh_modulet	orig_nametmoduletname_to_remove((s-/usr/lib64/python2.7/test/support/__init__.pyR6{s&





cCs�yt||�}Wn�tk
r�t|tj�rKd|j|f}n�t|tj�rsd|j|f}nit|tj�r�d|jj|f}n>t|t	�r�d|j|f}ndt	|�j|f}t
j|��nX|SdS(s?Get an attribute, raising SkipTest if AttributeError is raised.smodule %r has no attribute %rsclass %s has no attribute %rs%s instance has no attribute %rs"type object %r has no attribute %rs%r object has no attribute %rN(tgetattrtAttributeErrort
isinstancettypest
ModuleTypeR<t	ClassTypetInstanceTypet	__class__ttypeRGRH(tobjRJt	attributeRL((s-/usr/lib64/python2.7/test/support/__init__.pyR4�s
iicCs
|adS(N(t_original_stdout(tstdout((s-/usr/lib64/python2.7/test/support/__init__.pyR�scCs
tptjS(N(RrRNRs(((s-/usr/lib64/python2.7/test/support/__init__.pyR	�scCs&ytj|=Wntk
r!nXdS(N(RNRORW(RJ((s-/usr/lib64/python2.7/test/support/__init__.pyR
�s
cGsxy||�SWnctk
rs}tdkrVd|jj|fGHd|j|fGHntj|tj�||�SXdS(Nis%s: %ssre-run %s%r(tEnvironmentErrorRRnR<tostchmodtstattS_IRWXU(tpathtfunctargsterr((s-/usr/lib64/python2.7/test/support/__init__.pyt
_force_run�stwincCs�||�|r|}n$tjj|�\}}|p:d}d}xR|dkr�tj|�}|rm|n	||ks}dStj|�|d9}qFWtjd|tdd�dS(NRMg����MbP?g�?is)tests may fail, delete still pending for t
stackleveli(	RuRytsplittlistdirttimetsleepR@twarntRuntimeWarning(RztpathnametwaitalltdirnameRJttimeouttL((s-/usr/lib64/python2.7/test/support/__init__.pyt_waitfor�s
	

cCsttj|�dS(N(R�RuR(tfilename((s-/usr/lib64/python2.7/test/support/__init__.pyt_unlink�scCsttj|�dS(N(R�Rutrmdir(R�((s-/usr/lib64/python2.7/test/support/__init__.pyt_rmdir�scs6�fd��t�|dt�td�|�dS(Ncs�x�t|tj|�D]i}tjj||�}tjj|�rlt�|dt�t|tj|�qt|tj	|�qWdS(NR�(
R}RuR�RytjointisdirR�RVR�R(RyRJtfullname(t
_rmtree_inner(s-/usr/lib64/python2.7/test/support/__init__.pyR�sR�cSst|tj|�S(N(R}RuR�(tp((s-/usr/lib64/python2.7/test/support/__init__.pyt<lambda>	t(R�RV(Ry((R�s-/usr/lib64/python2.7/test/support/__init__.pyt_rmtree�scsSytj|�dSWntk
r(nX�fd���|�tj|�dS(Ncs�x�t|tj|�D]�}tjj||�}ytj|�j}Wntk
r`d}nXtj	|�r��|�t|tj
|�qt|tj|�qWdS(Ni(R}RuR�RyR�tlstattst_modeRtRwtS_ISDIRR�R(RyRJR�tmode(R�(s-/usr/lib64/python2.7/test/support/__init__.pyR�s


(tshutilRRtRuR�(Ry((R�s-/usr/lib64/python2.7/test/support/__init__.pyR�s


cCsIyt|�Wn4tk
rD}|jtjtjfkrE�qEnXdS(N(R�tOSErrorterrnotENOENTtENOTDIR(R�texc((s-/usr/lib64/python2.7/test/support/__init__.pyR$s
cCs@yt|�Wn+tk
r;}|jtjkr<�q<nXdS(N(R�R�R�R�(R�terror((s-/usr/lib64/python2.7/test/support/__init__.pyR�+s
cCsIyt|�Wn4tk
rD}|jtjtjfkrE�qEnXdS(N(R�R�R�R�tESRCH(Ryte((s-/usr/lib64/python2.7/test/support/__init__.pyR3s
cCsjt|�xYtjD]N}ttjj||tjd��ttjj||tjd��qWdS(sm"Forget" a module was ever imported by removing it from sys.modules and
    deleting any .pyc and .pyo files.tpyctpyoN(R
RNRyRRuR�textsep(RTR�((s-/usr/lib64/python2.7/test/support/__init__.pyR
;s
$cs�ttd�rtjSd}tjjd�r ddl�ddl�d}d}d�j	f�fd��Y}�j
j}|j�}|s��j
��n|�}�jj�}|j||�j|��j|��j|��}|s�j
��nt|j|@�s�d}q�n�tjdkr�dd	lm}	m�m}
m	}dd
lm}|	j|d��}
|
j�dkr�d
}q�d|f�fd��Y}|�}|
|�}|
j|�dks�|
j|�dkr�d}q�n|s�y;ddlm}|�}|j �|j!�|j"�Wq�t#k
r�}t$|�}t%|�dkrz|d d}ndj&t'|�j(|�}q�Xn|t_)|t_tjS(NtresultR~i����itUSEROBJECTFLAGScs;eZd�jjfd�jjfd�jjfgZRS(tfInheritt	fReservedtdwFlags(R<R=twintypestBOOLtDWORDt_fields_((tctypes(s-/usr/lib64/python2.7/test/support/__init__.pyR�Rss,gui not available (WSF_VISIBLE flag not set)tdarwin(tcdlltc_inttpointert	Structure(tfind_librarytApplicationServicesis0gui tests cannot run without OS X window managertProcessSerialNumbercs eZd�fd�fgZRS(t
highLongOfPSNtlowLongOfPSN(R<R=R�((R�(s-/usr/lib64/python2.7/test/support/__init__.pyR�ts	s#cannot run without OS X gui process(tTki2s [...]sTk unavailable due to {}: {}(*thasattrt_is_gui_availableR�RYRNtplatformRRR�tctypes.wintypesR�twindlltuser32tGetProcessWindowStationtWinErrorR�R�tGetUserObjectInformationWtbyreftsizeoftboolR�R�R�R�tctypes.utilR�tLoadLibrarytCGMainDisplayIDtGetCurrentProcesstSetFrontProcesstTkinterR�twithdrawtupdatetdestroyt	ExceptionRItlentformatRoR<treason(R�t	UOI_FLAGStWSF_VISIBLER�tdllthtuoftneededtresR�R�R�R�tapp_servicesR�tpsntpsn_pR�trootR�t
err_string((R�R�s-/usr/lib64/python2.7/test/support/__init__.pyR�Gsh		"			

	
cCstdkp|tkS(s�Test whether a resource is enabled.

    Known resources are set by regrtest.py.  If not running under regrtest.py,
    all resources are assumed enabled unless use_resources has been set.
    N(RRY(tresource((s-/usr/lib64/python2.7/test/support/__init__.pyR�scCs`t|�s4|dkr%d|}nt|��n|dkr\t�r\ttj��ndS(s@Raise ResourceDenied if the specified resource is not available.s$Use of the `%s' resource not enabledtguiN(RRYRR�R�(R�RL((s-/usr/lib64/python2.7/test/support/__init__.pyR�s
cs�fd�}|S(s�Decorator raising SkipTest if the OS is Mac OS X and the OS X
    version if less than min_version.

    For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
    is lesser than 10.5.
    cs.tj����fd��}�|_|S(Ncs�tjdkr�tj�d}y"ttt|jd���}Wntk
rTq�X|�kr�djtt	���}t
jd||f��q�n�||�S(NR�iRMs&Mac OS X %s or higher required, not %s(RNR�tmac_verttupletmaptintR�t
ValueErrorR�RIRGRH(R{tkwtversion_txttversiontmin_version_txt(Rztmin_version(s-/usr/lib64/python2.7/test/support/__init__.pytwrapper�s"
(t	functoolstwrapsR�(RzR�(R�(Rzs-/usr/lib64/python2.7/test/support/__init__.pyt	decorator�s!	((R�R�((R�s-/usr/lib64/python2.7/test/support/__init__.pyR�ss	127.0.0.1s::1cCs/tj||�}t|�}|j�~|S(s�
Returns an unused port that should be suitable for binding.  This is
    achieved by creating a temporary socket with the same family and type as
    the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to
    the specified host address (defaults to 0.0.0.0) with the port set to 0,
    eliciting an unused ephemeral port from the OS.  The temporary socket is
    then closed and deleted, and the ephemeral port is returned.

    Either this method or bind_port() should be used for any tests where a
    server socket needs to be bound to a particular port for the duration of
    the test.  Which one to use depends on whether the calling code is creating
    a python socket, or if an unused port needs to be provided in a constructor
    or passed to an external program (i.e. the -accept argument to openssl's
    s_server mode).  Always prefer bind_port() over find_unused_port() where
    possible.  Hard coded ports should *NEVER* be used.  As soon as a server
    socket is bound to a hard coded port, the ability to run multiple instances
    of the test simultaneously on the same host is compromised, which makes the
    test a ticking time bomb in a buildbot environment. On Unix buildbots, this
    may simply manifest as a failed test, which can be recovered from without
    intervention in most cases, but on Windows, the entire python process can
    completely and utterly wedge, requiring someone to log in to the buildbot
    and manually kill the affected process.

    (This is easy to reproduce on Windows, unfortunately, and can be traced to
    the SO_REUSEADDR socket option having different semantics on Windows versus
    Unix/Linux.  On Unix, you can't have two AF_INET SOCK_STREAM sockets bind,
    listen and then accept connections on identical host/ports.  An EADDRINUSE
    socket.error will be raised at some point (depending on the platform and
    the order bind and listen were called on each socket).

    However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE
    will ever be raised when attempting to bind two identical host/ports. When
    accept() is called on each socket, the second caller's process will steal
    the port from the first caller, leaving them both in an awkwardly wedged
    state where they'll no longer respond to any signals or graceful kills, and
    must be forcibly killed via OpenProcess()/TerminateProcess().

    The solution on Windows is to use the SO_EXCLUSIVEADDRUSE socket option
    instead of SO_REUSEADDR, which effectively affords the same semantics as
    SO_REUSEADDR on Unix.  Given the propensity of Unix developers in the Open
    Source world compared to Windows ones, this is a common mistake.  A quick
    look over OpenSSL's 0.9.8g source shows that they use SO_REUSEADDR when
    openssl.exe is called with the 's_server' option, for example. See
    http://bugs.python.org/issue2550 for more info.  The following site also
    has a very thorough description about the implications of both REUSEADDR
    and EXCLUSIVEADDRUSE on Windows:
    http://msdn2.microsoft.com/en-us/library/ms740621(VS.85).aspx)

    XXX: although this approach is a vast improvement on previous attempts to
    elicit unused ports, it rests heavily on the assumption that the ephemeral
    port returned to us by the OS won't immediately be dished back out to some
    other process when we close and delete our temporary socket but before our
    calling code has a chance to bind the returned port.  We can deal with this
    issue if/when we come across it.(tsocketRtclose(tfamilytsocktypettempsocktport((s-/usr/lib64/python2.7/test/support/__init__.pyR�s
6
cCs|jtjkr�|jtjkr�ttd�rc|jtjtj�dkrct	d��qcnttd�r�y1|jtjtj
�dkr�t	d��nWq�tk
r�q�Xnttd�r�|jtjtj
d�q�n|j|df�|j�d}|S(s%Bind the socket to a free port and return the port number.  Relies on
    ephemeral ports in order to ensure we are using an unbound port.  This is
    important as many tests may be running simultaneously, especially in a
    buildbot environment.  This method raises an exception if the sock.family
    is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR
    or SO_REUSEPORT set on it.  Tests should *never* set these socket options
    for TCP/IP sockets.  The only case for setting these options is testing
    multicasting via multiple UDP sockets.

    Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e.
    on Windows), it will be set on the socket.  This will prevent anyone else
    from bind()'ing to our host/port for the duration of the test.
    tSO_REUSEADDRisHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets!tSO_REUSEPORTsHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!tSO_EXCLUSIVEADDRUSEi(R�R�tAF_INETRotSOCK_STREAMR�t
getsockoptt
SOL_SOCKETR�RR�Rtt
setsockoptR�tbindtgetsockname(tsockthostR�((s-/usr/lib64/python2.7/test/support/__init__.pyRs$
cCs{tjrwd}zNy3tjtjtj�}|jtdf�tSWntjk
r[nXWd|rs|j	�nXnt
S(s+Check whether IPv6 is enabled on this host.iN(R�thas_ipv6RYtAF_INET6R�RtHOSTv6RVR�R�RX(R((s-/usr/lib64/python2.7/test/support/__init__.pyt_is_ipv6_enabled$s	cs"tj���fd��}|S(s5Skip the test on TLS certificate validation failures.csRy�||�Wn:tk
rM}dt|�krGtjd��n�nXdS(NtCERTIFICATE_VERIFY_FAILEDs.system does not contain necessary certificates(tIOErrorRIRGRH(R{tkwargsR�(tf(s-/usr/lib64/python2.7/test/support/__init__.pytdec7s(R�R�(RR((Rs-/usr/lib64/python2.7/test/support/__init__.pytsystem_must_validate_cert5s	g���ư>cCs#t|t�st|t�rcy8t|�t|�t}t||�|krUdSWqqXn�t|�t|�krt|ttf�rxPttt	|�t	|���D]-}t
||||�}|dkr�|Sq�Wt	|�t	|�kt	|�t	|�kS||k||kS(Ni(RitfloattabsRRoR�RQtrangetminR�R(txtytfuzztitoutcome((s-/usr/lib64/python2.7/test/support/__init__.pyRDs-(,iiitjavasno unicode supportcCs
t|d�S(Nsunicode-escape(tunicode(ts((s-/usr/lib64/python2.7/test/support/__init__.pytumsi�i0iAi�ii�ii*ii�i� s$testtriscosttestfiles@testR�s@test-��slatin-1tgetwindowsversioniis'u"@test-\u5171\u6709\u3055\u308c\u308b"tLatin1sgWARNING: The filename %r CAN be encoded by the filesystem.  Unicode filename tests may not be effectives	{}_{}_tmpshttp://www.pythontest.netccsQt}|dkrEddl}|j�}t}tjj|�}n�tr�t	|t
�r�tjjr�y|jt
j�pd�}Wq�tk
r�|s�tjd��q�q�Xnytj|�t}Wn7tk
r|s��ntjd|tdd�nX|rtj�}nz	|VWd|rL|tj�krLt|�nXdS(s�Return a context manager that creates a temporary directory.

    Arguments:

      path: the directory to create temporarily.  If omitted or None,
        defaults to creating a temporary directory using tempfile.mkdtemp.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, if the path is specified and cannot be
        created, only a warning is issued.

    i����Ntasciis;unable to encode the cwd name with the filesystem encoding.s+tests may fail, unable to create temp dir: Ri(RXRYttempfiletmkdtempRVRuRytrealpathRRiRtsupports_unicode_filenamestencodeRNtgetfilesystemencodingtUnicodeEncodeErrorRGRHtmkdirR�R@R�R�tgetpidR(Rytquiettdir_createdR tpid((s-/usr/lib64/python2.7/test/support/__init__.pyttemp_dir�s6





	ccs{tj�}ytj|�Wn7tk
rV|s9�ntjd|tdd�nXztj�VWdtj|�XdS(sgReturn a context manager that changes the current working directory.

    Arguments:

      path: the directory to use as the temporary current working directory.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, it issues only a warning and keeps the current
        working directory the same.

    s)tests may fail, unable to change CWD to: RiN(RutgetcwdtchdirR�R@R�R�(RyR)t	saved_dir((s-/usr/lib64/python2.7/test/support/__init__.pyt
change_cwds


ttempcwdc	csBtd|d|��'}t|d|��}|VWdQXWdQXdS(s�
    Context manager that temporarily creates and changes the CWD.

    The function temporarily changes the current working directory
    after creating a temporary directory in the current directory with
    name *name*.  If *name* is None, the temporary directory is
    created using tempfile.mkdtemp.

    If *quiet* is False (default) and it is not possible to
    create or change the CWD, an error is raised.  If *quiet* is True,
    only a warning is raised and the original CWD is used.

    RyR)N(R,R0(RJR)t	temp_pathtcwd_dir((s-/usr/lib64/python2.7/test/support/__init__.pyR&stdatacCs�tjj|�r|S|dk	r:tjj||�}ntgtj}x9|D]1}tjj||�}tjj|�rQ|SqQW|S(s�Try to find a file on sys.path and the working directory.  If it is not
    found the argument passed to the function is returned (this does not
    necessarily signal failure; could still be the legitimate path).N(RuRytisabsRYR�t
TEST_HOME_DIRRNtexists(tfiletsubdirRytdntfn((s-/usr/lib64/python2.7/test/support/__init__.pyRAs
cCsJ|j�}|j�g|D]}d|^q}dj|�}d|S(s%Like repr(dict), but in sorted order.s%r: %rs, s{%s}(R]tsortR�(tdictR]tpairt	reprpairst
withcommas((s-/usr/lib64/python2.7/test/support/__init__.pyROs

cCs9ttd�}z|j�SWd|j�tt�XdS(s`
    Create an invalid file descriptor by opening and closing a file and return
    its fd.
    twbN(topenRtfilenoR�R(R8((s-/usr/lib64/python2.7/test/support/__init__.pytmake_bad_fdWs

cCs||jt|��}t|dd�WdQX|j}|dk	rV|j|j|�n|dk	rx|j|j|�ndS(Ns
<test string>texec(tassertRaisesRegexptSyntaxErrortcompilet	exceptionRYtassertEqualtlinenotoffset(ttestcaset	statementterrtextRKRLtcmR|((s-/usr/lib64/python2.7/test/support/__init__.pyRcs	c
sSddl}ddl}|j|�djd�d}tjjt|�}�fd�}tjj|�r�||�}|dk	r�|St	|�nt
d�t�d|IJ|j|dd�}zNt
|d	��9}|j�}	x#|	r
|j|	�|j�}	q�WWdQXWd|j�X||�}|dk	r?|Std
|��dS(Ni����it/csGt|�}�dkr|S�|�r9|jd�|S|j�dS(Ni(RBRYtseekR�(R;R(tcheck(s-/usr/lib64/python2.7/test/support/__init__.pytcheck_valid_filess
turlfetchs	fetching %s ...R�iRAsinvalid resource "%s"(turlparseturllib2R�RuRyR�t
TEST_DATA_DIRR7RYRRR	turlopenRBtreadtwriteR�R(
turlRSRVRWR�R;RTRtoutR((RSs-/usr/lib64/python2.7/test/support/__init__.pyRls. 	

	
tWarningsRecordercBs8eZdZd�Zd�Zed��Zd�ZRS(syConvenience wrapper for the warnings list returned on
       entry to the warnings.catch_warnings() context manager.
    cCs||_d|_dS(Ni(t	_warningst_last(tselft
warnings_list((s-/usr/lib64/python2.7/test/support/__init__.pyt__init__�s	cCs\t|j�|jkr,t|jd|�S|tjjkrBdStd||f��dS(Ni����s%r has no attribute %r(	R�R_R`RgR@tWarningMessaget_WARNING_DETAILSRYRh(Ratattr((s-/usr/lib64/python2.7/test/support/__init__.pyt__getattr__�s
cCs|j|jS(N(R_R`(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR@�scCst|j�|_dS(N(R�R_R`(Ra((s-/usr/lib64/python2.7/test/support/__init__.pytreset�s(R<R=R>RcRgtpropertyR@Rh(((s-/usr/lib64/python2.7/test/support/__init__.pyR^�s
		c
csptjd�}|jjd�}|r4|j�ntjdt��&}tjdj	d�t
|�VWdQXg|D]}|j^qu}g}x�|D]�\}}	t}
x[|D]R}t
|�}tj||tj�r�t|j|	�r�t}
|j|�q�q�W|
r�|r�|j||	jf�q�q�W|rOtd|d��n|rltd	|d��ndS(
s�Catch the warnings, then check if all the expected
    warnings have been raised and re-raise unexpected warnings.
    If 'quiet' is True, only re-raise the unexpected warnings.
    it__warningregistry__trecordR@talwaysNsunhandled warning %ris)filter (%r, %s) did not catch any warning(RNt	_getframet	f_globalstgettclearR@RARVROtsimplefilterR^tmessageRXRItretmatchtIt
issubclassRntremoveR\R<tAssertionError(
tfiltersR)tframetregistrytwtwarningtreraisetmissingRLtcattseenR�Rr((s-/usr/lib64/python2.7/test/support/__init__.pyt_filterwarnings�s0
cOsI|jd�}|s<dtff}|dkr<t}q<nt||�S(s�Context manager to silence warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default True without argument,
         default False if some filters are defined)

    Without argument, it defaults to:
        check_warnings(("", Warning), quiet=True)
    R)R�N(RotWarningRYRVR�(RyR
R)((s-/usr/lib64/python2.7/test/support/__init__.pyR�scOs@tjr$|s*dtff}q*nd}t||jd��S(sjContext manager to silence py3k warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default False)

    Without argument, it defaults to:
        check_py3k_warnings(("", DeprecationWarning), quiet=False)
    R�R)((RNtpy3kwarningRCR�Ro(RyR
((s-/usr/lib64/python2.7/test/support/__init__.pyR �s
	cBs)eZdZd�Zd�Zd�ZRS(s,Context manager to force import to return a new module reference.

    This is useful for testing module-level behaviours, such as
    the emission of a DeprecationWarning on import.

    Use like this:

        with CleanImport("foo"):
            importlib.import_module("foo") # new reference
    cGsotjj�|_xV|D]N}|tjkrtj|}|j|krZtj|j=ntj|=qqWdS(N(RNROtcopytoriginal_modulesR<(Ratmodule_namestmodule_nameRe((s-/usr/lib64/python2.7/test/support/__init__.pyRcs

cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyt	__enter__scGstjj|j�dS(N(RNROR�R�(Rat
ignore_exc((s-/usr/lib64/python2.7/test/support/__init__.pyt__exit__s(R<R=R>RcR�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR!s
	
	cBs_eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
s_Class to help protect the environment variable properly.  Can be used as
    a context manager.cCstj|_i|_dS(N(Rutenviront_environt_changed(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyRc(scCs|j|S(N(R�(Ratenvvar((s-/usr/lib64/python2.7/test/support/__init__.pyt__getitem__,scCs<||jkr+|jj|�|j|<n||j|<dS(N(R�R�Ro(RaR�tvalue((s-/usr/lib64/python2.7/test/support/__init__.pyt__setitem__/scCsK||jkr+|jj|�|j|<n||jkrG|j|=ndS(N(R�R�Ro(RaR�((s-/usr/lib64/python2.7/test/support/__init__.pyt__delitem__5scCs
|jj�S(N(R�tkeys(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR�<scCs|||<dS(N((RaR�R�((s-/usr/lib64/python2.7/test/support/__init__.pytset?scCs||=dS(N((RaR�((s-/usr/lib64/python2.7/test/support/__init__.pytunsetBscCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR�EscGshxU|jj�D]D\}}|dkrG||jkrT|j|=qTq||j|<qW|jt_dS(N(R�R]RYR�RuR�(RaR�tktv((s-/usr/lib64/python2.7/test/support/__init__.pyR�Hs(R<R=R>RcR�R�R�R�R�R�R�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR"#s								t
DirsOnSysPathcBs)eZdZd�Zd�Zd�ZRS(s�Context manager to temporarily add directories to sys.path.

    This makes a copy of sys.path, appends any directories given
    as positional arguments, then reverts sys.path to the copied
    settings when the context ends.

    Note that *all* sys.path modifications in the body of the
    context manager, including replacement of the object,
    will be reverted at the end of the block.
    cGs-tj|_tj|_tjj|�dS(N(RNRytoriginal_valuetoriginal_objecttextend(Ratpaths((s-/usr/lib64/python2.7/test/support/__init__.pyRc^s
cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR�cscGs|jt_|jtj(dS(N(R�RNRyR�(RaR�((s-/usr/lib64/python2.7/test/support/__init__.pyR�fs(R<R=R>RcR�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR�Rs
		cBs2eZdZd�Zd�Zdddd�ZRS(s�Raise ResourceDenied if an exception is raised while the context manager
    is in effect that matches the specified exception and attributes.cKs||_||_dS(N(R�tattrs(RaR�R
((s-/usr/lib64/python2.7/test/support/__init__.pyRcps	cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR�tscCs}|dk	ryt|j|�ryxX|jj�D]8\}}t||�sMPnt||�|kr.Pq.q.Wtd��ndS(s�If type_ is a subclass of self.exc and value has attributes matching
        self.attrs, raise ResourceDenied.  Otherwise let the exception
        propagate (if any).s%an optional resource is not availableN(RYRvR�R�t	iteritemsR�RgR(Rattype_R�t	tracebackRft
attr_value((s-/usr/lib64/python2.7/test/support/__init__.pyR�wsN(R<R=R>RcR�RYR�(((s-/usr/lib64/python2.7/test/support/__init__.pyR%ks		c#s�dddd d!d"g}d#d$d%d&d'g}td|��|�g��s�g|D]\}}tt||�^qV�g|D]\}}tt||�^q��n���fd�}tj�}z�y%|dk	r�tj|�ndVWn�tk
r�}	xxtr}|	j	}
t
|
�dkrGt|
dt�rG|
d}	qt
|
�dkryt|
dt�ry|
d}	qPqW||	��nXWdtj|�XdS((s�Return a context manager that raises ResourceDenied when various issues
    with the Internet connection manifest themselves as exceptions.tECONNREFUSEDiot
ECONNRESETihtEHOSTUNREACHiqtENETUNREACHiet	ETIMEDOUTint
EADDRNOTAVAILict	EAI_AGAINi����tEAI_FAILi����t
EAI_NONAMEi����t
EAI_NODATAi����t
WSANO_DATAi�*sResource '%s' is not availablecst|dd�}t|tj�sNt|tj�rB|�ksN|�kr{tsrtjj	�j
dd�n��ndS(NR�is
(RgRYRiR�R�tgaierrorRRNtstderrR[R{(R|tn(tcaptured_errnostdeniedt
gai_errnos(s-/usr/lib64/python2.7/test/support/__init__.pytfilter_error�sNiii(R�io(R�ih(R�iq(R�ie(R�in(R�ic(R�i����(R�i����(R�i����(R�i����(R�i�*(RRgR�R�tgetdefaulttimeoutRYtsetdefaulttimeoutR	RVR{R�Ri(t
resource_nameR�terrnostdefault_errnostdefault_gai_errnosRJtnumR�told_timeoutR|ta((R�R�R�s-/usr/lib64/python2.7/test/support/__init__.pyR&�sJ		(+				%
%

ccs[ddl}tt|�}tt||j��ztt|�VWdtt||�XdS(s�Return a context manager used by captured_stdout and captured_stdin
    that temporarily replaces the sys stream *stream_name* with a StringIO.i����N(tStringIORgRNtsetattr(tstream_nameR�torig_stdout((s-/usr/lib64/python2.7/test/support/__init__.pyR#�scCs
td�S(s�Capture the output of sys.stdout:

       with captured_stdout() as s:
           print "hello"
       self.assertEqual(s.getvalue(), "hello")
    Rs(R#(((s-/usr/lib64/python2.7/test/support/__init__.pyR$�scCs
td�S(NR�(R#(((s-/usr/lib64/python2.7/test/support/__init__.pytcaptured_stderr�scCs
td�S(Ntstdin(R#(((s-/usr/lib64/python2.7/test/support/__init__.pytcaptured_stdin�scCs8tj�tr tjd�ntj�tj�dS(s�Force as many objects as possible to be collected.

    In non-CPython implementations of Python, this is needed because timely
    deallocation is not guaranteed by the garbage collector.  (Even in CPython
    this can be the case in case of reference cycles.)  This means that __del__
    methods may be called later than expected and weakrefs may remain alive for
    longer than expected.  This function tries its best to force all garbage
    objects to disappear.
    g�������?N(tgctcollectRR�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyt
gc_collect�s



t2PtgettotalrefcounttPcCstjt|d�S(Nt0P(tstructtcalcsizet_header(tfmt((s-/usr/lib64/python2.7/test/support/__init__.pytcalcobjsize�scCstjt|d�S(NR�(R�R�t_vheader(R�((s-/usr/lib64/python2.7/test/support/__init__.pytcalcvobjsize�sii	cCs�ddl}tj|�}t|�tkr:|jt@s_t|�tkrot|�jt@ro||j7}ndt|�||f}|j|||�dS(Ni����s&wrong size for %s: got %d, expected %d(	t	_testcapiRNt	getsizeofRot	__flags__t_TPFLAGS_HEAPTYPEt_TPFLAGS_HAVE_GCtSIZEOF_PYGC_HEADRJ(ttesttotsizeR�R�RL((s-/usr/lib64/python2.7/test/support/__init__.pytcheck_sizeofs%cs��fd�}|S(Ncs1���fd�}�j|_�j|_|S(Ncs�y.ddl}t|��}|j|�}Wn$tk
rD�nAd}}n1Xx-�D]%}y|j||�PWq\q\Xq\Wz�||�SWd|r�|r�|j||�nXdS(Ni����(tlocaleRgt	setlocaleRhRY(R{tkwdsR�tcategorytorig_localetloc(tcatstrRztlocales(s-/usr/lib64/python2.7/test/support/__init__.pytinners$

(t	func_nameR>(RzR�(R�R�(Rzs-/usr/lib64/python2.7/test/support/__init__.pyR�s((R�R�R�((R�R�s-/usr/lib64/python2.7/test/support/__init__.pyR'scs�fd�}|S(Ncs.��fd�}�j|_�j|_|S(Ncs�y
tj}Wn tk
r/tjd��nXdtjkrOtjd}nd}�tjd<|�z�||�SWd|dkr�tjd=n
|tjd<tj�XdS(Nstzset requiredtTZ(R�ttzsetRhRGRHRuR�RY(R{R�R�torig_tz(Rzttz(s-/usr/lib64/python2.7/test/support/__init__.pyR�;s




(R<R>(RzR�(R�(Rzs-/usr/lib64/python2.7/test/support/__init__.pyR�:s((R�R�((R�s-/usr/lib64/python2.7/test/support/__init__.pyR:9scCs�idd6td6td6dtd6}tjd|tjtjB�}|dkrgtd|f��ntt	|j
d��||j
d	�j��}|a|t
kr�t
}n|tdkr�td
|f��n|adS(NiR�tmtgtts(\d+(\.\d+)?) (K|M|G|T)b?$sInvalid memory limit %riis$Memory limit %r too low to be useful(t_1Mt_1GRsRtt
IGNORECASEtVERBOSERYR�R�Rtgrouptlowertreal_max_memusetMAX_Py_ssize_tt_2GR(tlimittsizesR�tmemlimit((s-/usr/lib64/python2.7/test/support/__init__.pyR(bs 2	ics���fd�}|S(sQDecorator for bigmem tests.

    'minsize' is the minimum useful size for the test (in arbitrary,
    test-interpreted units.) 'memuse' is the number of 'bytes per size' for
    the test, or a good estimate of it. 'overhead' specifies fixed overhead,
    independent of the testsize, and defaults to 5Mb.

    The decorator tries to guess a good value for 'size' and passes it to
    the decorated test function. If minsize * memuse is more than the
    allowed memory use (as defined by max_memuse), the test is skipped.
    Otherwise, minsize is adjusted upward to use up to max_memuse.
    cs7����fd�}�|_�|_�|_|S(Ncs�ts.d}|j|��dtk�n^tt���}|�krutrqtjjd�jf�ndSt	|dt��}�||�S(Niis)Skipping %s because of memory constraint
i2(
RtassertFalseR�R�RRNR�R[R<tmax(Ratmaxsize(Rtmemusetminsizetoverhead(s-/usr/lib64/python2.7/test/support/__init__.pyR��s"(R�R�R�(RR�(R�R�R�(Rs-/usr/lib64/python2.7/test/support/__init__.pyR��s
			((R�R�R�R�((R�R�R�s-/usr/lib64/python2.7/test/support/__init__.pyR)ws
cs����fd�}|S(Ncs7����fd�}�|_�|_�|_|S(Ncsftsd}n�}ts"�rYt|�krYtrUtjjd�jf�ndS�||�S(Nis)Skipping %s because of memory constraint
(R�RRNR�R[R<(RaR�(tdry_runRR�R�(s-/usr/lib64/python2.7/test/support/__init__.pyR��s	
(R�R�R�(RR�(RR�R�R�(Rs-/usr/lib64/python2.7/test/support/__init__.pyR��s
			((R�R�R�RR�((RR�R�R�s-/usr/lib64/python2.7/test/support/__init__.pytprecisionbigmemtest�scs�fd�}|S(s0Decorator for tests that fill the address space.cs@ttkr2tr<tjjd�jf�q<n
�|�SdS(Ns)Skipping %s because of memory constraint
(RR�RRNR�R[R<(Ra(R(s-/usr/lib64/python2.7/test/support/__init__.pyR��s
((RR�((Rs-/usr/lib64/python2.7/test/support/__init__.pyR*�scBseZd�ZRS(cCstj�}||�|S(N(RGt
TestResult(RaR�R�((s-/usr/lib64/python2.7/test/support/__init__.pytrun�s
(R<R=R(((s-/usr/lib64/python2.7/test/support/__init__.pyR+�scCs|S(N((Rp((s-/usr/lib64/python2.7/test/support/__init__.pyt_id�scCsP|dkr&t�r&tjtj�St|�r6tStjdj|��SdS(NR�sresource {0!r} is not enabled(R�RGtskipR�RRR�(R�((s-/usr/lib64/python2.7/test/support/__init__.pytrequires_resource�s
cCstdt�|�S(s9
    Decorator for tests only applicable on CPython.
    tcpython(timpl_detailRV(R�((s-/usr/lib64/python2.7/test/support/__init__.pyR2�scKs}t|�rtS|dkrpt|�\}}|r=d}nd}t|j��}|jdj|��}ntj	|�S(Ns*implementation detail not available on {0}s%implementation detail specific to {0}s or (
R3RRYt
_parse_guardstsortedR�R�R�RGR(RLtguardst
guardnamestdefault((s-/usr/lib64/python2.7/test/support/__init__.pyR�s	cCs2|sitd6tfS|j�d}||fS(NRi(RVRXtvalues(Rtis_true((s-/usr/lib64/python2.7/test/support/__init__.pyR	�scKs.t|�\}}|jtj�j�|�S(s5This function returns True or False depending on the host platform.
       Examples:
          if check_impl_detail():               # only on CPython (default)
          if check_impl_detail(jython=True):    # only on Jython
          if check_impl_detail(cpython=False):  # everywhere except on CPython
    (R	RoR�tpython_implementationR�(RR
((s-/usr/lib64/python2.7/test/support/__init__.pyR3�scCsrg}x\|jD]Q}t|tj�rEt||�|j|�q||�r|j|�qqW||_dS(s>Recursively filter test cases in a suite based on a predicate.N(t_testsRiRGt	TestSuitet
_filter_suiteR\(tsuitetpredtnewtestsR�((s-/usr/lib64/python2.7/test/support/__init__.pyR�s
cCs�tr'tjtjdddt�}n	t�}|j|�}|jr\|j	r\t
�n|j�s�t|j
�dkr�|jr�|j
dd}nLt|j�dkr�|j
r�|jdd}nd}ts�|d7}nt|��ndS(	s2Run tests from a unittest.TestSuite-derived class.t	verbosityitfailfastiismultiple errors occurreds!; run in verbose mode for detailsN(RRGtTextTestRunnerRNRsRR+RttestsRuntskippedRt
wasSuccessfulR�terrorstfailuresR(RtrunnerR�R|((s-/usr/lib64/python2.7/test/support/__init__.pyt
_run_suites 		
cCs$tdkrtSt|j��SdS(N(t_match_test_funcRYRVtid(R�((s-/usr/lib64/python2.7/test/support/__init__.pyt
match_test#scCsd|kotjd|�S(NRMs[?*\[\]](Rstsearch(tpattern((s-/usr/lib64/python2.7/test/support/__init__.pyt_is_full_match_test+scs�|tkrdS|s%d}d}nittt|��rLt|�j}nBdjttj	|��}t
j|�j��fd�}|}t
|�a|adS(Nt|cs0�|�rtStt�|jd���SdS(NRM(RVtanyR�R�(ttest_id(tregex_match(s-/usr/lib64/python2.7/test/support/__init__.pytmatch_test_regexJs((t_match_test_patternsRYtallR�R&R�t__contains__R�tfnmatcht	translateRsRHRtR�R!(tpatternsRztregexR+((R*s-/usr/lib64/python2.7/test/support/__init__.pytset_match_tests5s	cGs�tjtjf}tj�}x�|D]�}t|t�rx|tjkri|jtjtj|��q�t	d��q%t||�r�|j|�q%|jtj
|��q%Wt|t�t
|�dS(s1Run tests from unittest.TestCase-derived classes.s)str arguments must be keys in sys.modulesN(RGRtTestCaseRiRIRNROtaddTestt
findTestCasesR�t	makeSuiteRR#R (tclassestvalid_typesRtcls((s-/usr/lib64/python2.7/test/support/__init__.pyR,]s
 
Rtwin32tWITH_DOC_STRINGSstest requires docstringscCs�ddl}|dkr!t}nd}tj}t�t_z>|j|d|�\}}|rytd||f��nWd|t_Xtr�d|j|fGHn||fS(s
Run doctest on the given module.  Return (#failures, #tests).

    If optional argument verbosity is not specified (or is None), pass
    test.support's belief about verbosity on to doctest.  Else doctest's
    usual behavior is used (it searches sys.argv for -v).
    i����NRs%d of %d doctests faileds,doctest (%s) ... %d tests with zero failures(	tdoctestRYRRNRsR	ttestmodRR<(ReRR=tsave_stdoutRR�((s-/usr/lib64/python2.7/test/support/__init__.pyR-|s		
cCstrtj�fSdSdS(Ni(i(tthreadt_count(((s-/usr/lib64/python2.7/test/support/__init__.pyR.�s
cCsTts
dSd}x=t|�D]/}tj�}||kr?Pntjd�qWdS(Ni
g�������?(R@RRAR�R�(t
nb_threadst
_MAX_COUNTtcountR�((s-/usr/lib64/python2.7/test/support/__init__.pyR/�scs,ts
�Stj���fd��}|S(s�Use this function when threads are being used.  This will
    ensure that the threads are cleaned up even when the test fails.
    If threading is unavailable this function does nothing.
    cs)t�}z�|�SWdt|�XdS(N(R.R/(R{tkey(Rz(s-/usr/lib64/python2.7/test/support/__init__.pyR��s	(R@R�R�(RzR�((Rzs-/usr/lib64/python2.7/test/support/__init__.pyR0�sgN@ccs�tj�}z	dVWdtj�}||}x�tr�tj�}||krSPntj�|kr�tj�|}d|||||f}t|��ntjd�t�q1WXdS(sE
    bpo-31234: Context manager to wait until all threads created in the with
    statement exit.

    Use thread.count() to check if threads exited. Indirectly, wait until
    threads exit the internal t_bootstrap() C function of the thread module.

    threading_setup() and threading_cleanup() are designed to emit a warning
    if a test leaves running threads in the background. This context manager
    is designed to cleanup threads started by the thread.start_new_thread()
    which doesn't allow to wait for thread exit, whereas thread.Thread has a
    join() method.
    NsYwait_threads() failed to cleanup %s threads after %.1f seconds (count: %s, old count: %s)g{�G�z�?(R@RAR�RVRxR�R�(R�t	old_countt
start_timetdeadlineRDtdtRL((s-/usr/lib64/python2.7/test/support/__init__.pytwait_threads_exit�s 	
	
cCscttd�r_d}xGtr[y/tj|tj�\}}|dkrLPnWqPqXqWndS(s�Use this function at the end of test_main() whenever sub-processes
    are started.  This will help ensure that no extra children (zombies)
    stick around to hog resources and create problems when looking
    for refleaks.
    twaitpidi����iN(R�RuRVRKtWNOHANG(tany_processR+tstatus((s-/usr/lib64/python2.7/test/support/__init__.pyR7�s		c	cs�t|�}g}zfy,x%|D]}|j�|j|�qWWn.trkdt|�t|�fGHn�nXdVWd|r�|�ntj�}}x�tdd�D]�}|d7}x.|D]&}|jt|tj�d��q�Wg|D]}|j	�r�|^q�}|sPntr�dt|�|fGHq�q�WXg|D]}|j	�rE|^qE}|r�t
dt|���ndS(Ns/Can't start %d threads, only %d threads startediii<g{�G�z�?s7Unable to join %d threads during a period of %d minutessUnable to join %d threads(RQtstartR\RR�R�RR�R�tisAliveRx(tthreadstunlocktstartedR�tendtimet	starttimeR�((s-/usr/lib64/python2.7/test/support/__init__.pyR1s:

	


$%%ccs�t||�rNt||�}t|||�z	|VWdt|||�Xn<t|||�z	dVWdt||�r�t||�nXdS(s�Temporary swap out an attribute with a new object.

    Usage:
        with swap_attr(obj, "attr", 5):
            ...

        This will set obj.attr to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `attr` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.

        The old value (or None if it doesn't exist) will be assigned to the
        target of the "as" clause, if there is one.
    N(R�RgR�tdelattr(RpRftnew_valtreal_val((s-/usr/lib64/python2.7/test/support/__init__.pyt	swap_attr)s		ccsk||kr:||}|||<z	|VWd|||<Xn-|||<z	dVWd||krf||=nXdS(s�Temporary swap out an item with a new object.

    Usage:
        with swap_item(obj, "item", 5):
            ...

        This will set obj["item"] to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `item` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.

        The old value (or None if it doesn't exist) will be assigned to the
        target of the "as" clause, if there is one.
    N((RptitemRWRX((s-/usr/lib64/python2.7/test/support/__init__.pyt	swap_itemHs

	
	cCs\y|j�SWnGtk
rWydjd�|D��SWqXtk
rSt|�SXnXdS(sZEmulate the py3k bytes() constructor.

    NOTE: This is only a best effort function.
    R�css|]}t|�VqdS(N(tchr(t.0R((s-/usr/lib64/python2.7/test/support/__init__.pys	<genexpr>rsN(ttobytesRhR�t	TypeErrortbytes(tb((s-/usr/lib64/python2.7/test/support/__init__.pyR5gs

t	getcountss-types are immortal if COUNT_ALLOCS is definedcCsddl}|j�S(sZReturn a list of command-line arguments reproducing the current
    settings in sys.flags.i����N(t
subprocesst_args_from_interpreter_flags(Rc((s-/usr/lib64/python2.7/test/support/__init__.pytargs_from_interpreter_flagsyscCstjdd|�j�}|S(s�Strip the stderr of a Python process from potential debug output
    emitted by the interpreter.

    This will typically be run on the result of the communicate() method
    of a subprocess.Popen object.
    s\[\d+ refs\]\r?\n?$R�(Rstsubtstrip(R�((s-/usr/lib64/python2.7/test/support/__init__.pyR8scsid|f��fd��Y}tg�|||���|jtt��t�|j�d�dS(NtAcseZ��fd�ZRS(cs0t�d<yt��Wntk
r+nXdS(Ni(RVtnextt
StopIteration(Ra(tdonetit(s-/usr/lib64/python2.7/test/support/__init__.pyt__del__�s


(R<R=Rm((RkRl(s-/usr/lib64/python2.7/test/support/__init__.pyRh�si(RXtassertRaisesRjRiR�t
assertTrue(R�titerR:R{Rh((RkRls-/usr/lib64/python2.7/test/support/__init__.pytcheck_free_after_iterating�s	ccs:tj�}tj�z	dVWd|r5tj�nXdS(N(R�t	isenabledtdisabletenable(thave_gc((s-/usr/lib64/python2.7/test/support/__init__.pyt
disable_gc�s
	cCsTtjd�pd}d}x,|j�D]}|jd�r(|}q(q(W|dkS(s,Find if Python was built with optimizations.t	PY_CFLAGSR�s-Os-O0s-Og(R�s-O0s-Og(t	sysconfigtget_config_varR�RR(tcflagst	final_opttopt((s-/usr/lib64/python2.7/test/support/__init__.pytpython_is_optimized�s
cBs,eZdZdZdZd�Zd�ZRS(s�Try to prevent a crash report from popping up.

    On Windows, don't display the Windows Error Reporting dialog.  On UNIX,
    disable the creation of coredump file.
    cCstjjd�r�ddl}|jj|_d}|jj|�|_|jj|j|B�yddl	}|j
Wnttfk
r�qXi|_
x|j|j|jgD]C}|j
||j�}|j||j�}||f|j
|<q�Wnyddl}Wntk
r%d}nX|dk	r�y9|j|j�|_|j|jd|jdf�Wq�ttfk
r�q�Xntjdkrddl}dd	d
dg}	|j|	d|jd
|j�}
|
j�d}|j�dkrtj j!d�tj j"�qn|S(s�On Windows, disable Windows Error Reporting dialogs using
        SetErrorMode.

        On UNIX, try to save the previous core file size limit, then set
        soft limit to 0.
        R~i����NiiiR�s/usr/bin/defaultsRZscom.apple.CrashReportert
DialogTypeRsR�t	developers:this test triggers the Crash Reporter, that is intentional(#RNR�RRR�R�tkernel32t_k32tSetErrorModet	old_valueR�tCrtSetReportModeRhRFt	old_modestCRT_WARNt	CRT_ERRORt
CRT_ASSERTtCRTDBG_MODE_FILEtCrtSetReportFiletCRTDBG_FILE_STDERRR�RYt	getrlimittRLIMIT_COREt	setrlimitR�R�RctPopentPIPEtcommunicateRgRsR[tflush(RaR�tSEM_NOGPFAULTERRORBOXR�treport_typetold_modetold_fileR�RctcmdtprocRs((s-/usr/lib64/python2.7/test/support/__init__.pyR��sV				

	cGs�|jdkrdStjjd�r�|jj|j�|jr�ddl}xF|jj	�D]2\}\}}|j
||�|j||�q]Wq�n@ddl}y|j
|j|j�Wnttfk
r�nXdS(sARestore Windows ErrorMode or core file behavior to initial value.NR~i����(R�RYRNR�RRR�R�R�R�R]R�R�R�R�R�R�R�(RaR�R�R�R�R�R�((s-/usr/lib64/python2.7/test/support/__init__.pyR�s	"N(R<R=R>RYR�R�R�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR;�s
	GcCs*ddl}t��|j�WdQXdS(s�Deliberate crash of Python.

    Python can be killed by a segmentation fault (SIGSEGV), a bus error
    (SIGBUS), or a different error depending on the platform.

    Use SuppressCrashReport() to prevent a crash report from popping up.
    i����N(R�R;t
_read_null(R�((s-/usr/lib64/python2.7/test/support/__init__.pyt
_crash_pythons	
c
Cs�tjjd�rdy!tjd�}t|�dSWqdtk
r`}|jtjkra�qaqdXnd}t	td�r�ytj
d�}Wq�tk
r�q�Xnd
}tjdkr+yd	d
l}|j
Wnttfk
r�q+Xi}x9|j|j|jfD]}|j
|d�||<qWnzyd}xlt|�D]^}ytj|�}Wn+tk
r�}	|	jtjkr��q�qAXtj|�|d7}qAWWd
|d
k	r�x7|j|j|jfD]}|j
|||�q�WnX|S(
s/Count the number of open file descriptors.
    tlinuxtfreebsds
/proc/self/fdiitsysconftSC_OPEN_MAXR;i����Ni(R�R�(RNR�RRRuR�R�R�R�R�R�R�RYtmsvcrtR�RhRFR�R�R�RtduptEBADFR�(
tnamesR�tMAXFDR�R�R�RDtfdtfd2R�((s-/usr/lib64/python2.7/test/support/__init__.pytfd_count#sR

	

	tSaveSignalscBs)eZdZd�Zd�Zd�ZRS(s�
    Save an restore signal handlers.

    This class is only able to save/restore signal handlers registered
    by the Python signal module: see bpo-13285 for "external" signal
    handlers.
    cCs�ddl}||_ttd|j��|_xHdD]@}yt||�}Wntk
rfq7nX|jj|�q7Wi|_dS(Ni����itSIGKILLtSIGSTOP(R�R�(	tsignalRQRtNSIGtsignalsRgRhRwthandlers(RaR�tsignametsignum((s-/usr/lib64/python2.7/test/support/__init__.pyRchs	

cCsIxB|jD]7}|jj|�}|dkr4q
n||j|<q
WdS(N(R�R�t	getsignalRYR�(RaR�thandler((s-/usr/lib64/python2.7/test/support/__init__.pytsaveus
cCs7x0|jj�D]\}}|jj||�qWdS(N(R�R]R�(RaR�R�((s-/usr/lib64/python2.7/test/support/__init__.pytrestore�s(R<R=R>RcR�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR�_s	
	((ii@i@i@ii(i@ii(((((�R>R<RFt
contextlibR�R/R�R�R�RwRNRuR�R�R@RGREtUserDictRsR�R�RxRjR@RYt__all__t
SHORT_TIMEOUTR�RRRRHRtcontextmanagerRVRDRXRRUR[R6R4RRRR�RRrRR	R
R}RRR�R�R�R�RR�RR
R�RRRRRR�R�RRRR9R
RRt
PIPE_MAX_SIZEt
SOCK_MAX_SIZERRRt	NameErrort
skipUnlesstrequires_unicodeRtFS_NONASCIItunichrt	characterR$R%tdecodetUnicodeErrorRJRRitTESTFN_UNICODEtTESTFN_ENCODINGR�RtTESTFN_UNENCODABLEtevalR&R�R(t
TEST_HTTP_URLR-RR,R0RRyR�tabspatht__file__tTEST_SUPPORT_DIRR6R�RXRRRDRRtobjectR^R�RR R!t	DictMixinR"R�R%R&R#R$R�R�R�R�R�R�R�R�R�R�R'R:R�R�R�t_4GR�R�R(R)RR*R+RRR2RR	R3RR R!R,R#R&R3R,RytHAVE_DOCSTRINGStrequires_docstringsR-tenvironment_alteredR.R/R0RJR7R1RYR[R5tskipIftrequires_type_collectingReR8RqRvR}R;R�R�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyt<module>s�

								
	
	
&					
!										J			<$			
	


												

				
	.			*' /D					

				$	"


		'				
	
					
	(			&
			#	 					
e		<support/__init__.py000064400000227217150532427410010407 0ustar00"""Supporting definitions for the Python regression tests."""

if __name__ != 'test.support':
    raise ImportError('test.support must be imported from the test package')

import contextlib
import errno
import fnmatch
import functools
import gc
import socket
import stat
import sys
import os
import platform
import shutil
import warnings
import unittest
import importlib
import UserDict
import re
import time
import struct
import sysconfig
import types

try:
    import thread
except ImportError:
    thread = None

__all__ = ["Error", "TestFailed", "TestDidNotRun", "ResourceDenied", "import_module",
           "verbose", "use_resources", "max_memuse", "record_original_stdout",
           "get_original_stdout", "unload", "unlink", "rmtree", "forget",
           "is_resource_enabled", "requires", "requires_mac_ver",
           "find_unused_port", "bind_port",
           "fcmp", "have_unicode", "is_jython", "TESTFN", "HOST", "FUZZ",
           "SAVEDCWD", "temp_cwd", "findfile", "sortdict", "check_syntax_error",
           "open_urlresource", "check_warnings", "check_py3k_warnings",
           "CleanImport", "EnvironmentVarGuard", "captured_output",
           "captured_stdout", "TransientResource", "transient_internet",
           "run_with_locale", "set_memlimit", "bigmemtest", "bigaddrspacetest",
           "BasicTestRunner", "run_unittest", "run_doctest", "threading_setup",
           "threading_cleanup", "reap_threads", "start_threads", "cpython_only",
           "check_impl_detail", "get_attribute", "py3k_bytes",
           "import_fresh_module", "threading_cleanup", "reap_children",
           "strip_python_stderr", "IPV6_ENABLED", "run_with_tz",
           "SuppressCrashReport"]

SHORT_TIMEOUT = 30.0  # Added to make backporting from 3.x easier

class Error(Exception):
    """Base class for regression test exceptions."""

class TestFailed(Error):
    """Test failed."""

class TestDidNotRun(Error):
    """Test did not run any subtests."""

class ResourceDenied(unittest.SkipTest):
    """Test skipped because it requested a disallowed resource.

    This is raised when a test calls requires() for a resource that
    has not been enabled.  It is used to distinguish between expected
    and unexpected skips.
    """

@contextlib.contextmanager
def _ignore_deprecated_imports(ignore=True):
    """Context manager to suppress package and module deprecation
    warnings when importing them.

    If ignore is False, this context manager has no effect."""
    if ignore:
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", ".+ (module|package)",
                                    DeprecationWarning)
            yield
    else:
        yield


def import_module(name, deprecated=False):
    """Import and return the module to be tested, raising SkipTest if
    it is not available.

    If deprecated is True, any module or package deprecation messages
    will be suppressed."""
    with _ignore_deprecated_imports(deprecated):
        try:
            return importlib.import_module(name)
        except ImportError, msg:
            raise unittest.SkipTest(str(msg))


def _save_and_remove_module(name, orig_modules):
    """Helper function to save and remove a module from sys.modules

       Raise ImportError if the module can't be imported."""
    # try to import the module and raise an error if it can't be imported
    if name not in sys.modules:
        __import__(name)
        del sys.modules[name]
    for modname in list(sys.modules):
        if modname == name or modname.startswith(name + '.'):
            orig_modules[modname] = sys.modules[modname]
            del sys.modules[modname]

def _save_and_block_module(name, orig_modules):
    """Helper function to save and block a module in sys.modules

       Return True if the module was in sys.modules, False otherwise."""
    saved = True
    try:
        orig_modules[name] = sys.modules[name]
    except KeyError:
        saved = False
    sys.modules[name] = None
    return saved


def import_fresh_module(name, fresh=(), blocked=(), deprecated=False):
    """Imports and returns a module, deliberately bypassing the sys.modules cache
    and importing a fresh copy of the module. Once the import is complete,
    the sys.modules cache is restored to its original state.

    Modules named in fresh are also imported anew if needed by the import.
    If one of these modules can't be imported, None is returned.

    Importing of modules named in blocked is prevented while the fresh import
    takes place.

    If deprecated is True, any module or package deprecation messages
    will be suppressed."""
    # NOTE: test_heapq, test_json, and test_warnings include extra sanity
    # checks to make sure that this utility function is working as expected
    with _ignore_deprecated_imports(deprecated):
        # Keep track of modules saved for later restoration as well
        # as those which just need a blocking entry removed
        orig_modules = {}
        names_to_remove = []
        _save_and_remove_module(name, orig_modules)
        try:
            for fresh_name in fresh:
                _save_and_remove_module(fresh_name, orig_modules)
            for blocked_name in blocked:
                if not _save_and_block_module(blocked_name, orig_modules):
                    names_to_remove.append(blocked_name)
            fresh_module = importlib.import_module(name)
        except ImportError:
            fresh_module = None
        finally:
            for orig_name, module in orig_modules.items():
                sys.modules[orig_name] = module
            for name_to_remove in names_to_remove:
                del sys.modules[name_to_remove]
        return fresh_module


def get_attribute(obj, name):
    """Get an attribute, raising SkipTest if AttributeError is raised."""
    try:
        attribute = getattr(obj, name)
    except AttributeError:
        if isinstance(obj, types.ModuleType):
            msg = "module %r has no attribute %r" % (obj.__name__, name)
        elif isinstance(obj, types.ClassType):
            msg = "class %s has no attribute %r" % (obj.__name__, name)
        elif isinstance(obj, types.InstanceType):
            msg = "%s instance has no attribute %r" % (obj.__class__.__name__, name)
        elif isinstance(obj, type):
            msg = "type object %r has no attribute %r" % (obj.__name__, name)
        else:
            msg = "%r object has no attribute %r" % (type(obj).__name__, name)
        raise unittest.SkipTest(msg)
    else:
        return attribute


verbose = 1              # Flag set to 0 by regrtest.py
use_resources = None     # Flag set to [] by regrtest.py
max_memuse = 0           # Disable bigmem tests (they will still be run with
                         # small sizes, to make sure they work.)
real_max_memuse = 0
failfast = False

# _original_stdout is meant to hold stdout at the time regrtest began.
# This may be "the real" stdout, or IDLE's emulation of stdout, or whatever.
# The point is to have some flavor of stdout the user can actually see.
_original_stdout = None
def record_original_stdout(stdout):
    global _original_stdout
    _original_stdout = stdout

def get_original_stdout():
    return _original_stdout or sys.stdout

def unload(name):
    try:
        del sys.modules[name]
    except KeyError:
        pass

def _force_run(path, func, *args):
    try:
        return func(*args)
    except EnvironmentError as err:
        if verbose >= 2:
            print('%s: %s' % (err.__class__.__name__, err))
            print('re-run %s%r' % (func.__name__, args))
        os.chmod(path, stat.S_IRWXU)
        return func(*args)

if sys.platform.startswith("win"):
    def _waitfor(func, pathname, waitall=False):
        # Perform the operation
        func(pathname)
        # Now setup the wait loop
        if waitall:
            dirname = pathname
        else:
            dirname, name = os.path.split(pathname)
            dirname = dirname or '.'
        # Check for `pathname` to be removed from the filesystem.
        # The exponential backoff of the timeout amounts to a total
        # of ~1 second after which the deletion is probably an error
        # anyway.
        # Testing on an i7@4.3GHz shows that usually only 1 iteration is
        # required when contention occurs.
        timeout = 0.001
        while timeout < 1.0:
            # Note we are only testing for the existence of the file(s) in
            # the contents of the directory regardless of any security or
            # access rights.  If we have made it this far, we have sufficient
            # permissions to do that much using Python's equivalent of the
            # Windows API FindFirstFile.
            # Other Windows APIs can fail or give incorrect results when
            # dealing with files that are pending deletion.
            L = os.listdir(dirname)
            if not (L if waitall else name in L):
                return
            # Increase the timeout and try again
            time.sleep(timeout)
            timeout *= 2
        warnings.warn('tests may fail, delete still pending for ' + pathname,
                      RuntimeWarning, stacklevel=4)

    def _unlink(filename):
        _waitfor(os.unlink, filename)

    def _rmdir(dirname):
        _waitfor(os.rmdir, dirname)

    def _rmtree(path):
        def _rmtree_inner(path):
            for name in _force_run(path, os.listdir, path):
                fullname = os.path.join(path, name)
                if os.path.isdir(fullname):
                    _waitfor(_rmtree_inner, fullname, waitall=True)
                    _force_run(fullname, os.rmdir, fullname)
                else:
                    _force_run(fullname, os.unlink, fullname)
        _waitfor(_rmtree_inner, path, waitall=True)
        _waitfor(lambda p: _force_run(p, os.rmdir, p), path)
else:
    _unlink = os.unlink
    _rmdir = os.rmdir

    def _rmtree(path):
        try:
            shutil.rmtree(path)
            return
        except EnvironmentError:
            pass

        def _rmtree_inner(path):
            for name in _force_run(path, os.listdir, path):
                fullname = os.path.join(path, name)
                try:
                    mode = os.lstat(fullname).st_mode
                except EnvironmentError:
                    mode = 0
                if stat.S_ISDIR(mode):
                    _rmtree_inner(fullname)
                    _force_run(path, os.rmdir, fullname)
                else:
                    _force_run(path, os.unlink, fullname)
        _rmtree_inner(path)
        os.rmdir(path)

def unlink(filename):
    try:
        _unlink(filename)
    except OSError as exc:
        if exc.errno not in (errno.ENOENT, errno.ENOTDIR):
            raise

def rmdir(dirname):
    try:
        _rmdir(dirname)
    except OSError as error:
        # The directory need not exist.
        if error.errno != errno.ENOENT:
            raise

def rmtree(path):
    try:
        _rmtree(path)
    except OSError, e:
        # Unix returns ENOENT, Windows returns ESRCH.
        if e.errno not in (errno.ENOENT, errno.ESRCH):
            raise

def forget(modname):
    '''"Forget" a module was ever imported by removing it from sys.modules and
    deleting any .pyc and .pyo files.'''
    unload(modname)
    for dirname in sys.path:
        unlink(os.path.join(dirname, modname + os.extsep + 'pyc'))
        # Deleting the .pyo file cannot be within the 'try' for the .pyc since
        # the chance exists that there is no .pyc (and thus the 'try' statement
        # is exited) but there is a .pyo file.
        unlink(os.path.join(dirname, modname + os.extsep + 'pyo'))

# Check whether a gui is actually available
def _is_gui_available():
    if hasattr(_is_gui_available, 'result'):
        return _is_gui_available.result
    reason = None
    if sys.platform.startswith('win'):
        # if Python is running as a service (such as the buildbot service),
        # gui interaction may be disallowed
        import ctypes
        import ctypes.wintypes
        UOI_FLAGS = 1
        WSF_VISIBLE = 0x0001
        class USEROBJECTFLAGS(ctypes.Structure):
            _fields_ = [("fInherit", ctypes.wintypes.BOOL),
                        ("fReserved", ctypes.wintypes.BOOL),
                        ("dwFlags", ctypes.wintypes.DWORD)]
        dll = ctypes.windll.user32
        h = dll.GetProcessWindowStation()
        if not h:
            raise ctypes.WinError()
        uof = USEROBJECTFLAGS()
        needed = ctypes.wintypes.DWORD()
        res = dll.GetUserObjectInformationW(h,
            UOI_FLAGS,
            ctypes.byref(uof),
            ctypes.sizeof(uof),
            ctypes.byref(needed))
        if not res:
            raise ctypes.WinError()
        if not bool(uof.dwFlags & WSF_VISIBLE):
            reason = "gui not available (WSF_VISIBLE flag not set)"
    elif sys.platform == 'darwin':
        # The Aqua Tk implementations on OS X can abort the process if
        # being called in an environment where a window server connection
        # cannot be made, for instance when invoked by a buildbot or ssh
        # process not running under the same user id as the current console
        # user.  To avoid that, raise an exception if the window manager
        # connection is not available.
        from ctypes import cdll, c_int, pointer, Structure
        from ctypes.util import find_library

        app_services = cdll.LoadLibrary(find_library("ApplicationServices"))

        if app_services.CGMainDisplayID() == 0:
            reason = "gui tests cannot run without OS X window manager"
        else:
            class ProcessSerialNumber(Structure):
                _fields_ = [("highLongOfPSN", c_int),
                            ("lowLongOfPSN", c_int)]
            psn = ProcessSerialNumber()
            psn_p = pointer(psn)
            if (  (app_services.GetCurrentProcess(psn_p) < 0) or
                  (app_services.SetFrontProcess(psn_p) < 0) ):
                reason = "cannot run without OS X gui process"

    # check on every platform whether tkinter can actually do anything
    if not reason:
        try:
            from Tkinter import Tk
            root = Tk()
            root.withdraw()
            root.update()
            root.destroy()
        except Exception as e:
            err_string = str(e)
            if len(err_string) > 50:
                err_string = err_string[:50] + ' [...]'
            reason = 'Tk unavailable due to {}: {}'.format(type(e).__name__,
                                                           err_string)

    _is_gui_available.reason = reason
    _is_gui_available.result = not reason

    return _is_gui_available.result

def is_resource_enabled(resource):
    """Test whether a resource is enabled.

    Known resources are set by regrtest.py.  If not running under regrtest.py,
    all resources are assumed enabled unless use_resources has been set.
    """
    return use_resources is None or resource in use_resources

def requires(resource, msg=None):
    """Raise ResourceDenied if the specified resource is not available."""
    if not is_resource_enabled(resource):
        if msg is None:
            msg = "Use of the `%s' resource not enabled" % resource
        raise ResourceDenied(msg)
    if resource == 'gui' and not _is_gui_available():
        raise ResourceDenied(_is_gui_available.reason)

def requires_mac_ver(*min_version):
    """Decorator raising SkipTest if the OS is Mac OS X and the OS X
    version if less than min_version.

    For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
    is lesser than 10.5.
    """
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kw):
            if sys.platform == 'darwin':
                version_txt = platform.mac_ver()[0]
                try:
                    version = tuple(map(int, version_txt.split('.')))
                except ValueError:
                    pass
                else:
                    if version < min_version:
                        min_version_txt = '.'.join(map(str, min_version))
                        raise unittest.SkipTest(
                            "Mac OS X %s or higher required, not %s"
                            % (min_version_txt, version_txt))
            return func(*args, **kw)
        wrapper.min_version = min_version
        return wrapper
    return decorator


# Don't use "localhost", since resolving it uses the DNS under recent
# Windows versions (see issue #18792).
HOST = "127.0.0.1"
HOSTv6 = "::1"


def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
    """Returns an unused port that should be suitable for binding.  This is
    achieved by creating a temporary socket with the same family and type as
    the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to
    the specified host address (defaults to 0.0.0.0) with the port set to 0,
    eliciting an unused ephemeral port from the OS.  The temporary socket is
    then closed and deleted, and the ephemeral port is returned.

    Either this method or bind_port() should be used for any tests where a
    server socket needs to be bound to a particular port for the duration of
    the test.  Which one to use depends on whether the calling code is creating
    a python socket, or if an unused port needs to be provided in a constructor
    or passed to an external program (i.e. the -accept argument to openssl's
    s_server mode).  Always prefer bind_port() over find_unused_port() where
    possible.  Hard coded ports should *NEVER* be used.  As soon as a server
    socket is bound to a hard coded port, the ability to run multiple instances
    of the test simultaneously on the same host is compromised, which makes the
    test a ticking time bomb in a buildbot environment. On Unix buildbots, this
    may simply manifest as a failed test, which can be recovered from without
    intervention in most cases, but on Windows, the entire python process can
    completely and utterly wedge, requiring someone to log in to the buildbot
    and manually kill the affected process.

    (This is easy to reproduce on Windows, unfortunately, and can be traced to
    the SO_REUSEADDR socket option having different semantics on Windows versus
    Unix/Linux.  On Unix, you can't have two AF_INET SOCK_STREAM sockets bind,
    listen and then accept connections on identical host/ports.  An EADDRINUSE
    socket.error will be raised at some point (depending on the platform and
    the order bind and listen were called on each socket).

    However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE
    will ever be raised when attempting to bind two identical host/ports. When
    accept() is called on each socket, the second caller's process will steal
    the port from the first caller, leaving them both in an awkwardly wedged
    state where they'll no longer respond to any signals or graceful kills, and
    must be forcibly killed via OpenProcess()/TerminateProcess().

    The solution on Windows is to use the SO_EXCLUSIVEADDRUSE socket option
    instead of SO_REUSEADDR, which effectively affords the same semantics as
    SO_REUSEADDR on Unix.  Given the propensity of Unix developers in the Open
    Source world compared to Windows ones, this is a common mistake.  A quick
    look over OpenSSL's 0.9.8g source shows that they use SO_REUSEADDR when
    openssl.exe is called with the 's_server' option, for example. See
    http://bugs.python.org/issue2550 for more info.  The following site also
    has a very thorough description about the implications of both REUSEADDR
    and EXCLUSIVEADDRUSE on Windows:
    http://msdn2.microsoft.com/en-us/library/ms740621(VS.85).aspx)

    XXX: although this approach is a vast improvement on previous attempts to
    elicit unused ports, it rests heavily on the assumption that the ephemeral
    port returned to us by the OS won't immediately be dished back out to some
    other process when we close and delete our temporary socket but before our
    calling code has a chance to bind the returned port.  We can deal with this
    issue if/when we come across it."""
    tempsock = socket.socket(family, socktype)
    port = bind_port(tempsock)
    tempsock.close()
    del tempsock
    return port

def bind_port(sock, host=HOST):
    """Bind the socket to a free port and return the port number.  Relies on
    ephemeral ports in order to ensure we are using an unbound port.  This is
    important as many tests may be running simultaneously, especially in a
    buildbot environment.  This method raises an exception if the sock.family
    is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR
    or SO_REUSEPORT set on it.  Tests should *never* set these socket options
    for TCP/IP sockets.  The only case for setting these options is testing
    multicasting via multiple UDP sockets.

    Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e.
    on Windows), it will be set on the socket.  This will prevent anyone else
    from bind()'ing to our host/port for the duration of the test.
    """
    if sock.family == socket.AF_INET and sock.type == socket.SOCK_STREAM:
        if hasattr(socket, 'SO_REUSEADDR'):
            if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) == 1:
                raise TestFailed("tests should never set the SO_REUSEADDR "   \
                                 "socket option on TCP/IP sockets!")
        if hasattr(socket, 'SO_REUSEPORT'):
            try:
                if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) == 1:
                    raise TestFailed("tests should never set the SO_REUSEPORT "   \
                                     "socket option on TCP/IP sockets!")
            except EnvironmentError:
                # Python's socket module was compiled using modern headers
                # thus defining SO_REUSEPORT but this process is running
                # under an older kernel that does not support SO_REUSEPORT.
                pass
        if hasattr(socket, 'SO_EXCLUSIVEADDRUSE'):
            sock.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1)

    sock.bind((host, 0))
    port = sock.getsockname()[1]
    return port

def _is_ipv6_enabled():
    """Check whether IPv6 is enabled on this host."""
    if socket.has_ipv6:
        sock = None
        try:
            sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
            sock.bind((HOSTv6, 0))
            return True
        except socket.error:
            pass
        finally:
            if sock:
                sock.close()
    return False

IPV6_ENABLED = _is_ipv6_enabled()

def system_must_validate_cert(f):
    """Skip the test on TLS certificate validation failures."""
    @functools.wraps(f)
    def dec(*args, **kwargs):
        try:
            f(*args, **kwargs)
        except IOError as e:
            if "CERTIFICATE_VERIFY_FAILED" in str(e):
                raise unittest.SkipTest("system does not contain "
                                        "necessary certificates")
            raise
    return dec

FUZZ = 1e-6

def fcmp(x, y): # fuzzy comparison function
    if isinstance(x, float) or isinstance(y, float):
        try:
            fuzz = (abs(x) + abs(y)) * FUZZ
            if abs(x-y) <= fuzz:
                return 0
        except:
            pass
    elif type(x) == type(y) and isinstance(x, (tuple, list)):
        for i in range(min(len(x), len(y))):
            outcome = fcmp(x[i], y[i])
            if outcome != 0:
                return outcome
        return (len(x) > len(y)) - (len(x) < len(y))
    return (x > y) - (x < y)


# A constant likely larger than the underlying OS pipe buffer size, to
# make writes blocking.
# Windows limit seems to be around 512 B, and many Unix kernels have a
# 64 KiB pipe buffer size or 16 * PAGE_SIZE: take a few megs to be sure.
# (see issue #17835 for a discussion of this number).
PIPE_MAX_SIZE = 4 * 1024 * 1024 + 1

# A constant likely larger than the underlying OS socket buffer size, to make
# writes blocking.
# The socket buffer sizes can usually be tuned system-wide (e.g. through sysctl
# on Linux), or on a per-socket basis (SO_SNDBUF/SO_RCVBUF). See issue #18643
# for a discussion of this number).
SOCK_MAX_SIZE = 16 * 1024 * 1024 + 1

is_jython = sys.platform.startswith('java')

try:
    unicode
    have_unicode = True
except NameError:
    have_unicode = False

requires_unicode = unittest.skipUnless(have_unicode, 'no unicode support')

def u(s):
    return unicode(s, 'unicode-escape')

# FS_NONASCII: non-ASCII Unicode character encodable by
# sys.getfilesystemencoding(), or None if there is no such character.
FS_NONASCII = None
if have_unicode:
    for character in (
        # First try printable and common characters to have a readable filename.
        # For each character, the encoding list are just example of encodings able
        # to encode the character (the list is not exhaustive).

        # U+00E6 (Latin Small Letter Ae): cp1252, iso-8859-1
        unichr(0x00E6),
        # U+0130 (Latin Capital Letter I With Dot Above): cp1254, iso8859_3
        unichr(0x0130),
        # U+0141 (Latin Capital Letter L With Stroke): cp1250, cp1257
        unichr(0x0141),
        # U+03C6 (Greek Small Letter Phi): cp1253
        unichr(0x03C6),
        # U+041A (Cyrillic Capital Letter Ka): cp1251
        unichr(0x041A),
        # U+05D0 (Hebrew Letter Alef): Encodable to cp424
        unichr(0x05D0),
        # U+060C (Arabic Comma): cp864, cp1006, iso8859_6, mac_arabic
        unichr(0x060C),
        # U+062A (Arabic Letter Teh): cp720
        unichr(0x062A),
        # U+0E01 (Thai Character Ko Kai): cp874
        unichr(0x0E01),

        # Then try more "special" characters. "special" because they may be
        # interpreted or displayed differently depending on the exact locale
        # encoding and the font.

        # U+00A0 (No-Break Space)
        unichr(0x00A0),
        # U+20AC (Euro Sign)
        unichr(0x20AC),
    ):
        try:
            # In Windows, 'mbcs' is used, and encode() returns '?'
            # for characters missing in the ANSI codepage
            if character.encode(sys.getfilesystemencoding())\
                        .decode(sys.getfilesystemencoding())\
                    != character:
                raise UnicodeError
        except UnicodeError:
            pass
        else:
            FS_NONASCII = character
            break

# Filename used for testing
if os.name == 'java':
    # Jython disallows @ in module names
    TESTFN = '$test'
elif os.name == 'riscos':
    TESTFN = 'testfile'
else:
    TESTFN = '@test'
    # Unicode name only used if TEST_FN_ENCODING exists for the platform.
    if have_unicode:
        # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding()
        # TESTFN_UNICODE is a filename that can be encoded using the
        # file system encoding, but *not* with the default (ascii) encoding
        if isinstance('', unicode):
            # python -U
            # XXX perhaps unicode() should accept Unicode strings?
            TESTFN_UNICODE = "@test-\xe0\xf2"
        else:
            # 2 latin characters.
            TESTFN_UNICODE = unicode("@test-\xe0\xf2", "latin-1")
        TESTFN_ENCODING = sys.getfilesystemencoding()
        # TESTFN_UNENCODABLE is a filename that should *not* be
        # able to be encoded by *either* the default or filesystem encoding.
        # This test really only makes sense on Windows NT platforms
        # which have special Unicode support in posixmodule.
        if (not hasattr(sys, "getwindowsversion") or
                sys.getwindowsversion()[3] < 2): #  0=win32s or 1=9x/ME
            TESTFN_UNENCODABLE = None
        else:
            # Japanese characters (I think - from bug 846133)
            TESTFN_UNENCODABLE = eval('u"@test-\u5171\u6709\u3055\u308c\u308b"')
            try:
                # XXX - Note - should be using TESTFN_ENCODING here - but for
                # Windows, "mbcs" currently always operates as if in
                # errors=ignore' mode - hence we get '?' characters rather than
                # the exception.  'Latin1' operates as we expect - ie, fails.
                # See [ 850997 ] mbcs encoding ignores errors
                TESTFN_UNENCODABLE.encode("Latin1")
            except UnicodeEncodeError:
                pass
            else:
                print \
                'WARNING: The filename %r CAN be encoded by the filesystem.  ' \
                'Unicode filename tests may not be effective' \
                % TESTFN_UNENCODABLE


# Disambiguate TESTFN for parallel testing, while letting it remain a valid
# module name.
TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid())

# Define the URL of a dedicated HTTP server for the network tests.
# The URL must use clear-text HTTP: no redirection to encrypted HTTPS.
TEST_HTTP_URL = "http://www.pythontest.net"

# Save the initial cwd
SAVEDCWD = os.getcwd()

@contextlib.contextmanager
def temp_dir(path=None, quiet=False):
    """Return a context manager that creates a temporary directory.

    Arguments:

      path: the directory to create temporarily.  If omitted or None,
        defaults to creating a temporary directory using tempfile.mkdtemp.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, if the path is specified and cannot be
        created, only a warning is issued.

    """
    dir_created = False
    if path is None:
        import tempfile
        path = tempfile.mkdtemp()
        dir_created = True
        path = os.path.realpath(path)
    else:
        if (have_unicode and isinstance(path, unicode) and
            not os.path.supports_unicode_filenames):
            try:
                path = path.encode(sys.getfilesystemencoding() or 'ascii')
            except UnicodeEncodeError:
                if not quiet:
                    raise unittest.SkipTest('unable to encode the cwd name with '
                                            'the filesystem encoding.')
        try:
            os.mkdir(path)
            dir_created = True
        except OSError:
            if not quiet:
                raise
            warnings.warn('tests may fail, unable to create temp dir: ' + path,
                          RuntimeWarning, stacklevel=3)
    if dir_created:
        pid = os.getpid()
    try:
        yield path
    finally:
        # In case the process forks, let only the parent remove the
        # directory. The child has a diffent process id. (bpo-30028)
        if dir_created and pid == os.getpid():
            rmtree(path)

@contextlib.contextmanager
def change_cwd(path, quiet=False):
    """Return a context manager that changes the current working directory.

    Arguments:

      path: the directory to use as the temporary current working directory.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, it issues only a warning and keeps the current
        working directory the same.

    """
    saved_dir = os.getcwd()
    try:
        os.chdir(path)
    except OSError:
        if not quiet:
            raise
        warnings.warn('tests may fail, unable to change CWD to: ' + path,
                      RuntimeWarning, stacklevel=3)
    try:
        yield os.getcwd()
    finally:
        os.chdir(saved_dir)


@contextlib.contextmanager
def temp_cwd(name='tempcwd', quiet=False):
    """
    Context manager that temporarily creates and changes the CWD.

    The function temporarily changes the current working directory
    after creating a temporary directory in the current directory with
    name *name*.  If *name* is None, the temporary directory is
    created using tempfile.mkdtemp.

    If *quiet* is False (default) and it is not possible to
    create or change the CWD, an error is raised.  If *quiet* is True,
    only a warning is raised and the original CWD is used.

    """
    with temp_dir(path=name, quiet=quiet) as temp_path:
        with change_cwd(temp_path, quiet=quiet) as cwd_dir:
            yield cwd_dir

# TEST_HOME_DIR refers to the top level directory of the "test" package
# that contains Python's regression test suite
TEST_SUPPORT_DIR = os.path.dirname(os.path.abspath(__file__))
TEST_HOME_DIR = os.path.dirname(TEST_SUPPORT_DIR)

# TEST_DATA_DIR is used as a target download location for remote resources
TEST_DATA_DIR = os.path.join(TEST_HOME_DIR, "data")

def findfile(file, subdir=None):
    """Try to find a file on sys.path and the working directory.  If it is not
    found the argument passed to the function is returned (this does not
    necessarily signal failure; could still be the legitimate path)."""
    if os.path.isabs(file):
        return file
    if subdir is not None:
        file = os.path.join(subdir, file)
    path = [TEST_HOME_DIR] + sys.path
    for dn in path:
        fn = os.path.join(dn, file)
        if os.path.exists(fn): return fn
    return file

def sortdict(dict):
    "Like repr(dict), but in sorted order."
    items = dict.items()
    items.sort()
    reprpairs = ["%r: %r" % pair for pair in items]
    withcommas = ", ".join(reprpairs)
    return "{%s}" % withcommas

def make_bad_fd():
    """
    Create an invalid file descriptor by opening and closing a file and return
    its fd.
    """
    file = open(TESTFN, "wb")
    try:
        return file.fileno()
    finally:
        file.close()
        unlink(TESTFN)

def check_syntax_error(testcase, statement, errtext='', lineno=None, offset=None):
    with testcase.assertRaisesRegexp(SyntaxError, errtext) as cm:
        compile(statement, '<test string>', 'exec')
    err = cm.exception
    if lineno is not None:
        testcase.assertEqual(err.lineno, lineno)
    if offset is not None:
        testcase.assertEqual(err.offset, offset)

def open_urlresource(url, check=None):
    import urlparse, urllib2

    filename = urlparse.urlparse(url)[2].split('/')[-1] # '/': it's URL!

    fn = os.path.join(TEST_DATA_DIR, filename)

    def check_valid_file(fn):
        f = open(fn)
        if check is None:
            return f
        elif check(f):
            f.seek(0)
            return f
        f.close()

    if os.path.exists(fn):
        f = check_valid_file(fn)
        if f is not None:
            return f
        unlink(fn)

    # Verify the requirement before downloading the file
    requires('urlfetch')

    print >> get_original_stdout(), '\tfetching %s ...' % url
    f = urllib2.urlopen(url, timeout=15)
    try:
        with open(fn, "wb") as out:
            s = f.read()
            while s:
                out.write(s)
                s = f.read()
    finally:
        f.close()

    f = check_valid_file(fn)
    if f is not None:
        return f
    raise TestFailed('invalid resource "%s"' % fn)


class WarningsRecorder(object):
    """Convenience wrapper for the warnings list returned on
       entry to the warnings.catch_warnings() context manager.
    """
    def __init__(self, warnings_list):
        self._warnings = warnings_list
        self._last = 0

    def __getattr__(self, attr):
        if len(self._warnings) > self._last:
            return getattr(self._warnings[-1], attr)
        elif attr in warnings.WarningMessage._WARNING_DETAILS:
            return None
        raise AttributeError("%r has no attribute %r" % (self, attr))

    @property
    def warnings(self):
        return self._warnings[self._last:]

    def reset(self):
        self._last = len(self._warnings)


def _filterwarnings(filters, quiet=False):
    """Catch the warnings, then check if all the expected
    warnings have been raised and re-raise unexpected warnings.
    If 'quiet' is True, only re-raise the unexpected warnings.
    """
    # Clear the warning registry of the calling module
    # in order to re-raise the warnings.
    frame = sys._getframe(2)
    registry = frame.f_globals.get('__warningregistry__')
    if registry:
        registry.clear()
    with warnings.catch_warnings(record=True) as w:
        # Set filter "always" to record all warnings.  Because
        # test_warnings swap the module, we need to look up in
        # the sys.modules dictionary.
        sys.modules['warnings'].simplefilter("always")
        yield WarningsRecorder(w)
    # Filter the recorded warnings
    reraise = [warning.message for warning in w]
    missing = []
    for msg, cat in filters:
        seen = False
        for exc in reraise[:]:
            message = str(exc)
            # Filter out the matching messages
            if (re.match(msg, message, re.I) and
                issubclass(exc.__class__, cat)):
                seen = True
                reraise.remove(exc)
        if not seen and not quiet:
            # This filter caught nothing
            missing.append((msg, cat.__name__))
    if reraise:
        raise AssertionError("unhandled warning %r" % reraise[0])
    if missing:
        raise AssertionError("filter (%r, %s) did not catch any warning" %
                             missing[0])


@contextlib.contextmanager
def check_warnings(*filters, **kwargs):
    """Context manager to silence warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default True without argument,
         default False if some filters are defined)

    Without argument, it defaults to:
        check_warnings(("", Warning), quiet=True)
    """
    quiet = kwargs.get('quiet')
    if not filters:
        filters = (("", Warning),)
        # Preserve backward compatibility
        if quiet is None:
            quiet = True
    return _filterwarnings(filters, quiet)


@contextlib.contextmanager
def check_py3k_warnings(*filters, **kwargs):
    """Context manager to silence py3k warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default False)

    Without argument, it defaults to:
        check_py3k_warnings(("", DeprecationWarning), quiet=False)
    """
    if sys.py3kwarning:
        if not filters:
            filters = (("", DeprecationWarning),)
    else:
        # It should not raise any py3k warning
        filters = ()
    return _filterwarnings(filters, kwargs.get('quiet'))


class CleanImport(object):
    """Context manager to force import to return a new module reference.

    This is useful for testing module-level behaviours, such as
    the emission of a DeprecationWarning on import.

    Use like this:

        with CleanImport("foo"):
            importlib.import_module("foo") # new reference
    """

    def __init__(self, *module_names):
        self.original_modules = sys.modules.copy()
        for module_name in module_names:
            if module_name in sys.modules:
                module = sys.modules[module_name]
                # It is possible that module_name is just an alias for
                # another module (e.g. stub for modules renamed in 3.x).
                # In that case, we also need delete the real module to clear
                # the import cache.
                if module.__name__ != module_name:
                    del sys.modules[module.__name__]
                del sys.modules[module_name]

    def __enter__(self):
        return self

    def __exit__(self, *ignore_exc):
        sys.modules.update(self.original_modules)


class EnvironmentVarGuard(UserDict.DictMixin):

    """Class to help protect the environment variable properly.  Can be used as
    a context manager."""

    def __init__(self):
        self._environ = os.environ
        self._changed = {}

    def __getitem__(self, envvar):
        return self._environ[envvar]

    def __setitem__(self, envvar, value):
        # Remember the initial value on the first access
        if envvar not in self._changed:
            self._changed[envvar] = self._environ.get(envvar)
        self._environ[envvar] = value

    def __delitem__(self, envvar):
        # Remember the initial value on the first access
        if envvar not in self._changed:
            self._changed[envvar] = self._environ.get(envvar)
        if envvar in self._environ:
            del self._environ[envvar]

    def keys(self):
        return self._environ.keys()

    def set(self, envvar, value):
        self[envvar] = value

    def unset(self, envvar):
        del self[envvar]

    def __enter__(self):
        return self

    def __exit__(self, *ignore_exc):
        for (k, v) in self._changed.items():
            if v is None:
                if k in self._environ:
                    del self._environ[k]
            else:
                self._environ[k] = v
        os.environ = self._environ


class DirsOnSysPath(object):
    """Context manager to temporarily add directories to sys.path.

    This makes a copy of sys.path, appends any directories given
    as positional arguments, then reverts sys.path to the copied
    settings when the context ends.

    Note that *all* sys.path modifications in the body of the
    context manager, including replacement of the object,
    will be reverted at the end of the block.
    """

    def __init__(self, *paths):
        self.original_value = sys.path[:]
        self.original_object = sys.path
        sys.path.extend(paths)

    def __enter__(self):
        return self

    def __exit__(self, *ignore_exc):
        sys.path = self.original_object
        sys.path[:] = self.original_value


class TransientResource(object):

    """Raise ResourceDenied if an exception is raised while the context manager
    is in effect that matches the specified exception and attributes."""

    def __init__(self, exc, **kwargs):
        self.exc = exc
        self.attrs = kwargs

    def __enter__(self):
        return self

    def __exit__(self, type_=None, value=None, traceback=None):
        """If type_ is a subclass of self.exc and value has attributes matching
        self.attrs, raise ResourceDenied.  Otherwise let the exception
        propagate (if any)."""
        if type_ is not None and issubclass(self.exc, type_):
            for attr, attr_value in self.attrs.iteritems():
                if not hasattr(value, attr):
                    break
                if getattr(value, attr) != attr_value:
                    break
            else:
                raise ResourceDenied("an optional resource is not available")


@contextlib.contextmanager
def transient_internet(resource_name, timeout=30.0, errnos=()):
    """Return a context manager that raises ResourceDenied when various issues
    with the Internet connection manifest themselves as exceptions."""
    default_errnos = [
        ('ECONNREFUSED', 111),
        ('ECONNRESET', 104),
        ('EHOSTUNREACH', 113),
        ('ENETUNREACH', 101),
        ('ETIMEDOUT', 110),
        # socket.create_connection() fails randomly with
        # EADDRNOTAVAIL on Travis CI.
        ('EADDRNOTAVAIL', 99),
    ]
    default_gai_errnos = [
        ('EAI_AGAIN', -3),
        ('EAI_FAIL', -4),
        ('EAI_NONAME', -2),
        ('EAI_NODATA', -5),
        # Windows defines EAI_NODATA as 11001 but idiotic getaddrinfo()
        # implementation actually returns WSANO_DATA i.e. 11004.
        ('WSANO_DATA', 11004),
    ]

    denied = ResourceDenied("Resource '%s' is not available" % resource_name)
    captured_errnos = errnos
    gai_errnos = []
    if not captured_errnos:
        captured_errnos = [getattr(errno, name, num)
                           for (name, num) in default_errnos]
        gai_errnos = [getattr(socket, name, num)
                      for (name, num) in default_gai_errnos]

    def filter_error(err):
        n = getattr(err, 'errno', None)
        if (isinstance(err, socket.timeout) or
            (isinstance(err, socket.gaierror) and n in gai_errnos) or
            n in captured_errnos):
            if not verbose:
                sys.stderr.write(denied.args[0] + "\n")
            raise denied

    old_timeout = socket.getdefaulttimeout()
    try:
        if timeout is not None:
            socket.setdefaulttimeout(timeout)
        yield
    except IOError as err:
        # urllib can wrap original socket errors multiple times (!), we must
        # unwrap to get at the original error.
        while True:
            a = err.args
            if len(a) >= 1 and isinstance(a[0], IOError):
                err = a[0]
            # The error can also be wrapped as args[1]:
            #    except socket.error as msg:
            #        raise IOError('socket error', msg).with_traceback(sys.exc_info()[2])
            elif len(a) >= 2 and isinstance(a[1], IOError):
                err = a[1]
            else:
                break
        filter_error(err)
        raise
    # XXX should we catch generic exceptions and look for their
    # __cause__ or __context__?
    finally:
        socket.setdefaulttimeout(old_timeout)


@contextlib.contextmanager
def captured_output(stream_name):
    """Return a context manager used by captured_stdout and captured_stdin
    that temporarily replaces the sys stream *stream_name* with a StringIO."""
    import StringIO
    orig_stdout = getattr(sys, stream_name)
    setattr(sys, stream_name, StringIO.StringIO())
    try:
        yield getattr(sys, stream_name)
    finally:
        setattr(sys, stream_name, orig_stdout)

def captured_stdout():
    """Capture the output of sys.stdout:

       with captured_stdout() as s:
           print "hello"
       self.assertEqual(s.getvalue(), "hello")
    """
    return captured_output("stdout")

def captured_stderr():
    return captured_output("stderr")

def captured_stdin():
    return captured_output("stdin")

def gc_collect():
    """Force as many objects as possible to be collected.

    In non-CPython implementations of Python, this is needed because timely
    deallocation is not guaranteed by the garbage collector.  (Even in CPython
    this can be the case in case of reference cycles.)  This means that __del__
    methods may be called later than expected and weakrefs may remain alive for
    longer than expected.  This function tries its best to force all garbage
    objects to disappear.
    """
    gc.collect()
    if is_jython:
        time.sleep(0.1)
    gc.collect()
    gc.collect()


_header = '2P'
if hasattr(sys, "gettotalrefcount"):
    _header = '2P' + _header
_vheader = _header + 'P'

def calcobjsize(fmt):
    return struct.calcsize(_header + fmt + '0P')

def calcvobjsize(fmt):
    return struct.calcsize(_vheader + fmt + '0P')


_TPFLAGS_HAVE_GC = 1<<14
_TPFLAGS_HEAPTYPE = 1<<9

def check_sizeof(test, o, size):
    import _testcapi
    result = sys.getsizeof(o)
    # add GC header size
    if ((type(o) == type) and (o.__flags__ & _TPFLAGS_HEAPTYPE) or\
        ((type(o) != type) and (type(o).__flags__ & _TPFLAGS_HAVE_GC))):
        size += _testcapi.SIZEOF_PYGC_HEAD
    msg = 'wrong size for %s: got %d, expected %d' \
            % (type(o), result, size)
    test.assertEqual(result, size, msg)


#=======================================================================
# Decorator for running a function in a different locale, correctly resetting
# it afterwards.

def run_with_locale(catstr, *locales):
    def decorator(func):
        def inner(*args, **kwds):
            try:
                import locale
                category = getattr(locale, catstr)
                orig_locale = locale.setlocale(category)
            except AttributeError:
                # if the test author gives us an invalid category string
                raise
            except:
                # cannot retrieve original locale, so do nothing
                locale = orig_locale = None
            else:
                for loc in locales:
                    try:
                        locale.setlocale(category, loc)
                        break
                    except:
                        pass

            # now run the function, resetting the locale on exceptions
            try:
                return func(*args, **kwds)
            finally:
                if locale and orig_locale:
                    locale.setlocale(category, orig_locale)
        inner.func_name = func.func_name
        inner.__doc__ = func.__doc__
        return inner
    return decorator

#=======================================================================
# Decorator for running a function in a specific timezone, correctly
# resetting it afterwards.

def run_with_tz(tz):
    def decorator(func):
        def inner(*args, **kwds):
            try:
                tzset = time.tzset
            except AttributeError:
                raise unittest.SkipTest("tzset required")
            if 'TZ' in os.environ:
                orig_tz = os.environ['TZ']
            else:
                orig_tz = None
            os.environ['TZ'] = tz
            tzset()

            # now run the function, resetting the tz on exceptions
            try:
                return func(*args, **kwds)
            finally:
                if orig_tz is None:
                    del os.environ['TZ']
                else:
                    os.environ['TZ'] = orig_tz
                time.tzset()

        inner.__name__ = func.__name__
        inner.__doc__ = func.__doc__
        return inner
    return decorator

#=======================================================================
# Big-memory-test support. Separate from 'resources' because memory use should be configurable.

# Some handy shorthands. Note that these are used for byte-limits as well
# as size-limits, in the various bigmem tests
_1M = 1024*1024
_1G = 1024 * _1M
_2G = 2 * _1G
_4G = 4 * _1G

MAX_Py_ssize_t = sys.maxsize

def set_memlimit(limit):
    global max_memuse
    global real_max_memuse
    sizes = {
        'k': 1024,
        'm': _1M,
        'g': _1G,
        't': 1024*_1G,
    }
    m = re.match(r'(\d+(\.\d+)?) (K|M|G|T)b?$', limit,
                 re.IGNORECASE | re.VERBOSE)
    if m is None:
        raise ValueError('Invalid memory limit %r' % (limit,))
    memlimit = int(float(m.group(1)) * sizes[m.group(3).lower()])
    real_max_memuse = memlimit
    if memlimit > MAX_Py_ssize_t:
        memlimit = MAX_Py_ssize_t
    if memlimit < _2G - 1:
        raise ValueError('Memory limit %r too low to be useful' % (limit,))
    max_memuse = memlimit

def bigmemtest(minsize, memuse, overhead=5*_1M):
    """Decorator for bigmem tests.

    'minsize' is the minimum useful size for the test (in arbitrary,
    test-interpreted units.) 'memuse' is the number of 'bytes per size' for
    the test, or a good estimate of it. 'overhead' specifies fixed overhead,
    independent of the testsize, and defaults to 5Mb.

    The decorator tries to guess a good value for 'size' and passes it to
    the decorated test function. If minsize * memuse is more than the
    allowed memory use (as defined by max_memuse), the test is skipped.
    Otherwise, minsize is adjusted upward to use up to max_memuse.
    """
    def decorator(f):
        def wrapper(self):
            if not max_memuse:
                # If max_memuse is 0 (the default),
                # we still want to run the tests with size set to a few kb,
                # to make sure they work. We still want to avoid using
                # too much memory, though, but we do that noisily.
                maxsize = 5147
                self.assertFalse(maxsize * memuse + overhead > 20 * _1M)
            else:
                maxsize = int((max_memuse - overhead) / memuse)
                if maxsize < minsize:
                    # Really ought to print 'test skipped' or something
                    if verbose:
                        sys.stderr.write("Skipping %s because of memory "
                                         "constraint\n" % (f.__name__,))
                    return
                # Try to keep some breathing room in memory use
                maxsize = max(maxsize - 50 * _1M, minsize)
            return f(self, maxsize)
        wrapper.minsize = minsize
        wrapper.memuse = memuse
        wrapper.overhead = overhead
        return wrapper
    return decorator

def precisionbigmemtest(size, memuse, overhead=5*_1M, dry_run=True):
    def decorator(f):
        def wrapper(self):
            if not real_max_memuse:
                maxsize = 5147
            else:
                maxsize = size

            if ((real_max_memuse or not dry_run)
                and real_max_memuse < maxsize * memuse):
                if verbose:
                    sys.stderr.write("Skipping %s because of memory "
                                     "constraint\n" % (f.__name__,))
                return

            return f(self, maxsize)
        wrapper.size = size
        wrapper.memuse = memuse
        wrapper.overhead = overhead
        return wrapper
    return decorator

def bigaddrspacetest(f):
    """Decorator for tests that fill the address space."""
    def wrapper(self):
        if max_memuse < MAX_Py_ssize_t:
            if verbose:
                sys.stderr.write("Skipping %s because of memory "
                                 "constraint\n" % (f.__name__,))
        else:
            return f(self)
    return wrapper

#=======================================================================
# unittest integration.

class BasicTestRunner:
    def run(self, test):
        result = unittest.TestResult()
        test(result)
        return result

def _id(obj):
    return obj

def requires_resource(resource):
    if resource == 'gui' and not _is_gui_available():
        return unittest.skip(_is_gui_available.reason)
    if is_resource_enabled(resource):
        return _id
    else:
        return unittest.skip("resource {0!r} is not enabled".format(resource))

def cpython_only(test):
    """
    Decorator for tests only applicable on CPython.
    """
    return impl_detail(cpython=True)(test)

def impl_detail(msg=None, **guards):
    if check_impl_detail(**guards):
        return _id
    if msg is None:
        guardnames, default = _parse_guards(guards)
        if default:
            msg = "implementation detail not available on {0}"
        else:
            msg = "implementation detail specific to {0}"
        guardnames = sorted(guardnames.keys())
        msg = msg.format(' or '.join(guardnames))
    return unittest.skip(msg)

def _parse_guards(guards):
    # Returns a tuple ({platform_name: run_me}, default_value)
    if not guards:
        return ({'cpython': True}, False)
    is_true = guards.values()[0]
    assert guards.values() == [is_true] * len(guards)   # all True or all False
    return (guards, not is_true)

# Use the following check to guard CPython's implementation-specific tests --
# or to run them only on the implementation(s) guarded by the arguments.
def check_impl_detail(**guards):
    """This function returns True or False depending on the host platform.
       Examples:
          if check_impl_detail():               # only on CPython (default)
          if check_impl_detail(jython=True):    # only on Jython
          if check_impl_detail(cpython=False):  # everywhere except on CPython
    """
    guards, default = _parse_guards(guards)
    return guards.get(platform.python_implementation().lower(), default)


def _filter_suite(suite, pred):
    """Recursively filter test cases in a suite based on a predicate."""
    newtests = []
    for test in suite._tests:
        if isinstance(test, unittest.TestSuite):
            _filter_suite(test, pred)
            newtests.append(test)
        else:
            if pred(test):
                newtests.append(test)
    suite._tests = newtests

def _run_suite(suite):
    """Run tests from a unittest.TestSuite-derived class."""
    if verbose:
        runner = unittest.TextTestRunner(sys.stdout, verbosity=2,
                                         failfast=failfast)
    else:
        runner = BasicTestRunner()

    result = runner.run(suite)
    if not result.testsRun and not result.skipped:
        raise TestDidNotRun
    if not result.wasSuccessful():
        if len(result.errors) == 1 and not result.failures:
            err = result.errors[0][1]
        elif len(result.failures) == 1 and not result.errors:
            err = result.failures[0][1]
        else:
            err = "multiple errors occurred"
            if not verbose:
                err += "; run in verbose mode for details"
        raise TestFailed(err)


# By default, don't filter tests
_match_test_func = None
_match_test_patterns = None


def match_test(test):
    # Function used by support.run_unittest() and regrtest --list-cases
    if _match_test_func is None:
        return True
    else:
        return _match_test_func(test.id())


def _is_full_match_test(pattern):
    # If a pattern contains at least one dot, it's considered
    # as a full test identifier.
    # Example: 'test.test_os.FileTests.test_access'.
    #
    # Reject patterns which contain fnmatch patterns: '*', '?', '[...]'
    # or '[!...]'. For example, reject 'test_access*'.
    return ('.' in pattern) and (not re.search(r'[?*\[\]]', pattern))


def set_match_tests(patterns):
    global _match_test_func, _match_test_patterns

    if patterns == _match_test_patterns:
        # No change: no need to recompile patterns.
        return

    if not patterns:
        func = None
        # set_match_tests(None) behaves as set_match_tests(())
        patterns = ()
    elif all(map(_is_full_match_test, patterns)):
        # Simple case: all patterns are full test identifier.
        # The test.bisect utility only uses such full test identifiers.
        func = set(patterns).__contains__
    else:
        regex = '|'.join(map(fnmatch.translate, patterns))
        # The search *is* case sensitive on purpose:
        # don't use flags=re.IGNORECASE
        regex_match = re.compile(regex).match

        def match_test_regex(test_id):
            if regex_match(test_id):
                # The regex matchs the whole identifier like
                # 'test.test_os.FileTests.test_access'
                return True
            else:
                # Try to match parts of the test identifier.
                # For example, split 'test.test_os.FileTests.test_access'
                # into: 'test', 'test_os', 'FileTests' and 'test_access'.
                return any(map(regex_match, test_id.split(".")))

        func = match_test_regex

    # Create a copy since patterns can be mutable and so modified later
    _match_test_patterns = tuple(patterns)
    _match_test_func = func



def run_unittest(*classes):
    """Run tests from unittest.TestCase-derived classes."""
    valid_types = (unittest.TestSuite, unittest.TestCase)
    suite = unittest.TestSuite()
    for cls in classes:
        if isinstance(cls, str):
            if cls in sys.modules:
                suite.addTest(unittest.findTestCases(sys.modules[cls]))
            else:
                raise ValueError("str arguments must be keys in sys.modules")
        elif isinstance(cls, valid_types):
            suite.addTest(cls)
        else:
            suite.addTest(unittest.makeSuite(cls))
    _filter_suite(suite, match_test)
    _run_suite(suite)

#=======================================================================
# Check for the presence of docstrings.

HAVE_DOCSTRINGS = (check_impl_detail(cpython=False) or
                   sys.platform == 'win32' or
                   sysconfig.get_config_var('WITH_DOC_STRINGS'))

requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS,
                                          "test requires docstrings")


#=======================================================================
# doctest driver.

def run_doctest(module, verbosity=None):
    """Run doctest on the given module.  Return (#failures, #tests).

    If optional argument verbosity is not specified (or is None), pass
    test.support's belief about verbosity on to doctest.  Else doctest's
    usual behavior is used (it searches sys.argv for -v).
    """

    import doctest

    if verbosity is None:
        verbosity = verbose
    else:
        verbosity = None

    # Direct doctest output (normally just errors) to real stdout; doctest
    # output shouldn't be compared by regrtest.
    save_stdout = sys.stdout
    sys.stdout = get_original_stdout()
    try:
        f, t = doctest.testmod(module, verbose=verbosity)
        if f:
            raise TestFailed("%d of %d doctests failed" % (f, t))
    finally:
        sys.stdout = save_stdout
    if verbose:
        print 'doctest (%s) ... %d tests with zero failures' % (module.__name__, t)
    return f, t

#=======================================================================
# Threading support to prevent reporting refleaks when running regrtest.py -R

# Flag used by saved_test_environment of test.libregrtest.save_env,
# to check if a test modified the environment. The flag should be set to False
# before running a new test.
#
# For example, threading_cleanup() sets the flag is the function fails
# to cleanup threads.
environment_altered = False

# NOTE: we use thread._count() rather than threading.enumerate() (or the
# moral equivalent thereof) because a threading.Thread object is still alive
# until its __bootstrap() method has returned, even after it has been
# unregistered from the threading module.
# thread._count(), on the other hand, only gets decremented *after* the
# __bootstrap() method has returned, which gives us reliable reference counts
# at the end of a test run.

def threading_setup():
    if thread:
        return thread._count(),
    else:
        return 1,

def threading_cleanup(nb_threads):
    if not thread:
        return

    _MAX_COUNT = 10
    for count in range(_MAX_COUNT):
        n = thread._count()
        if n == nb_threads:
            break
        time.sleep(0.1)
    # XXX print a warning in case of failure?

def reap_threads(func):
    """Use this function when threads are being used.  This will
    ensure that the threads are cleaned up even when the test fails.
    If threading is unavailable this function does nothing.
    """
    if not thread:
        return func

    @functools.wraps(func)
    def decorator(*args):
        key = threading_setup()
        try:
            return func(*args)
        finally:
            threading_cleanup(*key)
    return decorator


@contextlib.contextmanager
def wait_threads_exit(timeout=60.0):
    """
    bpo-31234: Context manager to wait until all threads created in the with
    statement exit.

    Use thread.count() to check if threads exited. Indirectly, wait until
    threads exit the internal t_bootstrap() C function of the thread module.

    threading_setup() and threading_cleanup() are designed to emit a warning
    if a test leaves running threads in the background. This context manager
    is designed to cleanup threads started by the thread.start_new_thread()
    which doesn't allow to wait for thread exit, whereas thread.Thread has a
    join() method.
    """
    old_count = thread._count()
    try:
        yield
    finally:
        start_time = time.time()
        deadline = start_time + timeout
        while True:
            count = thread._count()
            if count <= old_count:
                break
            if time.time() > deadline:
                dt = time.time() - start_time
                msg = ("wait_threads() failed to cleanup %s "
                       "threads after %.1f seconds "
                       "(count: %s, old count: %s)"
                       % (count - old_count, dt, count, old_count))
                raise AssertionError(msg)
            time.sleep(0.010)
            gc_collect()


def reap_children():
    """Use this function at the end of test_main() whenever sub-processes
    are started.  This will help ensure that no extra children (zombies)
    stick around to hog resources and create problems when looking
    for refleaks.
    """

    # Reap all our dead child processes so we don't leave zombies around.
    # These hog resources and might be causing some of the buildbots to die.
    if hasattr(os, 'waitpid'):
        any_process = -1
        while True:
            try:
                # This will raise an exception on Windows.  That's ok.
                pid, status = os.waitpid(any_process, os.WNOHANG)
                if pid == 0:
                    break
            except:
                break

@contextlib.contextmanager
def start_threads(threads, unlock=None):
    threads = list(threads)
    started = []
    try:
        try:
            for t in threads:
                t.start()
                started.append(t)
        except:
            if verbose:
                print("Can't start %d threads, only %d threads started" %
                      (len(threads), len(started)))
            raise
        yield
    finally:
        if unlock:
            unlock()
        endtime = starttime = time.time()
        for timeout in range(1, 16):
            endtime += 60
            for t in started:
                t.join(max(endtime - time.time(), 0.01))
            started = [t for t in started if t.isAlive()]
            if not started:
                break
            if verbose:
                print('Unable to join %d threads during a period of '
                      '%d minutes' % (len(started), timeout))
    started = [t for t in started if t.isAlive()]
    if started:
        raise AssertionError('Unable to join %d threads' % len(started))

@contextlib.contextmanager
def swap_attr(obj, attr, new_val):
    """Temporary swap out an attribute with a new object.

    Usage:
        with swap_attr(obj, "attr", 5):
            ...

        This will set obj.attr to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `attr` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.

        The old value (or None if it doesn't exist) will be assigned to the
        target of the "as" clause, if there is one.
    """
    if hasattr(obj, attr):
        real_val = getattr(obj, attr)
        setattr(obj, attr, new_val)
        try:
            yield real_val
        finally:
            setattr(obj, attr, real_val)
    else:
        setattr(obj, attr, new_val)
        try:
            yield
        finally:
            if hasattr(obj, attr):
                delattr(obj, attr)

@contextlib.contextmanager
def swap_item(obj, item, new_val):
    """Temporary swap out an item with a new object.

    Usage:
        with swap_item(obj, "item", 5):
            ...

        This will set obj["item"] to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `item` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.

        The old value (or None if it doesn't exist) will be assigned to the
        target of the "as" clause, if there is one.
    """
    if item in obj:
        real_val = obj[item]
        obj[item] = new_val
        try:
            yield real_val
        finally:
            obj[item] = real_val
    else:
        obj[item] = new_val
        try:
            yield
        finally:
            if item in obj:
                del obj[item]

def py3k_bytes(b):
    """Emulate the py3k bytes() constructor.

    NOTE: This is only a best effort function.
    """
    try:
        # memoryview?
        return b.tobytes()
    except AttributeError:
        try:
            # iterable of ints?
            return b"".join(chr(x) for x in b)
        except TypeError:
            return bytes(b)

requires_type_collecting = unittest.skipIf(hasattr(sys, 'getcounts'),
                        'types are immortal if COUNT_ALLOCS is defined')

def args_from_interpreter_flags():
    """Return a list of command-line arguments reproducing the current
    settings in sys.flags."""
    import subprocess
    return subprocess._args_from_interpreter_flags()

def strip_python_stderr(stderr):
    """Strip the stderr of a Python process from potential debug output
    emitted by the interpreter.

    This will typically be run on the result of the communicate() method
    of a subprocess.Popen object.
    """
    stderr = re.sub(br"\[\d+ refs\]\r?\n?$", b"", stderr).strip()
    return stderr


def check_free_after_iterating(test, iter, cls, args=()):
    class A(cls):
        def __del__(self):
            done[0] = True
            try:
                next(it)
            except StopIteration:
                pass

    done = [False]
    it = iter(A(*args))
    # Issue 26494: Shouldn't crash
    test.assertRaises(StopIteration, next, it)
    # The sequence should be deallocated just after the end of iterating
    gc_collect()
    test.assertTrue(done[0])

@contextlib.contextmanager
def disable_gc():
    have_gc = gc.isenabled()
    gc.disable()
    try:
        yield
    finally:
        if have_gc:
            gc.enable()


def python_is_optimized():
    """Find if Python was built with optimizations."""
    cflags = sysconfig.get_config_var('PY_CFLAGS') or ''
    final_opt = ""
    for opt in cflags.split():
        if opt.startswith('-O'):
            final_opt = opt
    return final_opt not in ('', '-O0', '-Og')


class SuppressCrashReport:
    """Try to prevent a crash report from popping up.

    On Windows, don't display the Windows Error Reporting dialog.  On UNIX,
    disable the creation of coredump file.
    """
    old_value = None
    old_modes = None

    def __enter__(self):
        """On Windows, disable Windows Error Reporting dialogs using
        SetErrorMode.

        On UNIX, try to save the previous core file size limit, then set
        soft limit to 0.
        """
        if sys.platform.startswith('win'):
            # see http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621.aspx
            # GetErrorMode is not available on Windows XP and Windows Server 2003,
            # but SetErrorMode returns the previous value, so we can use that
            import ctypes
            self._k32 = ctypes.windll.kernel32
            SEM_NOGPFAULTERRORBOX = 0x02
            self.old_value = self._k32.SetErrorMode(SEM_NOGPFAULTERRORBOX)
            self._k32.SetErrorMode(self.old_value | SEM_NOGPFAULTERRORBOX)

            # Suppress assert dialogs in debug builds
            # (see http://bugs.python.org/issue23314)
            try:
                import _testcapi
                _testcapi.CrtSetReportMode
            except (AttributeError, ImportError):
                # no _testcapi or a release build
                pass
            else:
                self.old_modes = {}
                for report_type in [_testcapi.CRT_WARN,
                                    _testcapi.CRT_ERROR,
                                    _testcapi.CRT_ASSERT]:
                    old_mode = _testcapi.CrtSetReportMode(report_type,
                            _testcapi.CRTDBG_MODE_FILE)
                    old_file = _testcapi.CrtSetReportFile(report_type,
                            _testcapi.CRTDBG_FILE_STDERR)
                    self.old_modes[report_type] = old_mode, old_file

        else:
            try:
                import resource
            except ImportError:
                resource = None

            if resource is not None:
                try:
                    self.old_value = resource.getrlimit(resource.RLIMIT_CORE)
                    resource.setrlimit(resource.RLIMIT_CORE,
                                       (0, self.old_value[1]))
                except (ValueError, OSError):
                    pass

            if sys.platform == 'darwin':
                # Check if the 'Crash Reporter' on OSX was configured
                # in 'Developer' mode and warn that it will get triggered
                # when it is.
                #
                # This assumes that this context manager is used in tests
                # that might trigger the next manager.
                import subprocess
                cmd = ['/usr/bin/defaults', 'read',
                       'com.apple.CrashReporter', 'DialogType']
                proc = subprocess.Popen(cmd,
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE)
                stdout = proc.communicate()[0]
                if stdout.strip() == b'developer':
                    sys.stdout.write("this test triggers the Crash Reporter, "
                                     "that is intentional")
                    sys.stdout.flush()

        return self

    def __exit__(self, *ignore_exc):
        """Restore Windows ErrorMode or core file behavior to initial value."""
        if self.old_value is None:
            return

        if sys.platform.startswith('win'):
            self._k32.SetErrorMode(self.old_value)

            if self.old_modes:
                import _testcapi
                for report_type, (old_mode, old_file) in self.old_modes.items():
                    _testcapi.CrtSetReportMode(report_type, old_mode)
                    _testcapi.CrtSetReportFile(report_type, old_file)
        else:
            import resource
            try:
                resource.setrlimit(resource.RLIMIT_CORE, self.old_value)
            except (ValueError, OSError):
                pass


def _crash_python():
    """Deliberate crash of Python.

    Python can be killed by a segmentation fault (SIGSEGV), a bus error
    (SIGBUS), or a different error depending on the platform.

    Use SuppressCrashReport() to prevent a crash report from popping up.
    """

    import _testcapi
    with SuppressCrashReport():
        _testcapi._read_null()


def fd_count():
    """Count the number of open file descriptors.
    """
    if sys.platform.startswith(('linux', 'freebsd')):
        try:
            names = os.listdir("/proc/self/fd")
            # Substract one because listdir() opens internally a file
            # descriptor to list the content of the /proc/self/fd/ directory.
            return len(names) - 1
        except OSError as exc:
            if exc.errno != errno.ENOENT:
                raise

    MAXFD = 256
    if hasattr(os, 'sysconf'):
        try:
            MAXFD = os.sysconf("SC_OPEN_MAX")
        except OSError:
            pass

    old_modes = None
    if sys.platform == 'win32':
        # bpo-25306, bpo-31009: Call CrtSetReportMode() to not kill the process
        # on invalid file descriptor if Python is compiled in debug mode
        try:
            import msvcrt
            msvcrt.CrtSetReportMode
        except (AttributeError, ImportError):
            # no msvcrt or a release build
            pass
        else:
            old_modes = {}
            for report_type in (msvcrt.CRT_WARN,
                                msvcrt.CRT_ERROR,
                                msvcrt.CRT_ASSERT):
                old_modes[report_type] = msvcrt.CrtSetReportMode(report_type, 0)

    try:
        count = 0
        for fd in range(MAXFD):
            try:
                # Prefer dup() over fstat(). fstat() can require input/output
                # whereas dup() doesn't.
                fd2 = os.dup(fd)
            except OSError as e:
                if e.errno != errno.EBADF:
                    raise
            else:
                os.close(fd2)
                count += 1
    finally:
        if old_modes is not None:
            for report_type in (msvcrt.CRT_WARN,
                                msvcrt.CRT_ERROR,
                                msvcrt.CRT_ASSERT):
                msvcrt.CrtSetReportMode(report_type, old_modes[report_type])

    return count


class SaveSignals:
    """
    Save an restore signal handlers.

    This class is only able to save/restore signal handlers registered
    by the Python signal module: see bpo-13285 for "external" signal
    handlers.
    """

    def __init__(self):
        import signal
        self.signal = signal
        self.signals = list(range(1, signal.NSIG))
        # SIGKILL and SIGSTOP signals cannot be ignored nor catched
        for signame in ('SIGKILL', 'SIGSTOP'):
            try:
                signum = getattr(signal, signame)
            except AttributeError:
                continue
            self.signals.remove(signum)
        self.handlers = {}

    def save(self):
        for signum in self.signals:
            handler = self.signal.getsignal(signum)
            if handler is None:
                # getsignal() returns None if a signal handler was not
                # registered by the Python signal module,
                # and the handler is not SIG_DFL nor SIG_IGN.
                #
                # Ignore the signal: we cannot restore the handler.
                continue
            self.handlers[signum] = handler

    def restore(self):
        for signum, handler in self.handlers.items():
            self.signal.signal(signum, handler)
support/__init__.pyc000064400000211622150532427410010543 0ustar00�
{fc=@s�
dZedkr!ed��nddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZyddlZWnek
r:dZnXddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d4d<d=d>d?d@g=ZdAZdefdB��YZdefdC��YZdefdD��YZdejfdE��YZ ej!e"dF��Z#e$dG�Z%dH�Z&dI�Z'd�d�e$dJ�Z(dK�Z)dLZ*dZ+dMa,dMa-e$Z.da/dN�Z0dO�Z1dP�Z2dQ�Z3e
jj4dR�r+e$dS�Z5dT�Z6dU�Z7dV�Z8nej9Z6ej:Z7dW�Z8dX�Z9dY�Z:dZ�Z;d[�Z<d\�Z=d]�Z>dd^�Z?d_�Z@d`ZAdaZBejCejDdb�ZEeAdc�ZFdd�ZGeG�ZHde�ZIdfZJdg�ZKd�ZLd�ZMe
jj4dk�ZNyeOe"ZPWneQk
r-e$ZPnXejRePdl�ZSdm�ZTdZUePrx�eVdn�eVdo�eVdp�eVdq�eVdr�eVds�eVdt�eVdu�eVdv�eVdw�eVdx�fD]XZWy7eWjXe
jY��jZe
jY��eWkr�e[�nWne[k
rq�XeWZUPq�Wnej\dkkr6dyZ]n�ej\dzkrNd{Z]n�d|Z]ePr�e^d}eO�rrd~Z_neOd~d�Z_e
jY�Z`eae
d��s�e
jb�d�d�kr�dZcq�edd��ZcyecjXd��Wneek
r�q�Xd�ecGHnd�jfe]ejg��Z]d�Zheji�Zjej!de$d���Zkej!e$d���Zlej!d�e$d���Zmejnjoejnjpeq��Zrejnjoer�Zsejnjtesd��Zudd��Zvd��Zwd��Zxd}ddd��Zydd��Zzd�e{fd���YZ|e$d��Z}ej!d���Z~ej!d���Zd&e{fd���YZ�d'ej�fd���YZ�d�e{fd���YZ�d*e{fd���YZ�ej!dAd�d���Z�ej!d���Z�d��Z�d��Z�d��Z�d��Z�d�Z�eae
d��r�d�e�Z�ne�d�Z�d��Z�d��Z�d�Z�d�Z�d��Z�d��Z�d��Z�d�Z�die�Z�d�e�Z�dhe�Z�e
j�Z�d��Z�d�e�d��Z�d�e�e"d��Z�d��Z�d0d�d���YZ�d��Z�d��Z�d��Z�dd��Z�d��Z�d��Z�d��Z�d��Z�da�da�d��Z�d��Z�d��Z�d��Z�e�d�e$�pW	e
jd�kpW	ej�d��Z�ejRe�d��Z�dd��Z�e$Z�d��Z�d��Z�d��Z�ej!d�d���Z�d��Z�ej!dd���Z�ej!d���Z�ej!d���Z�d��Z�ej�eae
d��d��Z�d��Z�d��Z�d�d��Z�ej!d���Z�d��Z�d@d�d���YZ�d��Z�d��Z�d�d�d���YZ�dS(�s7Supporting definitions for the Python regression tests.stest.supports3test.support must be imported from the test packagei����NtErrort
TestFailedt
TestDidNotRuntResourceDeniedt
import_moduletverboset
use_resourcest
max_memusetrecord_original_stdouttget_original_stdouttunloadtunlinktrmtreetforgettis_resource_enabledtrequirestrequires_mac_vertfind_unused_portt	bind_porttfcmpthave_unicodet	is_jythontTESTFNtHOSTtFUZZtSAVEDCWDttemp_cwdtfindfiletsortdicttcheck_syntax_errortopen_urlresourcetcheck_warningstcheck_py3k_warningstCleanImporttEnvironmentVarGuardtcaptured_outputtcaptured_stdouttTransientResourcettransient_internettrun_with_localetset_memlimitt
bigmemtesttbigaddrspacetesttBasicTestRunnertrun_unittesttrun_doctesttthreading_setuptthreading_cleanuptreap_threadst
start_threadstcpython_onlytcheck_impl_detailt
get_attributet
py3k_bytestimport_fresh_modulet
reap_childrentstrip_python_stderrtIPV6_ENABLEDtrun_with_tztSuppressCrashReportg>@cBseZdZRS(s*Base class for regression test exceptions.(t__name__t
__module__t__doc__(((s-/usr/lib64/python2.7/test/support/__init__.pyR4scBseZdZRS(sTest failed.(R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR7scBseZdZRS(sTest did not run any subtests.(R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR:scBseZdZRS(s�Test skipped because it requested a disallowed resource.

    This is raised when a test calls requires() for a resource that
    has not been enabled.  It is used to distinguish between expected
    and unexpected skips.
    (R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR=sccs=|r4tj��tjddt�dVWdQXndVdS(s�Context manager to suppress package and module deprecation
    warnings when importing them.

    If ignore is False, this context manager has no effect.tignores.+ (module|package)N(twarningstcatch_warningstfilterwarningstDeprecationWarning(R?((s-/usr/lib64/python2.7/test/support/__init__.pyt_ignore_deprecated_importsEs
c	CsSt|��Aytj|�SWn(tk
rH}tjt|���nXWdQXdS(s�Import and return the module to be tested, raising SkipTest if
    it is not available.

    If deprecated is True, any module or package deprecation messages
    will be suppressed.N(RDt	importlibRtImportErrortunittesttSkipTesttstr(tnamet
deprecatedtmsg((s-/usr/lib64/python2.7/test/support/__init__.pyRTs

cCs�|tjkr&t|�tj|=nxTttj�D]C}||ks[|j|d�r6tj|||<tj|=q6q6WdS(swHelper function to save and remove a module from sys.modules

       Raise ImportError if the module can't be imported.t.N(tsystmodulest
__import__tlistt
startswith(RJtorig_modulestmodname((s-/usr/lib64/python2.7/test/support/__init__.pyt_save_and_remove_moduleas

cCsFt}ytj|||<Wntk
r4t}nXdtj|<|S(s�Helper function to save and block a module in sys.modules

       Return True if the module was in sys.modules, False otherwise.N(tTrueRNROtKeyErrortFalsetNone(RJRStsaved((s-/usr/lib64/python2.7/test/support/__init__.pyt_save_and_block_modulens


cCs�t|���i}g}t||�zyax|D]}t||�q3Wx-|D]%}t||�sQ|j|�qQqQWtj|�}Wntk
r�d}nXWdx'|j�D]\}	}
|
t	j
|	<q�Wx|D]}t	j
|=q�WX|SWdQXdS(sImports and returns a module, deliberately bypassing the sys.modules cache
    and importing a fresh copy of the module. Once the import is complete,
    the sys.modules cache is restored to its original state.

    Modules named in fresh are also imported anew if needed by the import.
    If one of these modules can't be imported, None is returned.

    Importing of modules named in blocked is prevented while the fresh import
    takes place.

    If deprecated is True, any module or package deprecation messages
    will be suppressed.N(RDRUR[tappendRERRFRYtitemsRNRO(RJtfreshtblockedRKRStnames_to_removet
fresh_nametblocked_nametfresh_modulet	orig_nametmoduletname_to_remove((s-/usr/lib64/python2.7/test/support/__init__.pyR6{s&





cCs�yt||�}Wn�tk
r�t|tj�rKd|j|f}n�t|tj�rsd|j|f}nit|tj�r�d|jj|f}n>t|t	�r�d|j|f}ndt	|�j|f}t
j|��nX|SdS(s?Get an attribute, raising SkipTest if AttributeError is raised.smodule %r has no attribute %rsclass %s has no attribute %rs%s instance has no attribute %rs"type object %r has no attribute %rs%r object has no attribute %rN(tgetattrtAttributeErrort
isinstancettypest
ModuleTypeR<t	ClassTypetInstanceTypet	__class__ttypeRGRH(tobjRJt	attributeRL((s-/usr/lib64/python2.7/test/support/__init__.pyR4�s
iicCs
|adS(N(t_original_stdout(tstdout((s-/usr/lib64/python2.7/test/support/__init__.pyR�scCs
tptjS(N(RrRNRs(((s-/usr/lib64/python2.7/test/support/__init__.pyR	�scCs&ytj|=Wntk
r!nXdS(N(RNRORW(RJ((s-/usr/lib64/python2.7/test/support/__init__.pyR
�s
cGsxy||�SWnctk
rs}tdkrVd|jj|fGHd|j|fGHntj|tj�||�SXdS(Nis%s: %ssre-run %s%r(tEnvironmentErrorRRnR<tostchmodtstattS_IRWXU(tpathtfunctargsterr((s-/usr/lib64/python2.7/test/support/__init__.pyt
_force_run�stwincCs�||�|r|}n$tjj|�\}}|p:d}d}xR|dkr�tj|�}|rm|n	||ks}dStj|�|d9}qFWtjd|tdd�dS(NRMg����MbP?g�?is)tests may fail, delete still pending for t
stackleveli(	RuRytsplittlistdirttimetsleepR@twarntRuntimeWarning(RztpathnametwaitalltdirnameRJttimeouttL((s-/usr/lib64/python2.7/test/support/__init__.pyt_waitfor�s
	

cCsttj|�dS(N(R�RuR(tfilename((s-/usr/lib64/python2.7/test/support/__init__.pyt_unlink�scCsttj|�dS(N(R�Rutrmdir(R�((s-/usr/lib64/python2.7/test/support/__init__.pyt_rmdir�scs6�fd��t�|dt�td�|�dS(Ncs�x�t|tj|�D]i}tjj||�}tjj|�rlt�|dt�t|tj|�qt|tj	|�qWdS(NR�(
R}RuR�RytjointisdirR�RVR�R(RyRJtfullname(t
_rmtree_inner(s-/usr/lib64/python2.7/test/support/__init__.pyR�sR�cSst|tj|�S(N(R}RuR�(tp((s-/usr/lib64/python2.7/test/support/__init__.pyt<lambda>	t(R�RV(Ry((R�s-/usr/lib64/python2.7/test/support/__init__.pyt_rmtree�scsSytj|�dSWntk
r(nX�fd���|�tj|�dS(Ncs�x�t|tj|�D]�}tjj||�}ytj|�j}Wntk
r`d}nXtj	|�r��|�t|tj
|�qt|tj|�qWdS(Ni(R}RuR�RyR�tlstattst_modeRtRwtS_ISDIRR�R(RyRJR�tmode(R�(s-/usr/lib64/python2.7/test/support/__init__.pyR�s


(tshutilRRtRuR�(Ry((R�s-/usr/lib64/python2.7/test/support/__init__.pyR�s


cCsIyt|�Wn4tk
rD}|jtjtjfkrE�qEnXdS(N(R�tOSErrorterrnotENOENTtENOTDIR(R�texc((s-/usr/lib64/python2.7/test/support/__init__.pyR$s
cCs@yt|�Wn+tk
r;}|jtjkr<�q<nXdS(N(R�R�R�R�(R�terror((s-/usr/lib64/python2.7/test/support/__init__.pyR�+s
cCsIyt|�Wn4tk
rD}|jtjtjfkrE�qEnXdS(N(R�R�R�R�tESRCH(Ryte((s-/usr/lib64/python2.7/test/support/__init__.pyR3s
cCsjt|�xYtjD]N}ttjj||tjd��ttjj||tjd��qWdS(sm"Forget" a module was ever imported by removing it from sys.modules and
    deleting any .pyc and .pyo files.tpyctpyoN(R
RNRyRRuR�textsep(RTR�((s-/usr/lib64/python2.7/test/support/__init__.pyR
;s
$cs�ttd�rtjSd}tjjd�r ddl�ddl�d}d}d�j	f�fd��Y}�j
j}|j�}|s��j
��n|�}�jj�}|j||�j|��j|��j|��}|s�j
��nt|j|@�s�d}q�n�tjdkr�dd	lm}	m�m}
m	}dd
lm}|	j|d��}
|
j�dkr�d
}q�d|f�fd��Y}|�}|
|�}|
j|�dks�|
j|�dkr�d}q�n|s�y;ddlm}|�}|j �|j!�|j"�Wq�t#k
r�}t$|�}t%|�dkrz|d d}ndj&t'|�j(|�}q�Xn|t_)|t_tjS(NtresultR~i����itUSEROBJECTFLAGScs;eZd�jjfd�jjfd�jjfgZRS(tfInheritt	fReservedtdwFlags(R<R=twintypestBOOLtDWORDt_fields_((tctypes(s-/usr/lib64/python2.7/test/support/__init__.pyR�Rss,gui not available (WSF_VISIBLE flag not set)tdarwin(tcdlltc_inttpointert	Structure(tfind_librarytApplicationServicesis0gui tests cannot run without OS X window managertProcessSerialNumbercs eZd�fd�fgZRS(t
highLongOfPSNtlowLongOfPSN(R<R=R�((R�(s-/usr/lib64/python2.7/test/support/__init__.pyR�ts	s#cannot run without OS X gui process(tTki2s [...]sTk unavailable due to {}: {}(*thasattrt_is_gui_availableR�RYRNtplatformRRR�tctypes.wintypesR�twindlltuser32tGetProcessWindowStationtWinErrorR�R�tGetUserObjectInformationWtbyreftsizeoftboolR�R�R�R�tctypes.utilR�tLoadLibrarytCGMainDisplayIDtGetCurrentProcesstSetFrontProcesstTkinterR�twithdrawtupdatetdestroyt	ExceptionRItlentformatRoR<treason(R�t	UOI_FLAGStWSF_VISIBLER�tdllthtuoftneededtresR�R�R�R�tapp_servicesR�tpsntpsn_pR�trootR�t
err_string((R�R�s-/usr/lib64/python2.7/test/support/__init__.pyR�Gsh		"			

	
cCstdkp|tkS(s�Test whether a resource is enabled.

    Known resources are set by regrtest.py.  If not running under regrtest.py,
    all resources are assumed enabled unless use_resources has been set.
    N(RRY(tresource((s-/usr/lib64/python2.7/test/support/__init__.pyR�scCs`t|�s4|dkr%d|}nt|��n|dkr\t�r\ttj��ndS(s@Raise ResourceDenied if the specified resource is not available.s$Use of the `%s' resource not enabledtguiN(RRYRR�R�(R�RL((s-/usr/lib64/python2.7/test/support/__init__.pyR�s
cs�fd�}|S(s�Decorator raising SkipTest if the OS is Mac OS X and the OS X
    version if less than min_version.

    For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
    is lesser than 10.5.
    cs.tj����fd��}�|_|S(Ncs�tjdkr�tj�d}y"ttt|jd���}Wntk
rTq�X|�kr�djtt	���}t
jd||f��q�n�||�S(NR�iRMs&Mac OS X %s or higher required, not %s(RNR�tmac_verttupletmaptintR�t
ValueErrorR�RIRGRH(R{tkwtversion_txttversiontmin_version_txt(Rztmin_version(s-/usr/lib64/python2.7/test/support/__init__.pytwrapper�s"
(t	functoolstwrapsR�(RzR�(R�(Rzs-/usr/lib64/python2.7/test/support/__init__.pyt	decorator�s!	((R�R�((R�s-/usr/lib64/python2.7/test/support/__init__.pyR�ss	127.0.0.1s::1cCs/tj||�}t|�}|j�~|S(s�
Returns an unused port that should be suitable for binding.  This is
    achieved by creating a temporary socket with the same family and type as
    the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to
    the specified host address (defaults to 0.0.0.0) with the port set to 0,
    eliciting an unused ephemeral port from the OS.  The temporary socket is
    then closed and deleted, and the ephemeral port is returned.

    Either this method or bind_port() should be used for any tests where a
    server socket needs to be bound to a particular port for the duration of
    the test.  Which one to use depends on whether the calling code is creating
    a python socket, or if an unused port needs to be provided in a constructor
    or passed to an external program (i.e. the -accept argument to openssl's
    s_server mode).  Always prefer bind_port() over find_unused_port() where
    possible.  Hard coded ports should *NEVER* be used.  As soon as a server
    socket is bound to a hard coded port, the ability to run multiple instances
    of the test simultaneously on the same host is compromised, which makes the
    test a ticking time bomb in a buildbot environment. On Unix buildbots, this
    may simply manifest as a failed test, which can be recovered from without
    intervention in most cases, but on Windows, the entire python process can
    completely and utterly wedge, requiring someone to log in to the buildbot
    and manually kill the affected process.

    (This is easy to reproduce on Windows, unfortunately, and can be traced to
    the SO_REUSEADDR socket option having different semantics on Windows versus
    Unix/Linux.  On Unix, you can't have two AF_INET SOCK_STREAM sockets bind,
    listen and then accept connections on identical host/ports.  An EADDRINUSE
    socket.error will be raised at some point (depending on the platform and
    the order bind and listen were called on each socket).

    However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE
    will ever be raised when attempting to bind two identical host/ports. When
    accept() is called on each socket, the second caller's process will steal
    the port from the first caller, leaving them both in an awkwardly wedged
    state where they'll no longer respond to any signals or graceful kills, and
    must be forcibly killed via OpenProcess()/TerminateProcess().

    The solution on Windows is to use the SO_EXCLUSIVEADDRUSE socket option
    instead of SO_REUSEADDR, which effectively affords the same semantics as
    SO_REUSEADDR on Unix.  Given the propensity of Unix developers in the Open
    Source world compared to Windows ones, this is a common mistake.  A quick
    look over OpenSSL's 0.9.8g source shows that they use SO_REUSEADDR when
    openssl.exe is called with the 's_server' option, for example. See
    http://bugs.python.org/issue2550 for more info.  The following site also
    has a very thorough description about the implications of both REUSEADDR
    and EXCLUSIVEADDRUSE on Windows:
    http://msdn2.microsoft.com/en-us/library/ms740621(VS.85).aspx)

    XXX: although this approach is a vast improvement on previous attempts to
    elicit unused ports, it rests heavily on the assumption that the ephemeral
    port returned to us by the OS won't immediately be dished back out to some
    other process when we close and delete our temporary socket but before our
    calling code has a chance to bind the returned port.  We can deal with this
    issue if/when we come across it.(tsocketRtclose(tfamilytsocktypettempsocktport((s-/usr/lib64/python2.7/test/support/__init__.pyR�s
6
cCs|jtjkr�|jtjkr�ttd�rc|jtjtj�dkrct	d��qcnttd�r�y1|jtjtj
�dkr�t	d��nWq�tk
r�q�Xnttd�r�|jtjtj
d�q�n|j|df�|j�d}|S(s%Bind the socket to a free port and return the port number.  Relies on
    ephemeral ports in order to ensure we are using an unbound port.  This is
    important as many tests may be running simultaneously, especially in a
    buildbot environment.  This method raises an exception if the sock.family
    is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR
    or SO_REUSEPORT set on it.  Tests should *never* set these socket options
    for TCP/IP sockets.  The only case for setting these options is testing
    multicasting via multiple UDP sockets.

    Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e.
    on Windows), it will be set on the socket.  This will prevent anyone else
    from bind()'ing to our host/port for the duration of the test.
    tSO_REUSEADDRisHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets!tSO_REUSEPORTsHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!tSO_EXCLUSIVEADDRUSEi(R�R�tAF_INETRotSOCK_STREAMR�t
getsockoptt
SOL_SOCKETR�RR�Rtt
setsockoptR�tbindtgetsockname(tsockthostR�((s-/usr/lib64/python2.7/test/support/__init__.pyRs$
cCs{tjrwd}zNy3tjtjtj�}|jtdf�tSWntjk
r[nXWd|rs|j	�nXnt
S(s+Check whether IPv6 is enabled on this host.iN(R�thas_ipv6RYtAF_INET6R�RtHOSTv6RVR�R�RX(R((s-/usr/lib64/python2.7/test/support/__init__.pyt_is_ipv6_enabled$s	cs"tj���fd��}|S(s5Skip the test on TLS certificate validation failures.csRy�||�Wn:tk
rM}dt|�krGtjd��n�nXdS(NtCERTIFICATE_VERIFY_FAILEDs.system does not contain necessary certificates(tIOErrorRIRGRH(R{tkwargsR�(tf(s-/usr/lib64/python2.7/test/support/__init__.pytdec7s(R�R�(RR((Rs-/usr/lib64/python2.7/test/support/__init__.pytsystem_must_validate_cert5s	g���ư>cCs#t|t�st|t�rcy8t|�t|�t}t||�|krUdSWqqXn�t|�t|�krt|ttf�rxPttt	|�t	|���D]-}t
||||�}|dkr�|Sq�Wt	|�t	|�kt	|�t	|�kS||k||kS(Ni(RitfloattabsRRoR�RQtrangetminR�R(txtytfuzztitoutcome((s-/usr/lib64/python2.7/test/support/__init__.pyRDs-(,iiitjavasno unicode supportcCs
t|d�S(Nsunicode-escape(tunicode(ts((s-/usr/lib64/python2.7/test/support/__init__.pytumsi�i0iAi�ii�ii*ii�i� s$testtriscosttestfiles@testR�s@test-��slatin-1tgetwindowsversioniis'u"@test-\u5171\u6709\u3055\u308c\u308b"tLatin1sgWARNING: The filename %r CAN be encoded by the filesystem.  Unicode filename tests may not be effectives	{}_{}_tmpshttp://www.pythontest.netccsQt}|dkrEddl}|j�}t}tjj|�}n�tr�t	|t
�r�tjjr�y|jt
j�pd�}Wq�tk
r�|s�tjd��q�q�Xnytj|�t}Wn7tk
r|s��ntjd|tdd�nX|rtj�}nz	|VWd|rL|tj�krLt|�nXdS(s�Return a context manager that creates a temporary directory.

    Arguments:

      path: the directory to create temporarily.  If omitted or None,
        defaults to creating a temporary directory using tempfile.mkdtemp.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, if the path is specified and cannot be
        created, only a warning is issued.

    i����Ntasciis;unable to encode the cwd name with the filesystem encoding.s+tests may fail, unable to create temp dir: Ri(RXRYttempfiletmkdtempRVRuRytrealpathRRiRtsupports_unicode_filenamestencodeRNtgetfilesystemencodingtUnicodeEncodeErrorRGRHtmkdirR�R@R�R�tgetpidR(Rytquiettdir_createdR tpid((s-/usr/lib64/python2.7/test/support/__init__.pyttemp_dir�s6





	ccs{tj�}ytj|�Wn7tk
rV|s9�ntjd|tdd�nXztj�VWdtj|�XdS(sgReturn a context manager that changes the current working directory.

    Arguments:

      path: the directory to use as the temporary current working directory.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, it issues only a warning and keeps the current
        working directory the same.

    s)tests may fail, unable to change CWD to: RiN(RutgetcwdtchdirR�R@R�R�(RyR)t	saved_dir((s-/usr/lib64/python2.7/test/support/__init__.pyt
change_cwds


ttempcwdc	csBtd|d|��'}t|d|��}|VWdQXWdQXdS(s�
    Context manager that temporarily creates and changes the CWD.

    The function temporarily changes the current working directory
    after creating a temporary directory in the current directory with
    name *name*.  If *name* is None, the temporary directory is
    created using tempfile.mkdtemp.

    If *quiet* is False (default) and it is not possible to
    create or change the CWD, an error is raised.  If *quiet* is True,
    only a warning is raised and the original CWD is used.

    RyR)N(R,R0(RJR)t	temp_pathtcwd_dir((s-/usr/lib64/python2.7/test/support/__init__.pyR&stdatacCs�tjj|�r|S|dk	r:tjj||�}ntgtj}x9|D]1}tjj||�}tjj|�rQ|SqQW|S(s�Try to find a file on sys.path and the working directory.  If it is not
    found the argument passed to the function is returned (this does not
    necessarily signal failure; could still be the legitimate path).N(RuRytisabsRYR�t
TEST_HOME_DIRRNtexists(tfiletsubdirRytdntfn((s-/usr/lib64/python2.7/test/support/__init__.pyRAs
cCsJ|j�}|j�g|D]}d|^q}dj|�}d|S(s%Like repr(dict), but in sorted order.s%r: %rs, s{%s}(R]tsortR�(tdictR]tpairt	reprpairst
withcommas((s-/usr/lib64/python2.7/test/support/__init__.pyROs

cCs9ttd�}z|j�SWd|j�tt�XdS(s`
    Create an invalid file descriptor by opening and closing a file and return
    its fd.
    twbN(topenRtfilenoR�R(R8((s-/usr/lib64/python2.7/test/support/__init__.pytmake_bad_fdWs

cCs||jt|��}t|dd�WdQX|j}|dk	rV|j|j|�n|dk	rx|j|j|�ndS(Ns
<test string>texec(tassertRaisesRegexptSyntaxErrortcompilet	exceptionRYtassertEqualtlinenotoffset(ttestcaset	statementterrtextRKRLtcmR|((s-/usr/lib64/python2.7/test/support/__init__.pyRcs	c
sSddl}ddl}|j|�djd�d}tjjt|�}�fd�}tjj|�r�||�}|dk	r�|St	|�nt
d�t�d|IJ|j|dd�}zNt
|d	��9}|j�}	x#|	r
|j|	�|j�}	q�WWdQXWd|j�X||�}|dk	r?|Std
|��dS(Ni����it/csGt|�}�dkr|S�|�r9|jd�|S|j�dS(Ni(RBRYtseekR�(R;R(tcheck(s-/usr/lib64/python2.7/test/support/__init__.pytcheck_valid_filess
turlfetchs	fetching %s ...R�iRAsinvalid resource "%s"(turlparseturllib2R�RuRyR�t
TEST_DATA_DIRR7RYRRR	turlopenRBtreadtwriteR�R(
turlRSRVRWR�R;RTRtoutR((RSs-/usr/lib64/python2.7/test/support/__init__.pyRls. 	

	
tWarningsRecordercBs8eZdZd�Zd�Zed��Zd�ZRS(syConvenience wrapper for the warnings list returned on
       entry to the warnings.catch_warnings() context manager.
    cCs||_d|_dS(Ni(t	_warningst_last(tselft
warnings_list((s-/usr/lib64/python2.7/test/support/__init__.pyt__init__�s	cCs\t|j�|jkr,t|jd|�S|tjjkrBdStd||f��dS(Ni����s%r has no attribute %r(	R�R_R`RgR@tWarningMessaget_WARNING_DETAILSRYRh(Ratattr((s-/usr/lib64/python2.7/test/support/__init__.pyt__getattr__�s
cCs|j|jS(N(R_R`(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR@�scCst|j�|_dS(N(R�R_R`(Ra((s-/usr/lib64/python2.7/test/support/__init__.pytreset�s(R<R=R>RcRgtpropertyR@Rh(((s-/usr/lib64/python2.7/test/support/__init__.pyR^�s
		c
csptjd�}|jjd�}|r4|j�ntjdt��&}tjdj	d�t
|�VWdQXg|D]}|j^qu}g}x�|D]�\}}	t}
x[|D]R}t
|�}tj||tj�r�t|j|	�r�t}
|j|�q�q�W|
r�|r�|j||	jf�q�q�W|rOtd|d��n|rltd	|d��ndS(
s�Catch the warnings, then check if all the expected
    warnings have been raised and re-raise unexpected warnings.
    If 'quiet' is True, only re-raise the unexpected warnings.
    it__warningregistry__trecordR@talwaysNsunhandled warning %ris)filter (%r, %s) did not catch any warning(RNt	_getframet	f_globalstgettclearR@RARVROtsimplefilterR^tmessageRXRItretmatchtIt
issubclassRntremoveR\R<tAssertionError(
tfiltersR)tframetregistrytwtwarningtreraisetmissingRLtcattseenR�Rr((s-/usr/lib64/python2.7/test/support/__init__.pyt_filterwarnings�s0
cOsI|jd�}|s<dtff}|dkr<t}q<nt||�S(s�Context manager to silence warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default True without argument,
         default False if some filters are defined)

    Without argument, it defaults to:
        check_warnings(("", Warning), quiet=True)
    R)R�N(RotWarningRYRVR�(RyR
R)((s-/usr/lib64/python2.7/test/support/__init__.pyR�scOs@tjr$|s*dtff}q*nd}t||jd��S(sjContext manager to silence py3k warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default False)

    Without argument, it defaults to:
        check_py3k_warnings(("", DeprecationWarning), quiet=False)
    R�R)((RNtpy3kwarningRCR�Ro(RyR
((s-/usr/lib64/python2.7/test/support/__init__.pyR �s
	cBs)eZdZd�Zd�Zd�ZRS(s,Context manager to force import to return a new module reference.

    This is useful for testing module-level behaviours, such as
    the emission of a DeprecationWarning on import.

    Use like this:

        with CleanImport("foo"):
            importlib.import_module("foo") # new reference
    cGsotjj�|_xV|D]N}|tjkrtj|}|j|krZtj|j=ntj|=qqWdS(N(RNROtcopytoriginal_modulesR<(Ratmodule_namestmodule_nameRe((s-/usr/lib64/python2.7/test/support/__init__.pyRcs

cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyt	__enter__scGstjj|j�dS(N(RNROR�R�(Rat
ignore_exc((s-/usr/lib64/python2.7/test/support/__init__.pyt__exit__s(R<R=R>RcR�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR!s
	
	cBs_eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
s_Class to help protect the environment variable properly.  Can be used as
    a context manager.cCstj|_i|_dS(N(Rutenviront_environt_changed(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyRc(scCs|j|S(N(R�(Ratenvvar((s-/usr/lib64/python2.7/test/support/__init__.pyt__getitem__,scCs<||jkr+|jj|�|j|<n||j|<dS(N(R�R�Ro(RaR�tvalue((s-/usr/lib64/python2.7/test/support/__init__.pyt__setitem__/scCsK||jkr+|jj|�|j|<n||jkrG|j|=ndS(N(R�R�Ro(RaR�((s-/usr/lib64/python2.7/test/support/__init__.pyt__delitem__5scCs
|jj�S(N(R�tkeys(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR�<scCs|||<dS(N((RaR�R�((s-/usr/lib64/python2.7/test/support/__init__.pytset?scCs||=dS(N((RaR�((s-/usr/lib64/python2.7/test/support/__init__.pytunsetBscCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR�EscGshxU|jj�D]D\}}|dkrG||jkrT|j|=qTq||j|<qW|jt_dS(N(R�R]RYR�RuR�(RaR�tktv((s-/usr/lib64/python2.7/test/support/__init__.pyR�Hs(R<R=R>RcR�R�R�R�R�R�R�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR"#s								t
DirsOnSysPathcBs)eZdZd�Zd�Zd�ZRS(s�Context manager to temporarily add directories to sys.path.

    This makes a copy of sys.path, appends any directories given
    as positional arguments, then reverts sys.path to the copied
    settings when the context ends.

    Note that *all* sys.path modifications in the body of the
    context manager, including replacement of the object,
    will be reverted at the end of the block.
    cGs-tj|_tj|_tjj|�dS(N(RNRytoriginal_valuetoriginal_objecttextend(Ratpaths((s-/usr/lib64/python2.7/test/support/__init__.pyRc^s
cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR�cscGs|jt_|jtj(dS(N(R�RNRyR�(RaR�((s-/usr/lib64/python2.7/test/support/__init__.pyR�fs(R<R=R>RcR�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR�Rs
		cBs2eZdZd�Zd�Zdddd�ZRS(s�Raise ResourceDenied if an exception is raised while the context manager
    is in effect that matches the specified exception and attributes.cKs||_||_dS(N(R�tattrs(RaR�R
((s-/usr/lib64/python2.7/test/support/__init__.pyRcps	cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR�tscCs}|dk	ryt|j|�ryxX|jj�D]8\}}t||�sMPnt||�|kr.Pq.q.Wtd��ndS(s�If type_ is a subclass of self.exc and value has attributes matching
        self.attrs, raise ResourceDenied.  Otherwise let the exception
        propagate (if any).s%an optional resource is not availableN(RYRvR�R�t	iteritemsR�RgR(Rattype_R�t	tracebackRft
attr_value((s-/usr/lib64/python2.7/test/support/__init__.pyR�wsN(R<R=R>RcR�RYR�(((s-/usr/lib64/python2.7/test/support/__init__.pyR%ks		c#s�dddd d!d"g}d#d$d%d&d'g}td|��|�g��s�g|D]\}}tt||�^qV�g|D]\}}tt||�^q��n���fd�}tj�}z�y%|dk	r�tj|�ndVWn�tk
r�}	xxtr}|	j	}
t
|
�dkrGt|
dt�rG|
d}	qt
|
�dkryt|
dt�ry|
d}	qPqW||	��nXWdtj|�XdS((s�Return a context manager that raises ResourceDenied when various issues
    with the Internet connection manifest themselves as exceptions.tECONNREFUSEDiot
ECONNRESETihtEHOSTUNREACHiqtENETUNREACHiet	ETIMEDOUTint
EADDRNOTAVAILict	EAI_AGAINi����tEAI_FAILi����t
EAI_NONAMEi����t
EAI_NODATAi����t
WSANO_DATAi�*sResource '%s' is not availablecst|dd�}t|tj�sNt|tj�rB|�ksN|�kr{tsrtjj	�j
dd�n��ndS(NR�is
(RgRYRiR�R�tgaierrorRRNtstderrR[R{(R|tn(tcaptured_errnostdeniedt
gai_errnos(s-/usr/lib64/python2.7/test/support/__init__.pytfilter_error�sNiii(R�io(R�ih(R�iq(R�ie(R�in(R�ic(R�i����(R�i����(R�i����(R�i����(R�i�*(RRgR�R�tgetdefaulttimeoutRYtsetdefaulttimeoutR	RVR{R�Ri(t
resource_nameR�terrnostdefault_errnostdefault_gai_errnosRJtnumR�told_timeoutR|ta((R�R�R�s-/usr/lib64/python2.7/test/support/__init__.pyR&�sJ		(+				%
%

ccs[ddl}tt|�}tt||j��ztt|�VWdtt||�XdS(s�Return a context manager used by captured_stdout and captured_stdin
    that temporarily replaces the sys stream *stream_name* with a StringIO.i����N(tStringIORgRNtsetattr(tstream_nameR�torig_stdout((s-/usr/lib64/python2.7/test/support/__init__.pyR#�scCs
td�S(s�Capture the output of sys.stdout:

       with captured_stdout() as s:
           print "hello"
       self.assertEqual(s.getvalue(), "hello")
    Rs(R#(((s-/usr/lib64/python2.7/test/support/__init__.pyR$�scCs
td�S(NR�(R#(((s-/usr/lib64/python2.7/test/support/__init__.pytcaptured_stderr�scCs
td�S(Ntstdin(R#(((s-/usr/lib64/python2.7/test/support/__init__.pytcaptured_stdin�scCs8tj�tr tjd�ntj�tj�dS(s�Force as many objects as possible to be collected.

    In non-CPython implementations of Python, this is needed because timely
    deallocation is not guaranteed by the garbage collector.  (Even in CPython
    this can be the case in case of reference cycles.)  This means that __del__
    methods may be called later than expected and weakrefs may remain alive for
    longer than expected.  This function tries its best to force all garbage
    objects to disappear.
    g�������?N(tgctcollectRR�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyt
gc_collect�s



t2PtgettotalrefcounttPcCstjt|d�S(Nt0P(tstructtcalcsizet_header(tfmt((s-/usr/lib64/python2.7/test/support/__init__.pytcalcobjsize�scCstjt|d�S(NR�(R�R�t_vheader(R�((s-/usr/lib64/python2.7/test/support/__init__.pytcalcvobjsize�sii	cCs�ddl}tj|�}t|�tkr:|jt@s_t|�tkrot|�jt@ro||j7}ndt|�||f}|j|||�dS(Ni����s&wrong size for %s: got %d, expected %d(	t	_testcapiRNt	getsizeofRot	__flags__t_TPFLAGS_HEAPTYPEt_TPFLAGS_HAVE_GCtSIZEOF_PYGC_HEADRJ(ttesttotsizeR�R�RL((s-/usr/lib64/python2.7/test/support/__init__.pytcheck_sizeofs%cs��fd�}|S(Ncs1���fd�}�j|_�j|_|S(Ncs�y.ddl}t|��}|j|�}Wn$tk
rD�nAd}}n1Xx-�D]%}y|j||�PWq\q\Xq\Wz�||�SWd|r�|r�|j||�nXdS(Ni����(tlocaleRgt	setlocaleRhRY(R{tkwdsR�tcategorytorig_localetloc(tcatstrRztlocales(s-/usr/lib64/python2.7/test/support/__init__.pytinners$

(t	func_nameR>(RzR�(R�R�(Rzs-/usr/lib64/python2.7/test/support/__init__.pyR�s((R�R�R�((R�R�s-/usr/lib64/python2.7/test/support/__init__.pyR'scs�fd�}|S(Ncs.��fd�}�j|_�j|_|S(Ncs�y
tj}Wn tk
r/tjd��nXdtjkrOtjd}nd}�tjd<|�z�||�SWd|dkr�tjd=n
|tjd<tj�XdS(Nstzset requiredtTZ(R�ttzsetRhRGRHRuR�RY(R{R�R�torig_tz(Rzttz(s-/usr/lib64/python2.7/test/support/__init__.pyR�;s




(R<R>(RzR�(R�(Rzs-/usr/lib64/python2.7/test/support/__init__.pyR�:s((R�R�((R�s-/usr/lib64/python2.7/test/support/__init__.pyR:9scCs�idd6td6td6dtd6}tjd|tjtjB�}|dkrgtd|f��ntt	|j
d��||j
d	�j��}|a|t
kr�t
}n|tdkr�td
|f��n|adS(NiR�tmtgtts(\d+(\.\d+)?) (K|M|G|T)b?$sInvalid memory limit %riis$Memory limit %r too low to be useful(t_1Mt_1GRsRtt
IGNORECASEtVERBOSERYR�R�Rtgrouptlowertreal_max_memusetMAX_Py_ssize_tt_2GR(tlimittsizesR�tmemlimit((s-/usr/lib64/python2.7/test/support/__init__.pyR(bs 2	ics���fd�}|S(sQDecorator for bigmem tests.

    'minsize' is the minimum useful size for the test (in arbitrary,
    test-interpreted units.) 'memuse' is the number of 'bytes per size' for
    the test, or a good estimate of it. 'overhead' specifies fixed overhead,
    independent of the testsize, and defaults to 5Mb.

    The decorator tries to guess a good value for 'size' and passes it to
    the decorated test function. If minsize * memuse is more than the
    allowed memory use (as defined by max_memuse), the test is skipped.
    Otherwise, minsize is adjusted upward to use up to max_memuse.
    cs7����fd�}�|_�|_�|_|S(Ncs�ts.d}|j|��dtk�n^tt���}|�krutrqtjjd�jf�ndSt	|dt��}�||�S(Niis)Skipping %s because of memory constraint
i2(
RtassertFalseR�R�RRNR�R[R<tmax(Ratmaxsize(Rtmemusetminsizetoverhead(s-/usr/lib64/python2.7/test/support/__init__.pyR��s"(R�R�R�(RR�(R�R�R�(Rs-/usr/lib64/python2.7/test/support/__init__.pyR��s
			((R�R�R�R�((R�R�R�s-/usr/lib64/python2.7/test/support/__init__.pyR)ws
cs����fd�}|S(Ncs7����fd�}�|_�|_�|_|S(Ncsftsd}n�}ts"�rYt|�krYtrUtjjd�jf�ndS�||�S(Nis)Skipping %s because of memory constraint
(R�RRNR�R[R<(RaR�(tdry_runRR�R�(s-/usr/lib64/python2.7/test/support/__init__.pyR��s	
(R�R�R�(RR�(RR�R�R�(Rs-/usr/lib64/python2.7/test/support/__init__.pyR��s
			((R�R�R�RR�((RR�R�R�s-/usr/lib64/python2.7/test/support/__init__.pytprecisionbigmemtest�scs�fd�}|S(s0Decorator for tests that fill the address space.cs@ttkr2tr<tjjd�jf�q<n
�|�SdS(Ns)Skipping %s because of memory constraint
(RR�RRNR�R[R<(Ra(R(s-/usr/lib64/python2.7/test/support/__init__.pyR��s
((RR�((Rs-/usr/lib64/python2.7/test/support/__init__.pyR*�scBseZd�ZRS(cCstj�}||�|S(N(RGt
TestResult(RaR�R�((s-/usr/lib64/python2.7/test/support/__init__.pytrun�s
(R<R=R(((s-/usr/lib64/python2.7/test/support/__init__.pyR+�scCs|S(N((Rp((s-/usr/lib64/python2.7/test/support/__init__.pyt_id�scCsP|dkr&t�r&tjtj�St|�r6tStjdj|��SdS(NR�sresource {0!r} is not enabled(R�RGtskipR�RRR�(R�((s-/usr/lib64/python2.7/test/support/__init__.pytrequires_resource�s
cCstdt�|�S(s9
    Decorator for tests only applicable on CPython.
    tcpython(timpl_detailRV(R�((s-/usr/lib64/python2.7/test/support/__init__.pyR2�scKs}t|�rtS|dkrpt|�\}}|r=d}nd}t|j��}|jdj|��}ntj	|�S(Ns*implementation detail not available on {0}s%implementation detail specific to {0}s or (
R3RRYt
_parse_guardstsortedR�R�R�RGR(RLtguardst
guardnamestdefault((s-/usr/lib64/python2.7/test/support/__init__.pyR�s	cCsW|sitd6tfS|j�d}|j�|gt|�ksLt�||fS(NRi(RVRXtvaluesR�Rx(Rtis_true((s-/usr/lib64/python2.7/test/support/__init__.pyR	�s
%cKs.t|�\}}|jtj�j�|�S(s5This function returns True or False depending on the host platform.
       Examples:
          if check_impl_detail():               # only on CPython (default)
          if check_impl_detail(jython=True):    # only on Jython
          if check_impl_detail(cpython=False):  # everywhere except on CPython
    (R	RoR�tpython_implementationR�(RR
((s-/usr/lib64/python2.7/test/support/__init__.pyR3�scCsrg}x\|jD]Q}t|tj�rEt||�|j|�q||�r|j|�qqW||_dS(s>Recursively filter test cases in a suite based on a predicate.N(t_testsRiRGt	TestSuitet
_filter_suiteR\(tsuitetpredtnewtestsR�((s-/usr/lib64/python2.7/test/support/__init__.pyR�s
cCs�tr'tjtjdddt�}n	t�}|j|�}|jr\|j	r\t
�n|j�s�t|j
�dkr�|jr�|j
dd}nLt|j�dkr�|j
r�|jdd}nd}ts�|d7}nt|��ndS(	s2Run tests from a unittest.TestSuite-derived class.t	verbosityitfailfastiismultiple errors occurreds!; run in verbose mode for detailsN(RRGtTextTestRunnerRNRsRR+RttestsRuntskippedRt
wasSuccessfulR�terrorstfailuresR(RtrunnerR�R|((s-/usr/lib64/python2.7/test/support/__init__.pyt
_run_suites 		
cCs$tdkrtSt|j��SdS(N(t_match_test_funcRYRVtid(R�((s-/usr/lib64/python2.7/test/support/__init__.pyt
match_test#scCsd|kotjd|�S(NRMs[?*\[\]](Rstsearch(tpattern((s-/usr/lib64/python2.7/test/support/__init__.pyt_is_full_match_test+scs�|tkrdS|s%d}d}nittt|��rLt|�j}nBdjttj	|��}t
j|�j��fd�}|}t
|�a|adS(Nt|cs0�|�rtStt�|jd���SdS(NRM(RVtanyR�R�(ttest_id(tregex_match(s-/usr/lib64/python2.7/test/support/__init__.pytmatch_test_regexJs((t_match_test_patternsRYtallR�R&R�t__contains__R�tfnmatcht	translateRsRHRtR�R!(tpatternsRztregexR+((R*s-/usr/lib64/python2.7/test/support/__init__.pytset_match_tests5s	cGs�tjtjf}tj�}x�|D]�}t|t�rx|tjkri|jtjtj|��q�t	d��q%t||�r�|j|�q%|jtj
|��q%Wt|t�t
|�dS(s1Run tests from unittest.TestCase-derived classes.s)str arguments must be keys in sys.modulesN(RGRtTestCaseRiRIRNROtaddTestt
findTestCasesR�t	makeSuiteRR#R (tclassestvalid_typesRtcls((s-/usr/lib64/python2.7/test/support/__init__.pyR,]s
 
Rtwin32tWITH_DOC_STRINGSstest requires docstringscCs�ddl}|dkr!t}nd}tj}t�t_z>|j|d|�\}}|rytd||f��nWd|t_Xtr�d|j|fGHn||fS(s
Run doctest on the given module.  Return (#failures, #tests).

    If optional argument verbosity is not specified (or is None), pass
    test.support's belief about verbosity on to doctest.  Else doctest's
    usual behavior is used (it searches sys.argv for -v).
    i����NRs%d of %d doctests faileds,doctest (%s) ... %d tests with zero failures(	tdoctestRYRRNRsR	ttestmodRR<(ReRR=tsave_stdoutRR�((s-/usr/lib64/python2.7/test/support/__init__.pyR-|s		
cCstrtj�fSdSdS(Ni(i(tthreadt_count(((s-/usr/lib64/python2.7/test/support/__init__.pyR.�s
cCsTts
dSd}x=t|�D]/}tj�}||kr?Pntjd�qWdS(Ni
g�������?(R@RRAR�R�(t
nb_threadst
_MAX_COUNTtcountR�((s-/usr/lib64/python2.7/test/support/__init__.pyR/�scs,ts
�Stj���fd��}|S(s�Use this function when threads are being used.  This will
    ensure that the threads are cleaned up even when the test fails.
    If threading is unavailable this function does nothing.
    cs)t�}z�|�SWdt|�XdS(N(R.R/(R{tkey(Rz(s-/usr/lib64/python2.7/test/support/__init__.pyR��s	(R@R�R�(RzR�((Rzs-/usr/lib64/python2.7/test/support/__init__.pyR0�sgN@ccs�tj�}z	dVWdtj�}||}x�tr�tj�}||krSPntj�|kr�tj�|}d|||||f}t|��ntjd�t�q1WXdS(sE
    bpo-31234: Context manager to wait until all threads created in the with
    statement exit.

    Use thread.count() to check if threads exited. Indirectly, wait until
    threads exit the internal t_bootstrap() C function of the thread module.

    threading_setup() and threading_cleanup() are designed to emit a warning
    if a test leaves running threads in the background. This context manager
    is designed to cleanup threads started by the thread.start_new_thread()
    which doesn't allow to wait for thread exit, whereas thread.Thread has a
    join() method.
    NsYwait_threads() failed to cleanup %s threads after %.1f seconds (count: %s, old count: %s)g{�G�z�?(R@RAR�RVRxR�R�(R�t	old_countt
start_timetdeadlineRDtdtRL((s-/usr/lib64/python2.7/test/support/__init__.pytwait_threads_exit�s 	
	
cCscttd�r_d}xGtr[y/tj|tj�\}}|dkrLPnWqPqXqWndS(s�Use this function at the end of test_main() whenever sub-processes
    are started.  This will help ensure that no extra children (zombies)
    stick around to hog resources and create problems when looking
    for refleaks.
    twaitpidi����iN(R�RuRVRKtWNOHANG(tany_processR+tstatus((s-/usr/lib64/python2.7/test/support/__init__.pyR7�s		c	cs�t|�}g}zfy,x%|D]}|j�|j|�qWWn.trkdt|�t|�fGHn�nXdVWd|r�|�ntj�}}x�tdd�D]�}|d7}x.|D]&}|jt|tj�d��q�Wg|D]}|j	�r�|^q�}|sPntr�dt|�|fGHq�q�WXg|D]}|j	�rE|^qE}|r�t
dt|���ndS(Ns/Can't start %d threads, only %d threads startediii<g{�G�z�?s7Unable to join %d threads during a period of %d minutessUnable to join %d threads(RQtstartR\RR�R�RR�R�tisAliveRx(tthreadstunlocktstartedR�tendtimet	starttimeR�((s-/usr/lib64/python2.7/test/support/__init__.pyR1s:

	


$%%ccs�t||�rNt||�}t|||�z	|VWdt|||�Xn<t|||�z	dVWdt||�r�t||�nXdS(s�Temporary swap out an attribute with a new object.

    Usage:
        with swap_attr(obj, "attr", 5):
            ...

        This will set obj.attr to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `attr` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.

        The old value (or None if it doesn't exist) will be assigned to the
        target of the "as" clause, if there is one.
    N(R�RgR�tdelattr(RpRftnew_valtreal_val((s-/usr/lib64/python2.7/test/support/__init__.pyt	swap_attr)s		ccsk||kr:||}|||<z	|VWd|||<Xn-|||<z	dVWd||krf||=nXdS(s�Temporary swap out an item with a new object.

    Usage:
        with swap_item(obj, "item", 5):
            ...

        This will set obj["item"] to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `item` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.

        The old value (or None if it doesn't exist) will be assigned to the
        target of the "as" clause, if there is one.
    N((RptitemRWRX((s-/usr/lib64/python2.7/test/support/__init__.pyt	swap_itemHs

	
	cCs\y|j�SWnGtk
rWydjd�|D��SWqXtk
rSt|�SXnXdS(sZEmulate the py3k bytes() constructor.

    NOTE: This is only a best effort function.
    R�css|]}t|�VqdS(N(tchr(t.0R((s-/usr/lib64/python2.7/test/support/__init__.pys	<genexpr>rsN(ttobytesRhR�t	TypeErrortbytes(tb((s-/usr/lib64/python2.7/test/support/__init__.pyR5gs

t	getcountss-types are immortal if COUNT_ALLOCS is definedcCsddl}|j�S(sZReturn a list of command-line arguments reproducing the current
    settings in sys.flags.i����N(t
subprocesst_args_from_interpreter_flags(Rc((s-/usr/lib64/python2.7/test/support/__init__.pytargs_from_interpreter_flagsyscCstjdd|�j�}|S(s�Strip the stderr of a Python process from potential debug output
    emitted by the interpreter.

    This will typically be run on the result of the communicate() method
    of a subprocess.Popen object.
    s\[\d+ refs\]\r?\n?$R�(Rstsubtstrip(R�((s-/usr/lib64/python2.7/test/support/__init__.pyR8scsid|f��fd��Y}tg�|||���|jtt��t�|j�d�dS(NtAcseZ��fd�ZRS(cs0t�d<yt��Wntk
r+nXdS(Ni(RVtnextt
StopIteration(Ra(tdonetit(s-/usr/lib64/python2.7/test/support/__init__.pyt__del__�s


(R<R=Rm((RkRl(s-/usr/lib64/python2.7/test/support/__init__.pyRh�si(RXtassertRaisesRjRiR�t
assertTrue(R�titerR:R{Rh((RkRls-/usr/lib64/python2.7/test/support/__init__.pytcheck_free_after_iterating�s	ccs:tj�}tj�z	dVWd|r5tj�nXdS(N(R�t	isenabledtdisabletenable(thave_gc((s-/usr/lib64/python2.7/test/support/__init__.pyt
disable_gc�s
	cCsTtjd�pd}d}x,|j�D]}|jd�r(|}q(q(W|dkS(s,Find if Python was built with optimizations.t	PY_CFLAGSR�s-Os-O0s-Og(R�s-O0s-Og(t	sysconfigtget_config_varR�RR(tcflagst	final_opttopt((s-/usr/lib64/python2.7/test/support/__init__.pytpython_is_optimized�s
cBs,eZdZdZdZd�Zd�ZRS(s�Try to prevent a crash report from popping up.

    On Windows, don't display the Windows Error Reporting dialog.  On UNIX,
    disable the creation of coredump file.
    cCstjjd�r�ddl}|jj|_d}|jj|�|_|jj|j|B�yddl	}|j
Wnttfk
r�qXi|_
x|j|j|jgD]C}|j
||j�}|j||j�}||f|j
|<q�Wnyddl}Wntk
r%d}nX|dk	r�y9|j|j�|_|j|jd|jdf�Wq�ttfk
r�q�Xntjdkrddl}dd	d
dg}	|j|	d|jd
|j�}
|
j�d}|j�dkrtj j!d�tj j"�qn|S(s�On Windows, disable Windows Error Reporting dialogs using
        SetErrorMode.

        On UNIX, try to save the previous core file size limit, then set
        soft limit to 0.
        R~i����NiiiR�s/usr/bin/defaultsRZscom.apple.CrashReportert
DialogTypeRsR�t	developers:this test triggers the Crash Reporter, that is intentional(#RNR�RRR�R�tkernel32t_k32tSetErrorModet	old_valueR�tCrtSetReportModeRhRFt	old_modestCRT_WARNt	CRT_ERRORt
CRT_ASSERTtCRTDBG_MODE_FILEtCrtSetReportFiletCRTDBG_FILE_STDERRR�RYt	getrlimittRLIMIT_COREt	setrlimitR�R�RctPopentPIPEtcommunicateRgRsR[tflush(RaR�tSEM_NOGPFAULTERRORBOXR�treport_typetold_modetold_fileR�RctcmdtprocRs((s-/usr/lib64/python2.7/test/support/__init__.pyR��sV				

	cGs�|jdkrdStjjd�r�|jj|j�|jr�ddl}xF|jj	�D]2\}\}}|j
||�|j||�q]Wq�n@ddl}y|j
|j|j�Wnttfk
r�nXdS(sARestore Windows ErrorMode or core file behavior to initial value.NR~i����(R�RYRNR�RRR�R�R�R�R]R�R�R�R�R�R�R�(RaR�R�R�R�R�R�((s-/usr/lib64/python2.7/test/support/__init__.pyR�s	"N(R<R=R>RYR�R�R�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR;�s
	GcCs*ddl}t��|j�WdQXdS(s�Deliberate crash of Python.

    Python can be killed by a segmentation fault (SIGSEGV), a bus error
    (SIGBUS), or a different error depending on the platform.

    Use SuppressCrashReport() to prevent a crash report from popping up.
    i����N(R�R;t
_read_null(R�((s-/usr/lib64/python2.7/test/support/__init__.pyt
_crash_pythons	
c
Cs�tjjd�rdy!tjd�}t|�dSWqdtk
r`}|jtjkra�qaqdXnd}t	td�r�ytj
d�}Wq�tk
r�q�Xnd
}tjdkr+yd	d
l}|j
Wnttfk
r�q+Xi}x9|j|j|jfD]}|j
|d�||<qWnzyd}xlt|�D]^}ytj|�}Wn+tk
r�}	|	jtjkr��q�qAXtj|�|d7}qAWWd
|d
k	r�x7|j|j|jfD]}|j
|||�q�WnX|S(
s/Count the number of open file descriptors.
    tlinuxtfreebsds
/proc/self/fdiitsysconftSC_OPEN_MAXR;i����Ni(R�R�(RNR�RRRuR�R�R�R�R�R�R�RYtmsvcrtR�RhRFR�R�R�RtduptEBADFR�(
tnamesR�tMAXFDR�R�R�RDtfdtfd2R�((s-/usr/lib64/python2.7/test/support/__init__.pytfd_count#sR

	

	tSaveSignalscBs)eZdZd�Zd�Zd�ZRS(s�
    Save an restore signal handlers.

    This class is only able to save/restore signal handlers registered
    by the Python signal module: see bpo-13285 for "external" signal
    handlers.
    cCs�ddl}||_ttd|j��|_xHdD]@}yt||�}Wntk
rfq7nX|jj|�q7Wi|_dS(Ni����itSIGKILLtSIGSTOP(R�R�(	tsignalRQRtNSIGtsignalsRgRhRwthandlers(RaR�tsignametsignum((s-/usr/lib64/python2.7/test/support/__init__.pyRchs	

cCsIxB|jD]7}|jj|�}|dkr4q
n||j|<q
WdS(N(R�R�t	getsignalRYR�(RaR�thandler((s-/usr/lib64/python2.7/test/support/__init__.pytsaveus
cCs7x0|jj�D]\}}|jj||�qWdS(N(R�R]R�(RaR�R�((s-/usr/lib64/python2.7/test/support/__init__.pytrestore�s(R<R=R>RcR�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR�_s	
	((ii@i@i@ii(i@ii(((((�R>R<RFt
contextlibR�R/R�R�R�RwRNRuR�R�R@RGREtUserDictRsR�R�RxRjR@RYt__all__t
SHORT_TIMEOUTR�RRRRHRtcontextmanagerRVRDRXRRUR[R6R4RRRR�RRrRR	R
R}RRR�R�R�R�RR�RR
R�RRRRRR�R�RRRR9R
RRt
PIPE_MAX_SIZEt
SOCK_MAX_SIZERRRt	NameErrort
skipUnlesstrequires_unicodeRtFS_NONASCIItunichrt	characterR$R%tdecodetUnicodeErrorRJRRitTESTFN_UNICODEtTESTFN_ENCODINGR�RtTESTFN_UNENCODABLEtevalR&R�R(t
TEST_HTTP_URLR-RR,R0RRyR�tabspatht__file__tTEST_SUPPORT_DIRR6R�RXRRRDRRtobjectR^R�RR R!t	DictMixinR"R�R%R&R#R$R�R�R�R�R�R�R�R�R�R�R'R:R�R�R�t_4GR�R�R(R)RR*R+RRR2RR	R3RR R!R,R#R&R3R,RytHAVE_DOCSTRINGStrequires_docstringsR-tenvironment_alteredR.R/R0RJR7R1RYR[R5tskipIftrequires_type_collectingReR8RqRvR}R;R�R�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyt<module>s�

								
	
	
&					
!										J			<$			
	


												

				
	.			*' /D					

				$	"


		'				
	
					
	(			&
			#	 					
e		<script_helper.pyc000064400000000272150532427410010130 0ustar00�
zfc@sddlTdS(i����(t*N(ttest.support.script_helper(((s*/usr/lib64/python2.7/test/script_helper.pyt<module>tscript_helper.pyo000064400000000272150532427410010144 0ustar00�
zfc@sddlTdS(i����(t*N(ttest.support.script_helper(((s*/usr/lib64/python2.7/test/script_helper.pyt<module>ttest_support.pyo000064400000000401150532427410010046 0ustar00�
zfc@s,ddlZddlZejejd<dS(i����Nstest.test_support(tsysttest.supportttesttsupporttmodules(((s)/usr/lib64/python2.7/test/test_support.pyt<module>s__init__.pyo000064400000000174150532427410007041 0ustar00�
zfc@sdS(N((((s%/usr/lib64/python2.7/test/__init__.pyt<module>t__init__.py000064400000000057150532427410006662 0ustar00# Dummy file to make this directory a package.
__init__.pyc000064400000000174150532427410007025 0ustar00�
zfc@sdS(N((((s%/usr/lib64/python2.7/test/__init__.pyt<module>ttest_support.py000064400000000117150532427410007673 0ustar00import sys
import test.support
sys.modules['test.test_support'] = test.support
support/testresult.py000064400000015015150532443020011050 0ustar00'''Test runner and result class for the regression test suite.

'''

import functools
import io
import sys
import time
import traceback
import unittest

import xml.etree.ElementTree as ET

from datetime import datetime

class RegressionTestResult(unittest.TextTestResult):
    separator1 = '=' * 70 + '\n'
    separator2 = '-' * 70 + '\n'

    def __init__(self, stream, descriptions, verbosity):
        super().__init__(stream=stream, descriptions=descriptions, verbosity=0)
        self.buffer = True
        self.__suite = ET.Element('testsuite')
        self.__suite.set('start', datetime.utcnow().isoformat(' '))

        self.__e = None
        self.__start_time = None
        self.__results = []
        self.__verbose = bool(verbosity)

    @classmethod
    def __getId(cls, test):
        try:
            test_id = test.id
        except AttributeError:
            return str(test)
        try:
            return test_id()
        except TypeError:
            return str(test_id)
        return repr(test)

    def startTest(self, test):
        super().startTest(test)
        self.__e = e = ET.SubElement(self.__suite, 'testcase')
        self.__start_time = time.perf_counter()
        if self.__verbose:
            self.stream.write(f'{self.getDescription(test)} ... ')
            self.stream.flush()

    def _add_result(self, test, capture=False, **args):
        e = self.__e
        self.__e = None
        if e is None:
            return
        e.set('name', args.pop('name', self.__getId(test)))
        e.set('status', args.pop('status', 'run'))
        e.set('result', args.pop('result', 'completed'))
        if self.__start_time:
            e.set('time', f'{time.perf_counter() - self.__start_time:0.6f}')

        if capture:
            if self._stdout_buffer is not None:
                stdout = self._stdout_buffer.getvalue().rstrip()
                ET.SubElement(e, 'system-out').text = stdout
            if self._stderr_buffer is not None:
                stderr = self._stderr_buffer.getvalue().rstrip()
                ET.SubElement(e, 'system-err').text = stderr

        for k, v in args.items():
            if not k or not v:
                continue
            e2 = ET.SubElement(e, k)
            if hasattr(v, 'items'):
                for k2, v2 in v.items():
                    if k2:
                        e2.set(k2, str(v2))
                    else:
                        e2.text = str(v2)
            else:
                e2.text = str(v)

    def __write(self, c, word):
        if self.__verbose:
            self.stream.write(f'{word}\n')

    @classmethod
    def __makeErrorDict(cls, err_type, err_value, err_tb):
        if isinstance(err_type, type):
            if err_type.__module__ == 'builtins':
                typename = err_type.__name__
            else:
                typename = f'{err_type.__module__}.{err_type.__name__}'
        else:
            typename = repr(err_type)

        msg = traceback.format_exception(err_type, err_value, None)
        tb = traceback.format_exception(err_type, err_value, err_tb)

        return {
            'type': typename,
            'message': ''.join(msg),
            '': ''.join(tb),
        }

    def addError(self, test, err):
        self._add_result(test, True, error=self.__makeErrorDict(*err))
        super().addError(test, err)
        self.__write('E', 'ERROR')

    def addExpectedFailure(self, test, err):
        self._add_result(test, True, output=self.__makeErrorDict(*err))
        super().addExpectedFailure(test, err)
        self.__write('x', 'expected failure')

    def addFailure(self, test, err):
        self._add_result(test, True, failure=self.__makeErrorDict(*err))
        super().addFailure(test, err)
        self.__write('F', 'FAIL')

    def addSkip(self, test, reason):
        self._add_result(test, skipped=reason)
        super().addSkip(test, reason)
        self.__write('S', f'skipped {reason!r}')

    def addSuccess(self, test):
        self._add_result(test)
        super().addSuccess(test)
        self.__write('.', 'ok')

    def addUnexpectedSuccess(self, test):
        self._add_result(test, outcome='UNEXPECTED_SUCCESS')
        super().addUnexpectedSuccess(test)
        self.__write('u', 'unexpected success')

    def printErrors(self):
        if self.__verbose:
            self.stream.write('\n')
        self.printErrorList('ERROR', self.errors)
        self.printErrorList('FAIL', self.failures)

    def printErrorList(self, flavor, errors):
        for test, err in errors:
            self.stream.write(self.separator1)
            self.stream.write(f'{flavor}: {self.getDescription(test)}\n')
            self.stream.write(self.separator2)
            self.stream.write('%s\n' % err)

    def get_xml_element(self):
        e = self.__suite
        e.set('tests', str(self.testsRun))
        e.set('errors', str(len(self.errors)))
        e.set('failures', str(len(self.failures)))
        return e

class QuietRegressionTestRunner:
    def __init__(self, stream, buffer=False):
        self.result = RegressionTestResult(stream, None, 0)
        self.result.buffer = buffer

    def run(self, test):
        test(self.result)
        return self.result

def get_test_runner_class(verbosity, buffer=False):
    if verbosity:
        return functools.partial(unittest.TextTestRunner,
                                 resultclass=RegressionTestResult,
                                 buffer=buffer,
                                 verbosity=verbosity)
    return functools.partial(QuietRegressionTestRunner, buffer=buffer)

def get_test_runner(stream, verbosity, capture_output=False):
    return get_test_runner_class(verbosity, capture_output)(stream)

if __name__ == '__main__':
    class TestTests(unittest.TestCase):
        def test_pass(self):
            pass

        def test_pass_slow(self):
            time.sleep(1.0)

        def test_fail(self):
            print('stdout', file=sys.stdout)
            print('stderr', file=sys.stderr)
            self.fail('failure message')

        def test_error(self):
            print('stdout', file=sys.stdout)
            print('stderr', file=sys.stderr)
            raise RuntimeError('error message')

    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestTests))
    stream = io.StringIO()
    runner_cls = get_test_runner_class(sum(a == '-v' for a in sys.argv))
    runner = runner_cls(sys.stdout)
    result = runner.run(suite)
    print('Output:', stream.getvalue())
    print('XML: ', end='')
    for s in ET.tostringlist(result.get_xml_element()):
        print(s.decode(), end='')
    print()
support/__pycache__/__init__.cpython-36.opt-1.pyc000064400000236455150532443020015631 0ustar003

Ow�h����@s^
dZedkred��ddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZ
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl!Z"ddl#Z#ddl$m%Z%yddl&Z&ddl'Z'Wnek
�rBdZ&dZ'YnXyddl(Z)Wnek
�rjdZ)YnXyddl*Z*Wnek
�r�dZ*YnXyddl+Z+Wnek
�r�dZ+YnXyddl,Z,Wnek
�r�dZ,YnXyddl-Z-Wnek
�r
dZ-YnXyddl.Z.Wnek
�r2dZ.YnXyddl/Z/Wnek
�rZdZ/YnXddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbg\Z0Gdcd�de1�Z2Gddd
�d
e2�Z3Gded�de2�Z4Gdfd�de j5�Z6ej7�dfdhdi��Z8�dgfdk�dld�Z9dmdn�Z:dodp�Z;dqd=�Z<drd>�Z=ffdjfdsd�Z>dtd9�Z?dZ@dZAdaBdaCdZDdjZEdaFdud�ZGdvd�ZHdwd�ZIdxdy�ZJejjKdz��r.�dhd{d|�ZLd}d~�ZMdd��ZNd�d��ZOd�d��ZPnejQZMejRZNd�d��ZOd�d��ZPd�d�ZQd�d��ZRd�d�ZSd�d��ZTd�d�ZUd�d��ZVd�d#�ZW�did�d$�ZXd�d��ZYd�d%�ZZd�d&�Z[d�d'�Z\�djd�d(�Z]d�Z^d�Z_ej`ejafd�dJ�Zbe^fd�dK�Zcd�dM�Zdd�d��Zeee�Zfd�d��Zg�dmZh�dpZie jjekjld��jKd��d��Zme jje*d��Zne jje+d��Zoe jje,d��Zpe jje-d��ZqejjKd��Zrejsd��Ztetdk	�oxetdkZuejd�k�r�eu�r�d�nd�ZvndZvejwd�k�r�d�Zxnd�Zxd�jyexejz��ZxdZ{xL�dqD]BZ|yej}ej~e|��e|k�r�e�Wnek
�rYnXe|Z{P�q�Wexd�Z�ejd�k�r:ddl�Z�e�j�d�e��Z�ej��Z�dZ�ejwd�k�r�ej��jd�k�r�exd�Z�ye�j�e��Wne�k
�r�YnXe�d�e�e�f�dZ�nBejd�k�r�yd�j�e��Wn&e�k
�r�exd�j�e�dǃZ�YnXdZ�xF�drD]<Zwyewj�e��Wn&e�k
�r,ej~ex�ewZ�PYnX�q�We{�rHexd�e{Z�ndZ�ej��Z�djZ�djZ�ej7�dsd�d΄�Z�ej7�dtd�dЄ�Z�ej7�dud�d��Z�e�edӃ�r�ej7d�dN��Z�ej�j�ej�j�e���Z�ej�j�e��Z�ej�j�e�dՃZ��dvd�d�Z�d�d �Z�d�d^�Z�d�dڄZ�dddۜd�d)�Z�d�dL�Z�Gd�d߄d�e��Z��dwd�d�Z�ej7d�dU��Z�ej7d�e�djfd�d��Z�ej7d�dV��Z�Gd�d�de��Z�Gd�dW�dWej�j��Z�Gd�d�d�e��Z�Gd�d*�d*e��Z�e�e�ej�d�Z�e�e�ej�d�Z�e�e�ej�d�Z�ej7d�fd�d�d.��Z�ej7d�d��Z�d�d�Z�d�d�Z�d�d�Z�d�d��Z�ej7d�d���Z�d�d��Z�d�Z�d�Z�e�ed���	rLd�e�Z�d�Z�e��dZd�d�ZÐd�d�ZĐdxZŐdyZƐd�d�Zǐd	dX�ZȐd
d_�ZɐdzZ�d�e�Z�d�e�Z�d�e�Z�ej�Zϐdd\�Z�G�d�d
��d
�Zѐd{�dd6�ZҐdd7�Z�G�dd/�d/�ZԐd�d�ZՐd�d�Z֐ddA�Zאdd8�Zؐd|�d�d�Z�daڐddB�Zېd�d�ZܐddE�Zݐd�d�Zސd�d �Zߐd!�d"�Z�d#�d$�Z�da�da�d%�d&�Z�d'�d(�Z�d)�d*�Z�d+d0�Z�d,�d-�Z�e݃�
o�ejd�k�
o�ejs�d.�Z�e�jdk	�oe�Z�e jje�d/�Z�d}�d0d1�Z�d1�d2�Z�d3�d4�Z�djZ�d5dQ�Z�d6dR�Z�d7dS�Z�ej7�d~�d9�d:��Z�d;dO�Z�ej7�d�d<dT��Z�ej7�d=dZ��Z�ej7�d>dY��Z��d?�d@�Z�e j�e�e�dA��dB�Z��dC�dD�Z��dE�dF�Z�G�dGdP�dPej�j��Z�G�dHd[�d[e���Zd�a�dId!��Z�dJd2��Zd�a�dK�dL��Z�dMd;��Z�dN�dO��Z�dPd"��Zf�dQ��dRd?��Z	dfff�dSd@��Z
G�dTd]�d]��Z�dU�dV��Z�dW�dX��Z
ff�dY�dZ��Zgf�d[da��Zd�a�d\dG��Zej7�d]�d^���Z�d_db��ZG�d`�da��da��ZG�db�dc��dc��Zej7�dd�de���ZdS(�z7Supporting definitions for the Python regression tests.ztest.supportz.support must be imported from the test package�N�)�get_test_runner�
PIPE_MAX_SIZE�verbose�
max_memuse�
use_resources�failfast�Error�
TestFailed�
TestDidNotRun�ResourceDenied�
import_module�import_fresh_module�CleanImport�unload�forget�record_original_stdout�get_original_stdout�captured_stdout�captured_stdin�captured_stderr�TESTFN�SAVEDCWD�unlink�rmtree�temp_cwd�findfile�create_empty_file�can_symlink�fs_is_case_insensitive�is_resource_enabled�requires�requires_freebsd_version�requires_linux_version�requires_mac_ver�requires_hashdigest�check_syntax_error�TransientResource�time_out�socket_peer_reset�ioerror_peer_reset�transient_internet�BasicTestRunner�run_unittest�run_doctest�skip_unless_symlink�
requires_gzip�requires_bz2�
requires_lzma�
bigmemtest�bigaddrspacetest�cpython_only�
get_attribute�requires_IEEE_754�skip_unless_xattr�
requires_zlib�anticipate_failure�load_package_tests�detect_api_mismatch�check__all__�requires_android_level�requires_multiprocessing_queue�	is_jython�
is_android�check_impl_detail�
unix_shell�setswitchinterval�HOST�IPV6_ENABLED�find_unused_port�	bind_port�open_urlresource�bind_unix_socket�
temp_umask�
reap_children�TestHandler�threading_setup�threading_cleanup�reap_threads�
start_threads�check_warnings�check_no_resource_warning�EnvironmentVarGuard�run_with_locale�	swap_item�	swap_attr�Matcher�set_memlimit�SuppressCrashReport�sortdict�run_with_tz�PGO�missing_compiler_executable�fd_countc@seZdZdZdS)r	z*Base class for regression test exceptions.N)�__name__�
__module__�__qualname__�__doc__�rdrd�-/usr/lib64/python3.6/test/support/__init__.pyr	|sc@seZdZdZdS)r
zTest failed.N)r`rarbrcrdrdrdrer
sc@seZdZdZdS)rzTest did not run any subtests.N)r`rarbrcrdrdrdrer�sc@seZdZdZdS)rz�Test skipped because it requested a disallowed resource.

    This is raised when a test calls requires() for a resource that
    has not be enabled.  It is used to distinguish between expected
    and unexpected skips.
    N)r`rarbrcrdrdrdrer�sTccs8|r.tj��tjddt�dVWdQRXndVdS)z�Context manager to suppress package and module deprecation
    warnings when importing them.

    If ignore is False, this context manager has no effect.
    �ignorez.+ (module|package)N)�warnings�catch_warnings�filterwarnings�DeprecationWarning)rfrdrdre�_ignore_deprecated_imports�s
rkF)�required_oncCsft|��Ty
tj|�Stk
rV}z&tjjt|��r8�tj	t
|���WYdd}~XnXWdQRXdS)acImport and return the module to be tested, raising SkipTest if
    it is not available.

    If deprecated is True, any module or package deprecation messages
    will be suppressed. If a module is required on a platform but optional for
    others, set required_on to an iterable of platform prefixes which will be
    compared against sys.platform.
    N)rk�	importlibr
�ImportError�sys�platform�
startswith�tuple�unittest�SkipTest�str)�name�
deprecatedrl�msgrdrdrer
�s	

cCs^|tjkrt|�tj|=x>ttj�D]0}||ks@|j|d�r&tj|||<tj|=q&WdS)zyHelper function to save and remove a module from sys.modules

    Raise ImportError if the module can't be imported.
    �.N)ro�modules�
__import__�listrq)rv�orig_modules�modnamerdrdre�_save_and_remove_module�s
rcCs>d}ytj|||<Wntk
r.d}YnXdtj|<|S)z�Helper function to save and block a module in sys.modules

    Return True if the module was in sys.modules, False otherwise.
    TFN)rorz�KeyError)rvr}Zsavedrdrdre�_save_and_block_module�s

r�cCs|r
tjSdd�S)z�Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    cSs|S)Nrd)�frdrdre�<lambda>�sz$anticipate_failure.<locals>.<lambda>)rsZexpectedFailure)Z	conditionrdrdrer:�scCsF|dkrd}tjjtjjtjjt���}|j|||d�}|j|�|S)z�Generic load_tests implementation for simple test packages.

    Most packages can implement load_tests using this function as follows:

       def load_tests(*args):
           return load_package_tests(os.path.dirname(__file__), *args)
    Nztest*)Z	start_dirZ
top_level_dir�pattern)�os�path�dirname�__file__ZdiscoverZaddTests)Zpkg_dir�loaderZstandard_testsr�Ztop_dirZ
package_testsrdrdrer;�s
cCs�t|���i}g}t||�zfyHx|D]}t||�q&Wx |D]}t||�s>|j|�q>Wtj|�}Wntk
r~d}YnXWdx|j�D]\}	}
|
tj	|	<q�Wx|D]}tj	|=q�WX|SQRXdS)a�Import and return a module, deliberately bypassing sys.modules.

    This function imports and returns a fresh copy of the named Python module
    by removing the named module from sys.modules before doing the import.
    Note that unlike reload, the original module is not affected by
    this operation.

    *fresh* is an iterable of additional module names that are also removed
    from the sys.modules cache before doing the import.

    *blocked* is an iterable of module names that are replaced with None
    in the module cache during the import to ensure that attempts to import
    them raise ImportError.

    The named module and any modules named in the *fresh* and *blocked*
    parameters are saved before starting the import and then reinserted into
    sys.modules when the fresh import is complete.

    Module and package deprecation messages are suppressed during this import
    if *deprecated* is True.

    This function will raise ImportError if the named module cannot be
    imported.
    N)
rkrr��appendrmr
rn�itemsrorz)rvZfreshZblockedrwr}Znames_to_removeZ
fresh_nameZblocked_nameZfresh_moduleZ	orig_name�moduleZname_to_removerdrdrer�s$





cCs>yt||�}Wn&tk
r4tjd||f��YnX|SdS)z?Get an attribute, raising SkipTest if AttributeError is raised.zobject %r has no attribute %rN)�getattr�AttributeErrorrsrt)�objrvZ	attributerdrdrer6s
cCs|adS)N)�_original_stdout)�stdoutrdrdrer0scCs
tptjS)N)r�ror�rdrdrdrer4scCs&ytj|=Wntk
r YnXdS)N)rorzr�)rvrdrdrer7scGsny||�Stk
rh}zDtdkrHtd|jj|f�td|j|f�tj|tj�||�Sd}~XnXdS)N�z%s: %szre-run %s%r)	�OSErrorr�print�	__class__r`r��chmod�stat�S_IRWXU)r��func�args�errrdrdre�
_force_run=sr��wincCs�||�|r|}ntjj|�\}}|p(d}d}x<|dkrjtj|�}|rJ|n||ksVdStj|�|d9}q0Wtjd|tdd�dS)Nryg����MbP?g�?r�z)tests may fail, delete still pending for �)�
stacklevel)	r�r��split�listdir�time�sleeprg�warn�RuntimeWarning)r��pathname�waitallr�rv�timeout�Lrdrdre�_waitforHs



r�cCsttj|�dS)N)r�r�r)�filenamerdrdre�_unlinkisr�cCsttj|�dS)N)r�r��rmdir)r�rdrdre�_rmdirlsr�cs,�fdd��t�|dd�tdd�|�dS)Ncs�x�t|tj|�D]�}tjj||�}ytj|�j}Wn<tk
rn}z td||ft	j
d�d}WYdd}~XnXtj|�r�t
�|dd�t|tj|�qt|tj|�qWdS)Nz-support.rmtree(): os.lstat(%r) failed with %s)�filerT)r�)r�r�r�r��join�lstat�st_moder�r�ro�
__stderr__r��S_ISDIRr�r�r)r�rv�fullname�mode�exc)�
_rmtree_innerrdrer�ps

z_rmtree.<locals>._rmtree_innerT)r�cSst|tj|�S)N)r�r�r�)�prdrdrer�sz_rmtree.<locals>.<lambda>)r�)r�rd)r�re�_rmtreeosr�c
Cs^yddl}Wntk
r Yn:X|jt|�d�}|jjj||t|��}|rZ|d|�S|S)Nrr�)�ctypesrnZcreate_unicode_buffer�len�windll�kernel32ZGetLongPathNameW)r�r��bufferZlengthrdrdre�	_longpath�s
r�csFytj|�dStk
r"YnX�fdd���|�tj|�dS)Nc
s�x~t|tj|�D]l}tjj||�}ytj|�j}Wntk
rJd}YnXtj	|�rn�|�t|tj
|�qt|tj|�qWdS)Nr)r�r�r�r�r�r�r�r�r�r�r�r)r�rvr�r�)r�rdrer��s

z_rmtree.<locals>._rmtree_inner)�shutilrr�r�r�)r�rd)r�rer��s
cCs|S)Nrd)r�rdrdrer��scCs*yt|�Wnttfk
r$YnXdS)N)r��FileNotFoundError�NotADirectoryError)r�rdrdrer�scCs&yt|�Wntk
r YnXdS)N)r�r�)r�rdrdrer��sr�cCs&yt|�Wntk
r YnXdS)N)r�r�)r�rdrdrer�scCsBtjj|�}tjjtjj|��}tjj||d�}tj||�|S)aMove a PEP 3147/488 pyc file to its legacy pyc location.

    :param source: The file system path to the source file.  The source file
        does not need to exist, however the PEP 3147/488 pyc file must exist.
    :return: The file system path to the legacy pyc file.
    �c)	rm�util�cache_from_sourcer�r�r��abspathr��rename)�sourceZpyc_fileZup_oneZ
legacy_pycrdrdre�make_legacy_pyc�s
r�cCs\t|�xNtjD]D}tjj||d�}t|d�x dD]}ttjj||d��q8WqWdS)	z�'Forget' a module was ever imported.

    This removes the module from sys.modules and deletes any PEP 3147/488 or
    legacy .pyc files.
    z.pyr��rr�)�optimizationN)r�rr�)	rror�r�r�rrmr�r�)r~r�r��optrdrdrer�s
cs�ttd�rtjSd}tjjd�r�ddl�ddl�d}d}G�fdd�d�j�}�j	j
}|j�}|sj�j��|�}�j
j�}|j||�j|��j|��j|��}|s��j��t|j|@�s�d}n�tjdk�rVdd	lm}	m�m}
m}dd
lm}|	j|d��}
|
j�dk�rd}nFG�fd
d�d|�}|�}|
|�}|
j|�dk�sR|
j|�dk�rVd}|�s�y.ddlm}|�}|j�|j �|j!�Wn\t"k
�r�}z>t#|�}t$|�dk�r�|dd�d}dj%t&|�j'|�}WYdd}~XnX|t_(|t_tjS)N�resultr�rrcs.eZdZd�jjfd�jjfd�jjfgZdS)z*_is_gui_available.<locals>.USEROBJECTFLAGSZfInheritZ	fReserved�dwFlagsN)r`rarb�wintypesZBOOL�DWORD�_fields_rd)r�rdre�USEROBJECTFLAGS�s

r�z,gui not available (WSF_VISIBLE flag not set)�darwin)�cdll�c_int�pointer�	Structure)�find_libraryZApplicationServicesz0gui tests cannot run without OS X window managercseZdZd�fd�fgZdS)z._is_gui_available.<locals>.ProcessSerialNumberZ
highLongOfPSNZlowLongOfPSNN)r`rarbr�rd)r�rdre�ProcessSerialNumbersr�z#cannot run without OS X gui process)�Tk�2z [...]zTk unavailable due to {}: {}))�hasattr�_is_gui_availabler�rorprqr�Zctypes.wintypesr�r�Zuser32ZGetProcessWindowStationZWinErrorr�r�ZGetUserObjectInformationWZbyrefZsizeof�boolr�r�r�r�Zctypes.utilr�ZLoadLibraryZCGMainDisplayIDZGetCurrentProcessZSetFrontProcessZtkinterr�Zwithdraw�updateZdestroy�	Exceptionrur��format�typer`�reason)r�Z	UOI_FLAGSZWSF_VISIBLEr�Zdll�hZuofZneeded�resr�r�r�r�Zapp_servicesr�ZpsnZpsn_pr��root�eZ
err_stringrd)r�r�rer��sh

r�cCstdkp|tkS)z�Test whether a resource is enabled.

    Known resources are set by regrtest.py.  If not running under regrtest.py,
    all resources are assumed enabled unless use_resources has been set.
    N)r)�resourcerdrdrer $scCs>t|�s |dkrd|}t|��|dkr:t�r:ttj��dS)z@Raise ResourceDenied if the specified resource is not available.Nz"Use of the %r resource not enabled�gui)r rr�r�)r�rxrdrdrer!,scs��fdd�}|S)z�Decorator raising SkipTest if the OS is `sysname` and the version is less
    than `min_version`.

    For example, @_requires_unix_version('FreeBSD', (7, 2)) raises SkipTest if
    the FreeBSD version is less than 7.2.
    cs$tj�����fdd��}�|_|S)Nc
s�tj��krztj�jdd�d}yttt|jd���}Wntk
rLYn.X|�krzdjtt	���}t
jd�||f���||�S)N�-rrryz(%s version %s or higher required, not %s)rp�system�releaser�rr�map�int�
ValueErrorr�rursrt)r��kw�version_txt�version�min_version_txt)r��min_version�sysnamerdre�wrapper=sz:_requires_unix_version.<locals>.decorator.<locals>.wrapper)�	functools�wrapsr�)r�r�)r�r�)r�re�	decorator<sz)_requires_unix_version.<locals>.decoratorrd)r�r�r�rd)r�r�re�_requires_unix_version5sr�cGs
td|�S)z�Decorator raising SkipTest if the OS is FreeBSD and the FreeBSD version is
    less than `min_version`.

    For example, @requires_freebsd_version(7, 2) raises SkipTest if the FreeBSD
    version is less than 7.2.
    ZFreeBSD)r�)r�rdrdrer"PscGs
td|�S)z�Decorator raising SkipTest if the OS is Linux and the Linux version is
    less than `min_version`.

    For example, @requires_linux_version(2, 6, 32) raises SkipTest if the Linux
    version is less than 2.6.32.
    ZLinux)r�)r�rdrdrer#Yscs�fdd�}|S)z�Decorator raising SkipTest if the OS is Mac OS X and the OS X
    version if less than min_version.

    For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
    is lesser than 10.5.
    cs"tj����fdd��}�|_|S)Ncsxtjdkrntj�d}yttt|jd���}Wntk
rBYn,X|�krndjtt	���}t
jd||f���||�S)Nr�rryz&Mac OS X %s or higher required, not %s)rorpZmac_verrrr�r�r�r�r�rursrt)r�r�r�r�r�)r�r�rdrer�js
z4requires_mac_ver.<locals>.decorator.<locals>.wrapper)r�r�r�)r�r�)r�)r�rer�isz#requires_mac_ver.<locals>.decoratorrd)r�r�rd)r�rer$bscs��fdd�}|S)a�Decorator raising SkipTest if a hashing algorithm is not available

    The hashing algorithm could be missing or blocked by a strict crypto
    policy.

    If 'openssl' is True, then the decorator checks that OpenSSL provides
    the algorithm. Otherwise the check falls back to built-in
    implementations.

    ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS
    ValueError: unsupported hash type md4
    cstj�����fdd��}|S)NcsXy&�rtdk	rtj��n
tj��Wn&tk
rLtjd��d���YnX�||�S)Nz
hash digest 'z' is not available.)�_hashlib�new�hashlibr�rsrt)r��kwargs)�
digestnamer��opensslrdrer��sz7requires_hashdigest.<locals>.decorator.<locals>.wrapper)r�r�)r�r�)rr)r�rer��sz&requires_hashdigest.<locals>.decoratorrd)rrr�rd)rrrer%}s
z	127.0.0.1z::1cCs"tj||�}t|�}|j�~|S)a�
Returns an unused port that should be suitable for binding.  This is
    achieved by creating a temporary socket with the same family and type as
    the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to
    the specified host address (defaults to 0.0.0.0) with the port set to 0,
    eliciting an unused ephemeral port from the OS.  The temporary socket is
    then closed and deleted, and the ephemeral port is returned.

    Either this method or bind_port() should be used for any tests where a
    server socket needs to be bound to a particular port for the duration of
    the test.  Which one to use depends on whether the calling code is creating
    a python socket, or if an unused port needs to be provided in a constructor
    or passed to an external program (i.e. the -accept argument to openssl's
    s_server mode).  Always prefer bind_port() over find_unused_port() where
    possible.  Hard coded ports should *NEVER* be used.  As soon as a server
    socket is bound to a hard coded port, the ability to run multiple instances
    of the test simultaneously on the same host is compromised, which makes the
    test a ticking time bomb in a buildbot environment. On Unix buildbots, this
    may simply manifest as a failed test, which can be recovered from without
    intervention in most cases, but on Windows, the entire python process can
    completely and utterly wedge, requiring someone to log in to the buildbot
    and manually kill the affected process.

    (This is easy to reproduce on Windows, unfortunately, and can be traced to
    the SO_REUSEADDR socket option having different semantics on Windows versus
    Unix/Linux.  On Unix, you can't have two AF_INET SOCK_STREAM sockets bind,
    listen and then accept connections on identical host/ports.  An EADDRINUSE
    OSError will be raised at some point (depending on the platform and
    the order bind and listen were called on each socket).

    However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE
    will ever be raised when attempting to bind two identical host/ports. When
    accept() is called on each socket, the second caller's process will steal
    the port from the first caller, leaving them both in an awkwardly wedged
    state where they'll no longer respond to any signals or graceful kills, and
    must be forcibly killed via OpenProcess()/TerminateProcess().

    The solution on Windows is to use the SO_EXCLUSIVEADDRUSE socket option
    instead of SO_REUSEADDR, which effectively affords the same semantics as
    SO_REUSEADDR on Unix.  Given the propensity of Unix developers in the Open
    Source world compared to Windows ones, this is a common mistake.  A quick
    look over OpenSSL's 0.9.8g source shows that they use SO_REUSEADDR when
    openssl.exe is called with the 's_server' option, for example. See
    http://bugs.python.org/issue2550 for more info.  The following site also
    has a very thorough description about the implications of both REUSEADDR
    and EXCLUSIVEADDRUSE on Windows:
    http://msdn2.microsoft.com/en-us/library/ms740621(VS.85).aspx)

    XXX: although this approach is a vast improvement on previous attempts to
    elicit unused ports, it rests heavily on the assumption that the ephemeral
    port returned to us by the OS won't immediately be dished back out to some
    other process when we close and delete our temporary socket but before our
    calling code has a chance to bind the returned port.  We can deal with this
    issue if/when we come across it.
    )�socketrH�close)�familyZsocktypeZtempsock�portrdrdrerG�s
8cCs�|jtjkr�|jtjkr�ttd�r>|jtjtj�dkr>t	d��ttd�r~y |jtjtj
�dkrft	d��Wntk
r|YnXttd�r�|jtjtj
d�|j|df�|j�d}|S)a%Bind the socket to a free port and return the port number.  Relies on
    ephemeral ports in order to ensure we are using an unbound port.  This is
    important as many tests may be running simultaneously, especially in a
    buildbot environment.  This method raises an exception if the sock.family
    is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR
    or SO_REUSEPORT set on it.  Tests should *never* set these socket options
    for TCP/IP sockets.  The only case for setting these options is testing
    multicasting via multiple UDP sockets.

    Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e.
    on Windows), it will be set on the socket.  This will prevent anyone else
    from bind()'ing to our host/port for the duration of the test.
    �SO_REUSEADDRrzHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets!�SO_REUSEPORTzHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!�SO_EXCLUSIVEADDRUSEr)rr�AF_INETr��SOCK_STREAMr�Z
getsockoptZ
SOL_SOCKETrr
rr�Z
setsockoptr�bindZgetsockname)�sock�hostrrdrdrerH�s


cCs:y|j|�Wn&tk
r4|j�tjd��YnXdS)zBBind a unix socket, raising SkipTest if PermissionError is raised.zcannot bind AF_UNIX socketsN)r�PermissionErrorrrsrt)rZaddrrdrdrerJs
cCsZtjrVd}z<y"tjtjtj�}|jtdf�dStk
rBYnXWd|rT|j�XdS)z+Check whether IPv6 is enabled on this host.NrTF)rZhas_ipv6ZAF_INET6r
r�HOSTv6r�r)rrdrdre�_is_ipv6_enableds

rcstj���fdd��}|S)z5Skip the test on TLS certificate validation failures.csNy�||�Wn:tk
rH}zdt|�kr6tjd���WYdd}~XnXdS)NZCERTIFICATE_VERIFY_FAILEDz.system does not contain necessary certificates)�IOErrorrursrt)r�r�r�)r�rdre�decs
z&system_must_validate_cert.<locals>.dec)r�r�)r�rrd)r�re�system_must_validate_certs	rr�i�ZdoubleZIEEEztest requires IEEE 754 doublesz
requires zlibz
requires gzipzrequires bz2z
requires lzma�java�ANDROID_API_LEVEL�win32z/system/bin/shz/bin/shz$testz@testz	{}_{}_tmp�æ�İ�Ł�φ�К�א�،�ت�ก� �€u-àòɘŁğr�ZNFD�ntr�u-共Ł♡ͣ�ztWARNING: The filename %r CAN be encoded by the filesystem encoding (%s). Unicode filename tests may not be effective��s-��surrogateescape��w����������r�ccs�d}|dkr&tj�}d}tjj|�}nBytj|�d}Wn.tk
rf|sN�tjd|t	dd�YnX|rttj
�}z
|VWd|r�|tj
�kr�t|�XdS)a�Return a context manager that creates a temporary directory.

    Arguments:

      path: the directory to create temporarily.  If omitted or None,
        defaults to creating a temporary directory using tempfile.mkdtemp.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, if the path is specified and cannot be
        created, only a warning is issued.

    FNTz+tests may fail, unable to create temp dir: �)r�)�tempfile�mkdtempr�r��realpath�mkdirr�rgr�r��getpidr)r��quietZdir_created�pidrdrdre�temp_dir�s&


r2ccsftj�}ytj|�Wn.tk
rD|s,�tjd|tdd�YnXztj�VWdtj|�XdS)agReturn a context manager that changes the current working directory.

    Arguments:

      path: the directory to use as the temporary current working directory.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, it issues only a warning and keeps the current
        working directory the same.

    z)tests may fail, unable to change CWD to: r*)r�N)r��getcwd�chdirr�rgr�r�)r�r0Z	saved_dirrdrdre�
change_cwd	s

r5�tempcwdccs:t||d��$}t||d��}|VWdQRXWdQRXdS)a�
    Context manager that temporarily creates and changes the CWD.

    The function temporarily changes the current working directory
    after creating a temporary directory in the current directory with
    name *name*.  If *name* is None, the temporary directory is
    created using tempfile.mkdtemp.

    If *quiet* is False (default) and it is not possible to
    create or change the CWD, an error is raised.  If *quiet* is True,
    only a warning is raised and the original CWD is used.

    )r�r0)r0N)r2r5)rvr0Z	temp_pathZcwd_dirrdrdrer$s�umaskccs&tj|�}z
dVWdtj|�XdS)z8Context manager that temporarily sets the process umask.N)r�r7)r7ZoldmaskrdrdrerK8s

�datacCsbtjj|�r|S|dk	r&tjj||�}tgtj}x*|D]"}tjj||�}tjj|�r8|Sq8W|S)a[Try to find a file on sys.path or in the test directory.  If it is not
    found the argument passed to the function is returned (this does not
    necessarily signal failure; could still be the legitimate path).

    Setting *subdir* indicates a relative path to use to find the file
    rather than looking directly in the path directories.
    N)r�r��isabsr��
TEST_HOME_DIRro�exists)r�Zsubdirr�Zdn�fnrdrdrerIs
cCs(tj|tjtjBtjB�}tj|�dS)z>Create an empty file. If the file already exists, truncate it.N)r��open�O_WRONLY�O_CREAT�O_TRUNCr)r��fdrdrdrer[scCs,t|j��}dd�|D�}dj|�}d|S)z%Like repr(dict), but in sorted order.cSsg|]}d|�qS)z%r: %rrd)�.0Zpairrdrdre�
<listcomp>cszsortdict.<locals>.<listcomp>z, z{%s})�sortedr�r�)�dictr�Z	reprpairsZ
withcommasrdrdrer[`s
cCs*ttd�}z|j�S|j�tt�XdS)z`
    Create an invalid file descriptor by opening and closing a file and return
    its fd.
    �wbN)r=r�filenorr)r�rdrdre�make_bad_fdgs

rH)�lineno�offsetcCsp|jt��}t|dd�WdQRX|j}|j|j�|dk	rJ|j|j|�|j|j�|dk	rl|j|j|�dS)Nz
<test string>�exec)�assertRaises�SyntaxError�compileZ	exceptionZassertIsNotNonerI�assertEqualrJ)�testcaseZ	statementrIrJ�cmr�rdrdrer&sscsVddl}ddl}�jdd��|jj|�djd�d}tjjt	|�}���fdd�}tjj
|�r|||�}|dk	rt|St|�td�t
r�td	|t�d
�|jj�}tr�|jjd�|j|d
d�}tr�|jjd�dkr�tj|d�}zBt|d��.}	|j�}
x|
�r|	j|
�|j�}
�q�WWdQRXWd|j�X||�}|dk	�rF|Std|��dS)Nr�checkr��/rcs>t|f����}�dkr|S�|�r2|jd�|S|j�dS)Nr)r=�seekr)r<r�)r�rRr�rdre�check_valid_file�s
z*open_urlresource.<locals>.check_valid_fileZurlfetchz	fetching %s ...)r��Accept-Encoding�gzip�)r�zContent-Encoding)ZfileobjrFzinvalid resource %r���)rVrW)Zurllib.requestZurllib.parse�pop�parseZurlparser�r�r�r��
TEST_DATA_DIRr;rr!rr�rZrequestZbuild_openerrWZ
addheadersr�r=Zheaders�getZGzipFile�read�writerr
)Zurlr�r��urllibr�r<rUr��opener�out�srd)r�rRr�rerI~s<	



c@s4eZdZdZdd�Zdd�Zedd��Zdd	�Zd
S)�WarningsRecorderzyConvenience wrapper for the warnings list returned on
       entry to the warnings.catch_warnings() context manager.
    cCs||_d|_dS)Nr)�	_warnings�_last)�selfZ
warnings_listrdrdre�__init__�szWarningsRecorder.__init__cCsDt|j�|jkr t|jd|�S|tjjkr0dStd||f��dS)Nrz%r has no attribute %rrY)r�rerfr�rg�WarningMessage�_WARNING_DETAILSr�)rg�attrrdrdre�__getattr__�s
zWarningsRecorder.__getattr__cCs|j|jd�S)N)rerf)rgrdrdrerg�szWarningsRecorder.warningscCst|j�|_dS)N)r�rerf)rgrdrdre�reset�szWarningsRecorder.resetN)	r`rarbrcrhrl�propertyrgrmrdrdrdrerd�s
rdc
cs
tjd�}|jjd�}|r"|j�tjdd�� }tjdjd�t	|�VWdQRXt
|�}g}xz|D]r\}}d}	xH|dd�D]8}|j}
tj
|t|
�tj�r�t|
j|�r�d}	|j|�q�W|	rf|rf|j||jf�qfW|r�td	|d
��|�rtd|d
��dS)z�Catch the warnings, then check if all the expected
    warnings have been raised and re-raise unexpected warnings.
    If 'quiet' is True, only re-raise the unexpected warnings.
    r�Z__warningregistry__T)�recordrg�alwaysNFzunhandled warning %srz)filter (%r, %s) did not catch any warning)ro�	_getframe�	f_globalsr]�clearrgrhrz�simplefilterrdr|�message�re�matchru�I�
issubclassr��remover�r`�AssertionError)�filtersr0�frame�registry�wZreraiseZmissingrx�cat�seenZwarningrdrdre�_filterwarnings�s0
r�cOs.|jd�}|s$dtff}|dkr$d}t||�S)a�Context manager to silence warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default True without argument,
         default False if some filters are defined)

    Without argument, it defaults to:
        check_warnings(("", Warning), quiet=True)
    r0r�NT)r]�Warningr�)r|r�r0rdrdrerR�s

r�ccsHtjdd��&}tjd||d�dV|r.t�WdQRX|j|g�dS)a�Context manager to check that no warnings are emitted.

    This context manager enables a given warning within its scope
    and checks that no warnings are emitted even with that warning
    enabled.

    If force_gc is True, a garbage collection is attempted before checking
    for warnings. This may help to catch warnings emitted when objects
    are deleted, such as ResourceWarning.

    Other keyword arguments are passed to warnings.filterwarnings().
    T)rorp)ru�categoryN)rgrhri�
gc_collectrO)rPrur�Zforce_gc�warnsrdrdre�check_no_warningssr�ccsBtjdd�� }tjdtd�dVt�WdQRX|j|g�dS)a"Context manager to check that no ResourceWarning is emitted.

    Usage:

        with check_no_resource_warning(self):
            f = open(...)
            ...
            del f

    You must remove the object which may emit ResourceWarning before
    the end of the context manager.
    T)rorp)r�N)rgrhri�ResourceWarningr�rO)rPr�rdrdrerSs
c@s(eZdZdZdd�Zdd�Zdd�ZdS)	ra,Context manager to force import to return a new module reference.

    This is useful for testing module-level behaviours, such as
    the emission of a DeprecationWarning on import.

    Use like this:

        with CleanImport("foo"):
            importlib.import_module("foo") # new reference
    cGsNtjj�|_x<|D]4}|tjkrtj|}|j|kr>tj|j=tj|=qWdS)N)rorz�copy�original_modulesr`)rgZmodule_namesZmodule_namer�rdrdrerh?s




zCleanImport.__init__cCs|S)Nrd)rgrdrdre�	__enter__LszCleanImport.__enter__cGstjj|j�dS)N)rorzr�r�)rg�
ignore_excrdrdre�__exit__OszCleanImport.__exit__N)r`rarbrcrhr�r�rdrdrdrer3s

c@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)rTz_Class to help protect the environment variable properly.  Can be used as
    a context manager.cCstj|_i|_dS)N)r��environ�_environ�_changed)rgrdrdrerhXszEnvironmentVarGuard.__init__cCs
|j|S)N)r�)rg�envvarrdrdre�__getitem__\szEnvironmentVarGuard.__getitem__cCs*||jkr|jj|�|j|<||j|<dS)N)r�r�r])rgr��valuerdrdre�__setitem___s
zEnvironmentVarGuard.__setitem__cCs2||jkr|jj|�|j|<||jkr.|j|=dS)N)r�r�r])rgr�rdrdre�__delitem__es

zEnvironmentVarGuard.__delitem__cCs
|jj�S)N)r��keys)rgrdrdrer�lszEnvironmentVarGuard.keyscCs
t|j�S)N)�iterr�)rgrdrdre�__iter__oszEnvironmentVarGuard.__iter__cCs
t|j�S)N)r�r�)rgrdrdre�__len__rszEnvironmentVarGuard.__len__cCs|||<dS)Nrd)rgr�r�rdrdre�setuszEnvironmentVarGuard.setcCs
||=dS)Nrd)rgr�rdrdre�unsetxszEnvironmentVarGuard.unsetcCs|S)Nrd)rgrdrdrer�{szEnvironmentVarGuard.__enter__cGsJx<|jj�D].\}}|dkr0||jkr:|j|=q||j|<qW|jt_dS)N)r�r�r�r�r�)rgr��k�vrdrdrer�~s

zEnvironmentVarGuard.__exit__N)r`rarbrcrhr�r�r�r�r�r�r�r�r�r�rdrdrdrerTSsc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
DirsOnSysPatha�Context manager to temporarily add directories to sys.path.

    This makes a copy of sys.path, appends any directories given
    as positional arguments, then reverts sys.path to the copied
    settings when the context ends.

    Note that *all* sys.path modifications in the body of the
    context manager, including replacement of the object,
    will be reverted at the end of the block.
    cGs(tjdd�|_tj|_tjj|�dS)N)ror��original_value�original_object�extend)rg�pathsrdrdrerh�szDirsOnSysPath.__init__cCs|S)Nrd)rgrdrdrer��szDirsOnSysPath.__enter__cGs|jt_|jtjdd�<dS)N)r�ror�r�)rgr�rdrdrer��szDirsOnSysPath.__exit__N)r`rarbrcrhr�r�rdrdrdrer��s
r�c@s*eZdZdZdd�Zdd�Zd	dd�ZdS)
r'z�Raise ResourceDenied if an exception is raised while the context manager
    is in effect that matches the specified exception and attributes.cKs||_||_dS)N)r��attrs)rgr�r�rdrdrerh�szTransientResource.__init__cCs|S)Nrd)rgrdrdrer��szTransientResource.__enter__NcCsT|dk	rPt|j|�rPx:|jj�D]$\}}t||�s4Pt||�|kr Pq Wtd��dS)z�If type_ is a subclass of self.exc and value has attributes matching
        self.attrs, raise ResourceDenied.  Otherwise let the exception
        propagate (if any).Nz%an optional resource is not available)ryr�r�r�r�r�r)rgZtype_r��	tracebackrkZ
attr_valuerdrdrer��s
zTransientResource.__exit__)NNN)r`rarbrcrhr�r�rdrdrdrer'�s)�errnog>@)r��errnosc	#spd!d"d#d$d%d&g}d(d*d,d.d/g}td|��|�g��sRdd�|D��dd�|D�����fdd�}tj�}z�y|dk	r�tj|�dVWn�tjk
�r�}z&tr�tjj	�j
dd��|�WYdd}~Xn�tk
�rZ}zpx^|j
}t|�d k�rt
|dt��r|d}n*t|�dk�r8t
|d t��r8|d }nP�q�W||��WYdd}~XnXWdtj|�XdS)0z�Return a context manager that raises ResourceDenied when various issues
    with the Internet connection manifest themselves as exceptions.�ECONNREFUSED�o�
ECONNRESET�h�EHOSTUNREACH�q�ENETUNREACH�e�	ETIMEDOUT�n�
EADDRNOTAVAIL�c�	EAI_AGAINr*�EAI_FAILr��
EAI_NONAMEr��
EAI_NODATA��
WSANO_DATA�*zResource %r is not availablecSsg|]\}}tt||��qSrd)r�r�)rBrv�numrdrdrerC�sz&transient_internet.<locals>.<listcomp>cSsg|]\}}tt||��qSrd)r�r)rBrvr�rdrdrerC�scs�t|dd�}t|tj�s�t|tj�r,|�ks�t|tjj�rTd|jkoNdkns�t|tjj	�r�d|j
ks�d|j
ks�d|j
ks�|�kr�ts�tj
j�jdd��|�dS)	Nr�i�iW�ConnectionRefusedError�TimeoutError�EOFErrorr�
)r��
isinstancerr�Zgaierrorr`�errorZ	HTTPError�codeZURLErrorr�rro�stderrr_r�)r��n)�captured_errnos�denied�
gai_errnosrdre�filter_error�s


z(transient_internet.<locals>.filter_errorNrr�r)r�r�)r�r�)r�r�)r�r�)r�r�)r�r����)r�r����)r�r����)r�r����)r�r�)r�r�)rrZgetdefaulttimeoutZsetdefaulttimeout�nntplibZNNTPTemporaryErrorrror�r_r�r�r�r�)	Z
resource_namer�r�Zdefault_errnosZdefault_gai_errnosr�Zold_timeoutr��ard)r�r�r�rer+�sP



c
csFddl}tt|�}tt||j��ztt|�VWdtt||�XdS)z�Return a context manager used by captured_stdout/stdin/stderr
    that temporarily replaces the sys stream *stream_name* with a StringIO.rN)�ior�ro�setattr�StringIO)Zstream_namer�Zorig_stdoutrdrdre�captured_outputs
r�cCstd�S)z�Capture the output of sys.stdout:

       with captured_stdout() as stdout:
           print("hello")
       self.assertEqual(stdout.getvalue(), "hello\n")
    r�)r�rdrdrdrerscCstd�S)z�Capture the output of sys.stderr:

       with captured_stderr() as stderr:
           print("hello", file=sys.stderr)
       self.assertEqual(stderr.getvalue(), "hello\n")
    r�)r�rdrdrdrer%scCstd�S)a	Capture the input to sys.stdin:

       with captured_stdin() as stdin:
           stdin.write('hello\n')
           stdin.seek(0)
           # call test code that consumes from sys.stdin
           captured = input()
       self.assertEqual(captured, "hello")
    �stdin)r�rdrdrdrer.s
cCs*tj�trtjd�tj�tj�dS)a�Force as many objects as possible to be collected.

    In non-CPython implementations of Python, this is needed because timely
    deallocation is not guaranteed by the garbage collector.  (Even in CPython
    this can be the case in case of reference cycles.)  This means that __del__
    methods may be called later than expected and weakrefs may remain alive for
    longer than expected.  This function tries its best to force all garbage
    objects to disappear.
    g�������?N)�gcZcollectr@r�r�rdrdrdrer�;s


r�c
cs.tj�}tj�z
dVWd|r(tj�XdS)N)r��	isenabled�disable�enable)Zhave_gcrdrdre�
disable_gcKs
r�cCs:tjd�pd}d}x|j�D]}|jd�r|}qW|dkS)z,Find if Python was built with optimizations.�	PY_CFLAGSr�z-O�-O0�-Og)r�r�r�)�	sysconfig�get_config_varr�rq)ZcflagsZ	final_optr�rdrdre�python_is_optimizedVs
r�ZnPZ0n�gettotalrefcountZ2PZ0Pr�cCstjt|t�S)N)�struct�calcsize�_header�_align)�fmtrdrdre�calcobjsizegsr�cCstjt|t�S)N)r�r��_vheaderr�)r�rdrdre�calcvobjsizejsr���	cCspddl}tj|�}t|�tkr(|jt@sBt|�tkrLt|�jt@rL||j7}dt|�||f}|j|||�dS)Nrz&wrong size for %s: got %d, expected %d)	�	_testcapiro�	getsizeofr��	__flags__�_TPFLAGS_HEAPTYPE�_TPFLAGS_HAVE_GCZSIZEOF_PYGC_HEADrO)�test�o�sizer�r�rxrdrdre�check_sizeofqs

r�cs��fdd�}|S)Ncs$���fdd�}�j|_�j|_|S)Ncs�y ddl}t|��}|j|�}Wn(tk
r6�YnBd}}Yn0Xx,�D]$}y|j||�PWqPYqPXqPWz
�||�S|r�|r�|j||�XdS)Nr)�localer��	setlocaler�)r��kwdsr�r�Zorig_locale�loc)�catstrr��localesrdre�inner�s$



z1run_with_locale.<locals>.decorator.<locals>.inner)r`rc)r�r�)r�r�)r�rer��sz"run_with_locale.<locals>.decoratorrd)r�r�r�rd)r�r�rerU�scs�fdd�}|S)Ncs"��fdd�}�j|_�j|_|S)Ncs�y
tj}Wntk
r(tjd��YnXdtjkr@tjd}nd}�tjd<|�z
�||�S|dkrrtjd=n
|tjd<tj�XdS)Nztzset requiredZTZ)r��tzsetr�rsrtr�r�)r�r�r�Zorig_tz)r��tzrdrer��s





z-run_with_tz.<locals>.decorator.<locals>.inner)r`rc)r�r�)r�)r�rer��szrun_with_tz.<locals>.decoratorrd)r�r�rd)r�rer\�scCs�dttdtd�}tjd|tjtjB�}|dkr>td|f��tt|j	d��||j	d�j
��}|a|tkrrt}|t
dkr�td|f��|adS)Ni)r��m�g�tz(\d+(\.\d+)?) (K|M|G|T)b?$zInvalid memory limit %rrr*z$Memory limit %r too low to be useful)�_1M�_1Grvrw�
IGNORECASE�VERBOSEr�r��float�group�lower�real_max_memuse�MAX_Py_ssize_t�_2Gr)�limitZsizesr�ZmemlimitrdrdrerY�s$c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_MemoryWatchdogz`An object which periodically watches the process' memory consumption
    and prints it out.
    cCsdjtj�d�|_d|_dS)Nz/proc/{pid}/statm)r1F)r�r�r/�procfile�started)rgrdrdrerh�sz_MemoryWatchdog.__init__cCs�yt|jd�}Wn<tk
rL}z tjdj|�t�tjj	�dSd}~XnXt
d�}tjtj
|g|tjd�|_|j�d|_dS)N�rz!/proc not available for stats: {}zmemory_watchdog.py)r�r�T)r=r
r�rgr�r�r�ror��flushr�
subprocess�Popen�
executableZDEVNULL�mem_watchdogrr)rgr�r�Zwatchdog_scriptrdrdre�start�s
z_MemoryWatchdog.startcCs|jr|jj�|jj�dS)N)rrZ	terminate�wait)rgrdrdre�stop�s
z_MemoryWatchdog.stopN)r`rarbrcrhrrrdrdrdrer	�sr	cs���fdd�}|S)atDecorator for bigmem tests.

    'size' is a requested size for the test (in arbitrary, test-interpreted
    units.) 'memuse' is the number of bytes per unit for the test, or a good
    estimate of it. For example, a test that needs two byte buffers, of 4 GiB
    each, could be decorated with @bigmemtest(size=_4G, memuse=2).

    The 'size' argument is normally passed to the decorated test method as an
    extra argument. If 'dry_run' is true, the value passed to the test method
    may be less than the requested value. If 'dry_run' is false, it means the
    test doesn't support dummy runs when -M is not specified.
    cs ���fdd����_��_�S)Nc
s��j}�j}tsd}n|}ts$�rFt||krFtjd||d��tr|tr|t�tdj||dd��t�}|j	�nd}z
�||�S|r�|j
�XdS)	Niz'not enough memory: %.1fG minimum neededir*z* ... expected peak memory use: {peak:.1f}G)Zpeaki@i@)r��memuserrsrtrr�r�r	rr)rgr�r�maxsizeZwatchdog)�dry_runr�r�rdrer�s*


z.bigmemtest.<locals>.decorator.<locals>.wrapper)r�r)r�)rrr�)r�r�rer�szbigmemtest.<locals>.decoratorrd)r�rrr�rd)rrr�rer3s
!cs�fdd�}|S)z0Decorator for tests that fill the address space.csDttkr8td
kr$tdkr$tjd��q@tjdtd��n�|�SdS)
Nr��?r�z-not enough memory: try a 32-bit build insteadz'not enough memory: %.1fG minimum neededir*ll����li@)rrrsrt)rg)r�rdrer�3sz!bigaddrspacetest.<locals>.wrapperrd)r�r�rd)r�rer41sc@seZdZdd�ZdS)r,cCstj�}||�|S)N)rsZ
TestResult)rgr�r�rdrdre�runDszBasicTestRunner.runN)r`rarbrrdrdrdrer,CscCs|S)Nrd)r�rdrdre�_idIsrcCs<|dkrt�rtjtj�St|�r(tStjdj|��SdS)Nr�zresource {0!r} is not enabled)r�rs�skipr�r rr�)r�rdrdre�requires_resourceLs
rcCs&trt|krtjd|tf�StSdS)Nz%s at Android API level %d)rA�_ANDROID_API_LEVELrsrr)�levelr�rdrdrer>TscCstdd�|�S)z9
    Decorator for tests only applicable on CPython.
    T)�cpython)�impl_detail)r�rdrdrer5[scKsVtf|�rtS|dkrLt|�\}}|r,d}nd}t|j��}|jdj|��}tj|�S)Nz*implementation detail not available on {0}z%implementation detail specific to {0}z or )	rBr�
_parse_guardsrDr�r�r�rsr)rx�guardsZ
guardnames�defaultrdrdrer!as
r!cCsTtdkr:ddl}y|j�daWntk
r8daYnXd}trF|Stj|�|�S)z8Skip decorator for tests that use multiprocessing.Queue.NrTFz6requires a functioning shared semaphore implementation)�_have_mp_queue�multiprocessingZQueuernrsr)r�r&rxrdrdrer?os
cCs*|sddidfSt|j��d}||fS)Nr TFr)r|�values)r#Zis_truerdrdrer"~sr"cKs t|�\}}|jtj�j�|�S)a5This function returns True or False depending on the host platform.
       Examples:
          if check_impl_detail():               # only on CPython (default)
          if check_impl_detail(jython=True):    # only on Jython
          if check_impl_detail(cpython=False):  # everywhere except on CPython
    )r"r]rpZpython_implementationr)r#r$rdrdrerB�scs,ttd�s�Stj���fdd��}|SdS)zEDecorator to temporarily turn off tracing for the duration of a test.�gettracecs.tj�}ztjd��||�Stj|�XdS)N)ror(�settrace)r�r�Zoriginal_trace)r�rdrer��s


zno_tracing.<locals>.wrapperN)r�ror�r�)r�r�rd)r�re�
no_tracing�s
r*cCstt|��S)aDecorator for tests which involve reference counting.

    To start, the decorator does not run the test if is not run by CPython.
    After that, any trace function is unset during the test to prevent
    unexpected refcounts caused by the trace function.

    )r*r5)r�rdrdre�
refcount_test�sr+cCsRg}xB|jD]8}t|tj�r2t||�|j|�q||�r|j|�qW||_dS)z>Recursively filter test cases in a suite based on a predicate.N)Z_testsr�rs�	TestSuite�
_filter_suiter�)�suiteZpredZnewtestsr�rdrdrer-�s
r-cCs�ttjttdk	d�}|j|�}tdk	r4tj|j��|js>t	�|j
�s�t|j�dkrl|j
rl|jdd}n6t|j
�dkr�|jr�|j
dd}nd}ts�|d7}t|��dS)z2Run tests from a unittest.TestSuite-derived class.N)�	verbosityZcapture_outputrrzmultiple errors occurredz!; run in verbose mode for details)rror�r�junit_xml_listrr�Zget_xml_elementZtestsRunrZ
wasSuccessfulr��errorsZfailuresr
)r.Zrunnerr�r�rdrdre�
_run_suite�s"
r2cCstdkrdSt|j��SdS)NT)�_match_test_func�id)r�rdrdre�
match_test�sr5cCsd|kotjd|�S)Nryz[?*\[\]])rv�search)r�rdrdre�_is_full_match_test�sr7csr|tkrdS|sd}f}nHttt|��r4t|�j}n.djttj|��}t	j
|�j��fdd�}|}t|�a|a
dS)N�|cs$�|�rdStt�|jd���SdS)NTry)�anyr�r�)Ztest_id)�regex_matchrdre�match_test_regex�sz)set_match_tests.<locals>.match_test_regex)�_match_test_patterns�allr�r7r��__contains__r��fnmatch�	translatervrNrwrrr3)Zpatternsr�Zregexr;rd)r:re�set_match_tests�srAcGs�tjtjf}tj�}xh|D]`}t|t�rT|tjkrJ|jtjtj|��qzt	d��qt||�rj|j|�q|jtj
|��qWt|t�t
|�dS)z1Run tests from unittest.TestCase-derived classes.z)str arguments must be keys in sys.modulesN)rsr,ZTestCaser�rurorzZaddTestZ
findTestCasesr�Z	makeSuiter-r5r2)�classesZvalid_typesr.�clsrdrdrer-s





cCsdS)z,Just used to check if docstrings are enabledNrdrdrdrdre�_check_docstrings(srD�WITH_DOC_STRINGSztest requires docstringscCs`ddl}|dkrt}nd}|j|||d�\}}|rBtd||f��trXtd|j|f�||fS)aRun doctest on the given module.  Return (#failures, #tests).

    If optional argument verbosity is not specified (or is None), pass
    support's belief about verbosity on to doctest.  Else doctest's
    usual behavior is used (it searches sys.argv for -v).
    rN)r�optionflagsz%d of %d doctests failedz,doctest (%s) ... %d tests with zero failures)�doctestrZtestmodr
r�r`)r�r/rFrGr�r�rdrdrer.9scCstjj�fS)N)rorzr�rdrdrdre�
modules_setupTsrHcCs:dd�tjj�D�}tjj�tjj|�tjj|�dS)NcSs"g|]\}}|jd�r||f�qS)z
encodings.)rq)rBr�r�rdrdrerC[sz#modules_cleanup.<locals>.<listcomp>)rorzr�rsr�)Z
oldmodulesZ	encodingsrdrdre�modules_cleanupWs
rIcCs"trtj�tjj�fSdffSdS)Nr)�_thread�_count�	threading�	_danglingr�rdrdrdrerNzscGsJtsdSd}x8t|�D],}tj�tjf}||kr2Ptjd�t�qWdS)N�dg{�G�z�?)rJ�rangerKrLrMr�r�r�)Zoriginal_valuesZ
_MAX_COUNT�countr'rdrdrerO�s
cs"ts�Stj���fdd��}|S)z�Use this function when threads are being used.  This will
    ensure that the threads are cleaned up even when the test fails.
    If threading is unavailable this function does nothing.
    cst�}z�|�St|�XdS)N)rNrO)r��key)r�rdrer��szreap_threads.<locals>.decorator)rJr�r�)r�r�rd)r�rerP�s�N@ccs�tj�}z
dVWdtj�}||}xjtj�}||kr8Ptj�|kr|tj�|}d||�d|d�d|�d|�d�	}t|��tjd�t�q&WXdS)	aH
    bpo-31234: Context manager to wait until all threads created in the with
    statement exit.

    Use _thread.count() to check if threads exited. Indirectly, wait until
    threads exit the internal t_bootstrap() C function of the _thread module.

    threading_setup() and threading_cleanup() are designed to emit a warning
    if a test leaves running threads in the background. This context manager
    is designed to cleanup threads started by the _thread.start_new_thread()
    which doesn't allow to wait for thread exit, whereas thread.Thread has a
    join() method.
    Nz!wait_threads() failed to cleanup z threads after z.1fz seconds (count: z
, old count: �)g{�G�z�?)rJrKr�Z	monotonicr{r�r�)r�Z	old_countZ
start_timeZdeadlinerPZdtrxrdrdre�wait_threads_exit�s
$
rTc
CsZttd�rVd}xFy2tj|tj�\}}|dkr.Ptd|tjd�WqPYqXqWdS)z�Use this function at the end of test_main() whenever sub-processes
    are started.  This will help ensure that no extra children (zombies)
    stick around to hog resources and create problems when looking
    for refleaks.
    �waitpidrrz2Warning -- reap_children() reaped child process %s)r�NrY)r�r�rU�WNOHANGr�ror�)Zany_processr1ZstatusrdrdrerL�s
ccs*t|�}g}zZy$x|D]}|j�|j|�qWWn*trVtdt|�t|�f��YnXdVWdz�|rt|�tj�}}xltdd�D]^}|d7}x$|D]}|jt	|tj�d��q�Wdd�|D�}|s�Ptr�tdt|�|f�q�WWdd	d�|D�}|�r"t
jtj
�td
t|���XXdS)Nz/Can't start %d threads, only %d threads startedrr�<g{�G�z�?cSsg|]}|j�r|�qSrd)�isAlive)rBr�rdrdrerC�sz!start_threads.<locals>.<listcomp>z7Unable to join %d threads during a period of %d minutescSsg|]}|j�r|�qSrd)rX)rBr�rdrdrerC�szUnable to join %d threads)r|rr�rr�r�r�rOr��max�faulthandlerZdump_tracebackror�r{)ZthreadsZunlockrr�ZendtimeZ	starttimer�rdrdrerQ�s>


c
csnt||�r<t||�}t|||�z
|VWdt|||�Xn.t|||�z
dVWdt||�rht||�XdS)a�Temporary swap out an attribute with a new object.

    Usage:
        with swap_attr(obj, "attr", 5):
            ...

        This will set obj.attr to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `attr` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.

        The old value (or None if it doesn't exist) will be assigned to the
        target of the "as" clause, if there is one.
    N)r�r�r��delattr)r�rk�new_val�real_valrdrdrerW�s




ccsX||kr0||}|||<z
|VWd|||<Xn$|||<z
dVWd||krR||=XdS)a�Temporary swap out an item with a new object.

    Usage:
        with swap_item(obj, "item", 5):
            ...

        This will set obj["item"] to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `item` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.

        The old value (or None if it doesn't exist) will be assigned to the
        target of the "as" clause, if there is one.
    Nrd)r��itemr\r]rdrdrerV	s

cCstjdd|�j�}|S)z�Strip the stderr of a Python process from potential debug output
    emitted by the interpreter.

    This will typically be run on the result of the communicate() method
    of a subprocess.Popen object.
    s\[\d+ refs, \d+ blocks\]\r?\n?�)rv�sub�strip)r�rdrdre�strip_python_stderr8	srbZ	getcountsz-types are immortal if COUNT_ALLOCS is definedcCstj�S)znReturn a list of command-line arguments reproducing the current
    settings in sys.flags and sys.warnoptions.)rZ_args_from_interpreter_flagsrdrdrdre�args_from_interpreter_flagsE	srccCstj�S)zgReturn a list of command-line arguments reproducing the current
    optimization settings in sys.flags.)rZ"_optim_args_from_interpreter_flagsrdrdrdre�!optim_args_from_interpreter_flagsJ	srdc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rMcCstjjj|d�||_dS)Nr)�logging�handlers�BufferingHandlerrh�matcher)rgrhrdrdrerhT	szTestHandler.__init__cCsdS)NFrd)rgrdrdre�shouldFlush]	szTestHandler.shouldFlushcCs|j|�|jj|j�dS)N)r�r�r��__dict__)rgrordrdre�emit`	s
zTestHandler.emitcKs.d}x$|jD]}|jj|f|�rd}PqW|S)zW
        Look for a saved dict whose keys/values match the supplied arguments.
        FT)r�rh�matches)rgr�r��drdrdrerld	szTestHandler.matchesN)r`rarbrhrirkrlrdrdrdrerMS	s	c@s eZdZdZdd�Zdd�ZdS)	rXrxrucKs<d}x2|D]*}||}|j|�}|j|||�s
d}Pq
W|S)a.
        Try to match a single dict with the supplied arguments.

        Keys whose values are strings and which are in self._partial_matches
        will be checked for partial (i.e. substring) matches. You can extend
        this scheme to (for example) do regular expression matching, etc.
        TF)r]�match_value)rgrmr�r�r�r��dvrdrdrerls	s

zMatcher.matchescCsHt|�t|�krd}n.t|�tk	s,||jkr6||k}n|j|�dk}|S)zT
        Try to match a single stored value (dv) with a supplied value (v).
        Fr)r�ru�_partial_matches�find)rgr�ror�r�rdrdrern�	s
zMatcher.match_valueN)rxru)r`rarbrprlrnrdrdrdrerXo	sc
CsZtdk	rtStd}ytjt|�d}Wntttfk
rFd}YnXtj|�|a|S)NrTF)�_can_symlinkrr��symlinkr��NotImplementedErrorr�rz)Zsymlink_path�canrdrdrer�	s

cCs t�}d}|r|Stj|�|�S)z8Skip decorator for tests that require functional symlinkz*Requires functional symlink implementation)rrsr)r��okrxrdrdrer/�	scCs�tdk	rtSttd�sd}n�tj�}tj|d�\}}z�ttd���}y`tj|dd�tj|dd�tj|j	�dd�t
j�}tj
d	|�}|dkp�t|jd
��dk}Wntk
r�d}YnXWdQRXWdtt�t|�t|�X|a|S)N�setxattrF)�dirrFs	user.testr_strusted.foos42z
2.6.(\d{1,2})r�')�
_can_xattrr�r�r+r,Zmkstempr=rrwrGrpr�rvrwr�rr�rr�)ruZtmp_dirZtmp_fpZtmp_name�fpZkernel_versionr�rdrdre�	can_xattr�	s,

r|cCs t�}d}|r|Stj|�|�S)zDSkip decorator for tests that require functional extended attributesz(no non-broken extended attribute support)r|rsr)r�rvrxrdrdrer8�	scCs$tpt}d}|r|Stj|�|�S)z;Skip decorator for tests not run in (non-extended) PGO taskz#Not run for (non-extended) PGO task)r]�PGO_EXTENDEDrsr)r�rvrxrdrdre�skip_if_pgo_task�	s
r~cCs^tj|d��H}|j}|j�}||kr,|j�}ytjj||�Stk
rNdSXWdQRXdS)zKDetects if the file system for the specified directory is case-insensitive.)rxFN)	r+ZNamedTemporaryFilerv�upperrr�r��samefiler�)Z	directory�base�	base_pathZ	case_pathrdrdrer�	s)rfcCs>tt|��tt|��}|r(|t|�8}tdd�|D��}|S)aReturns the set of items in ref_api not in other_api, except for a
    defined list of items to be ignored in this check.

    By default this skips private attributes beginning with '_' but
    includes all magic methods, i.e. those starting and ending in '__'.
    css(|] }|jd�s|jd�r|VqdS)�_�__N)rq�endswith)rBr�rdrdre�	<genexpr>�	sz&detect_api_mismatch.<locals>.<genexpr>)r�rx)Zref_apiZ	other_apirfZ
missing_itemsrdrdrer<�	s
cCs�|dkr|jf}nt|t�r"|f}t|�}xbt|�D]V}|jd�s4||krLq4t||�}t|dd�|ks�t|d�r4t|tj	�r4|j
|�q4W|j|j|�dS)aAssert that the __all__ variable of 'module' contains all public names.

    The module's public names (its API) are detected automatically based on
    whether they match the public name convention and were defined in
    'module'.

    The 'name_of_module' argument can specify (as a string or tuple thereof)
    what module(s) an API could be defined in in order to be detected as a
    public API. One case for this is when 'module' imports part of its public
    API from other modules, possibly a C backend (like 'csv' and its '_csv').

    The 'extra' argument can be a set of names that wouldn't otherwise be
    automatically detected as "public", like objects without a proper
    '__module__' attribute. If provided, it will be added to the
    automatically detected ones.

    The 'blacklist' argument can be a set of names that must not be treated
    as part of the public API even though their names indicate otherwise.

    Usage:
        import bar
        import foo
        import unittest
        from test import support

        class MiscTestCase(unittest.TestCase):
            def test__all__(self):
                support.check__all__(self, foo)

        class OtherTestCase(unittest.TestCase):
            def test__all__(self):
                extra = {'BAR_CONST', 'FOO_CONST'}
                blacklist = {'baz'}  # Undocumented name.
                # bar imports part of its API from _bar.
                support.check__all__(self, bar, ('bar', '_bar'),
                                     extra=extra, blacklist=blacklist)

    Nr�ra)
r`r�rur�rxrqr�r��types�
ModuleType�addZassertCountEqual�__all__)Z	test_caser�Zname_of_moduleZextraZ	blacklistZexpectedrvr�rdrdrer=�	s)


c@s(eZdZdZdZdZdd�Zdd�ZdS)rZz�Try to prevent a crash report from popping up.

    On Windows, don't display the Windows Error Reporting dialog.  On UNIX,
    disable the creation of coredump file.
    Nc
Csrtjjd�r�ddl}|jj|_d}|jj|�|_|jj|j|B�yddl	}|j
Wnttfk
rlYnLXi|_
x�|j|j|jgD].}|j
||j�}|j||j�}||f|j
|<q�Wn�tdk	�r
y*tjtj�|_tjtjd|jdf�Wnttfk
�rYnXtjdk�rnddd	d
g}tj|tjtjd�}|�|j�d}	WdQRX|	j�dk�rntd
ddd�|S)z�On Windows, disable Windows Error Reporting dialogs using
        SetErrorMode.

        On UNIX, try to save the previous core file size limit, then set
        soft limit to 0.
        r�rNr�rr�z/usr/bin/defaultsr^zcom.apple.CrashReporterZ
DialogType)r�r�s	developerz:this test triggers the Crash Reporter, that is intentionalr�T)�endr
) rorprqr�r�r��_k32�SetErrorMode�	old_value�msvcrt�CrtSetReportModer�rn�	old_modes�CRT_WARN�	CRT_ERROR�
CRT_ASSERTZCRTDBG_MODE_FILE�CrtSetReportFileZCRTDBG_FILE_STDERRr�Z	getrlimit�RLIMIT_CORE�	setrlimitr�r�rr�PIPEZcommunicaterar�)
rgr�ZSEM_NOGPFAULTERRORBOXr��report_type�old_mode�old_file�cmd�procr�rdrdrer�2
sN




zSuppressCrashReport.__enter__cGs�|jdkrdStjjd�rl|jj|j�|jr�ddl}xj|jj�D]$\}\}}|j	||�|j
||�qBWn6tdk	r�ytjtj
|j�Wnttfk
r�YnXdS)zARestore Windows ErrorMode or core file behavior to initial value.Nr�r)r�rorprqr�r�r�r�r�r�r�r�r�r�r�r�)rgr�r�r�r�r�rdrdrer�s
s
zSuppressCrashReport.__exit__)r`rarbrcr�r�r�r�rdrdrdrerZ)
s
Acsrt���d�y�j��Wn$ttfk
r@t��d��YnXd�����fdd�}|j|�t��|�dS)z�Override 'object_to_patch'.'attr_name' with 'new_value'.

    Also, add a cleanup procedure to 'test_instance' to restore
    'object_to_patch' value for 'attr_name'.
    The 'attr_name' should be a valid attribute for 'object_to_patch'.

    FNTcs �rt����n
t���dS)N)r�r[rd)�
attr_is_local�	attr_name�object_to_patchr�rdre�cleanup�
szpatch.<locals>.cleanup)r�rjr�r�Z
addCleanupr�)Z
test_instancer�r�Z	new_valuer�rd)r�r�r�r�re�patch�
s


r�cCsFyddl}Wntk
r YnX|j�r4tjd��ddl}|j|�S)zi
    Run code in a subinterpreter. Raise unittest.SkipTest if the tracemalloc
    module is enabled.
    rNzUrun_in_subinterp() cannot be used if tracemalloc module is tracing memory allocations)�tracemallocrnZ
is_tracingrsrtr��run_in_subinterp)r�r�r�rdrdrer��
s
r�csHG��fdd�d|�}d�|||���|jtt��t�|j��dS)NcseZdZ��fdd�ZdS)z%check_free_after_iterating.<locals>.Acs*d�yt��Wntk
r$YnXdS)NT)�next�
StopIteration)rg)�done�itrdre�__del__�
s
z-check_free_after_iterating.<locals>.A.__del__N)r`rarbr�rd)r�r�rdre�A�
sr�F)rLr�r�r�Z
assertTrue)r�r�rCr�r�rd)r�r�re�check_free_after_iterating�
s	r�cCs|ddlm}m}m}|j�}|j|�xP|jD]F}|r@||kr@q.t||�}|rPn
|dkrZq.|j|d�dkr.|dSq.WdS)a<Check if the compiler components used to build the interpreter exist.

    Check for the existence of the compiler executables whose names are listed
    in 'cmd_names' or all the compiler executables when 'cmd_names' is empty
    and return the first missing executable or None when none is found
    missing.

    r)�	ccompilerr��spawnN)	Z	distutilsr�r�r�Znew_compilerZcustomize_compilerZexecutablesr�Zfind_executable)Z	cmd_namesr�r�r�Zcompilerrvr�rdrdrer^�
s	

cCs@d}tr6||kr6tdkr.tjddg�j�dkatr6|}tj|�S)Ng�h㈵��>Zgetpropzro.kernel.qemu�1)rA�_is_android_emulatorrZcheck_outputrarorD)ZintervalZminimum_intervalrdrdrerD�
sc
cs>tjj�}tj�}ztj�dVWd|r8tj|dd�XdS)NT)r�Zall_threads)ror�rGrZ�
is_enabledr�r�)rAr�rdrdre�disable_faulthandler�
s

r�c	/Cs�tjjd�r8ytjd�}t|�dStk
r6YnXd}ttd�rjytjd�}Wnt	k
rhYnXd}tjd	kr�yd
dl
}|jWntt
fk
r�Yn0Xi}x(|j|j|jfD]}|j|d
�||<q�Wzpd
}xft|�D]Z}ytj|�}Wn4t	k
�r(}z|jtjk�r�WYdd}~Xq�Xtj|�|d7}q�WWd|dk	�rzx*|j|j|jfD]}|j|||��q`WX|S)z/Count the number of open file descriptors.
    �linux�freebsdz
/proc/self/fdr��sysconf�SC_OPEN_MAXNrr)r�r�)rorprqr�r�r�r�r�r�r�r�r�r�rnr�r�r�rO�dupr�ZEBADFr)	�namesZMAXFDr�r�r�rPrAZfd2r�rdrdrer_	sP





c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�SaveSignalsz�
    Save an restore signal handlers.

    This class is only able to save/restore signal handlers registered
    by the Python signal module: see bpo-13285 for "external" signal
    handlers.
    cCsjddl}||_ttd|j��|_x>dD]6}yt||�}Wntk
rNw&YnX|jj|�q&Wi|_dS)Nrr�SIGKILL�SIGSTOP)r�r�)	�signalr|rO�NSIG�signalsr�r�rzrf)rgr�Zsigname�signumrdrdrerhMs
zSaveSignals.__init__cCs4x.|jD]$}|jj|�}|dkr"q||j|<qWdS)N)r�r��	getsignalrf)rgr��handlerrdrdre�saveZs
zSaveSignals.savecCs*x$|jj�D]\}}|jj||�qWdS)N)rfr�r�)rgr�r�rdrdre�restorefszSaveSignals.restoreN)r`rarbrcrhr�r�rdrdrdrer�Ds
r�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�FakePathz.Simple implementing of the path protocol.
    cCs
||_dS)N)r�)rgr�rdrdrerhnszFakePath.__init__cCsd|j�d�S)Nz
<FakePath �>)r�)rgrdrdre�__repr__qszFakePath.__repr__cCs6t|jt�s$t|jt�r,t|jt�r,|j�n|jSdS)N)r�r��
BaseExceptionr�ry)rgrdrdre�
__fspath__ts
zFakePath.__fspath__N)r`rarbrcrhr�r�rdrdrdrer�ksr�ccs.tj�}ztj|�dVWdtj|�XdS)z>Temporarily change the integer string conversion length limit.N)ro�get_int_max_str_digits�set_int_max_str_digits)Z
max_digitsZcurrentrdrdre�adjust_int_max_str_digits|s


r�)T)F)F)N)Nii@i@i@ii)rrrrrrrrr r!r")r&r$r'r(r))NF)F)r6F)N)Fi@ii)T)N)Nr)rR)N(rcr`rn�collections.abc�collections�
contextlibZdatetimer�rZr?r�r�r�rm�importlib.utilr�Zlogging.handlersrer�r�rprvr�rr�r�rror�r+r�r�rsZurllib.errorr`rgZ
testresultrrJrLZmultiprocessing.processr&�zlibrW�bz2Zlzmar�r�r�r�r	r
rrtr�contextmanagerrkr
rr�r:r;rr6rrrrr0rr�rrrr�rqr�r�r�r�r�rr�rr�rr�r r!r�r"r#r$r%rErr	r
rGrHrJrrFrrZ
SOCK_MAX_SIZEZ
skipUnlessr�
__getformat__r7r9r0r1r2r@r�rrArCrvrr�r/ZFS_NONASCII�	character�fsdecode�fsencode�UnicodeErrorZTESTFN_UNICODEZunicodedata�	normalize�getfilesystemencodingZTESTFN_ENCODINGZTESTFN_UNENCODABLEZgetwindowsversion�encode�UnicodeEncodeErrorr��decode�UnicodeDecodeErrorZTESTFN_UNDECODABLEZTESTFN_NONASCIIr3rr]r}r2r5rr�rKr�r�r�r�ZTEST_SUPPORT_DIRr:r�r\rrr[rHr&rI�objectrdr�rRr�r�rSr�abc�MutableMappingrTr�r'r�r�r(r�r)r*r+r�rrrr�r�r�r�r�r�r�r�r�r�r�rUr\r�r�rZ_4GrrrYr	r3r4r,rrr>r5r!r%r?r"rBr*r+r-r2r3r<r5r7rAr-rDZMISSING_C_DOCSTRINGSZHAVE_DOCSTRINGSZrequires_docstringsr.rHrIZenvironment_alteredrNrOrPrTrLrQrWrVrbZskipIfZrequires_type_collectingrcrdrfrgrMrXrrrr/rzr|r8r~rr<r=rZr�r�r�r^r�rDr�r_r�r�r�rdrdrdre�<module>s�











2	
!

J			>%	


%2' 5M		



$
#
0







(




"
#
	"
:_";'support/__pycache__/script_helper.cpython-36.opt-1.pyc000064400000015702150532443020016723 0ustar003

Ow�h�)�@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZmZdadd�ZGdd�dejdd#��Zdd�Zd
d�Zdd�Zdd�Zejejd�dd�Zdd�Zd$dd�Zd%dd�Zd&dd�Zd'd!d"�ZdS)(�N)�source_from_cache)�make_legacy_pyc�strip_python_stderrcCsVtdkrRdtjkrdadSytjtjdddg�Wntjk
rLdaYnXdatS)a 
    Returns True if our sys.executable interpreter requires environment
    variables in order to be able to run at all.

    This is designed to be used with @unittest.skipIf() to annotate tests
    that need to use an assert_python*() function to launch an isolated
    mode (-I) or no environment mode (-E) sub-interpreter process.

    A normal build & test does not run into this situation but it can happen
    when trying to run the standard library test suite from an interpreter that
    doesn't have an obvious home with Python's current home finding logic.

    Setting PYTHONHOME is one way to get most of the testsuite to run in that
    situation.  PYTHONPATH or PYTHONUSERSITE are other common environment
    variables that might impact whether or not the interpreter can start.
    NZ
PYTHONHOMETz-Ez-czimport sys; sys.exit(0)F)�$__cached_interp_requires_environment�os�environ�
subprocessZ
check_call�sys�
executableZCalledProcessError�rr�2/usr/lib64/python3.6/test/support/script_helper.py� interpreter_requires_environments


r
c@seZdZdZdd�ZdS)�_PythonRunResultz2Helper for reporting Python subprocess run resultscCs�d	}|j|j}}t|�|kr0d||d�}t|�|krNd||d�}|jdd�j�}|jdd�j�}td|j|||f��dS)
z4Provide helpful details about failed subcommand runs�P�ds(... truncated stdout ...)Ns(... truncated stderr ...)�ascii�replacezRProcess return code is %d
command line: %r

stdout:
---
%s
---

stderr:
---
%s
---i@)�out�err�len�decode�rstrip�AssertionError�rc)�self�cmd_line�maxlenrrrrr�fail>sz_PythonRunResult.failN)�__name__�
__module__�__qualname__�__doc__rrrrrr;srrrrc
Ost�}d|kr|jd�}n|o$|}tjddg}|rB|jd�n|rX|rX|jd�|jdd�r�i}tjdkr�tjd|d<n
tjj�}d	|kr�d
|d	<|j	|�|j
|�tj|tj
tj
tj
|d�}|�*z|j�\}}Wd|j�tj�XWdQRX|j}	t|�}t|	||�|fS)NZ
__isolatedz-XZfaulthandlerz-Iz-EZ
__cleanenvZwin32Z
SYSTEMROOT�TERM�)�stdin�stdout�stderr�env)r
�popr	r
�append�platformrr�copy�update�extendr�Popen�PIPEZcommunicate�kill�_cleanup�
returncoderr)
�args�env_varsZenv_required�isolatedrr'�procrrrrrr�run_python_until_end[s:





r7cOs4t||�\}}|jr|s&|jr0|r0|j|�|S)N)r7rr)Zexpected_successr3r4�resrrrr�_assert_python�s
r9cOstd|�|�S)a|
    Assert that running the interpreter with `args` and optional environment
    variables `env_vars` succeeds (rc == 0) and return a (return code, stdout,
    stderr) tuple.

    If the __cleanenv keyword is set, env_vars is used as a fresh environment.

    Python is started in isolated mode (command line option -I),
    except if the __isolated keyword is set to False.
    T)T)r9)r3r4rrr�assert_python_ok�sr:cOstd|�|�S)z�
    Assert that running the interpreter with `args` and optional environment
    variables `env_vars` fails (rc != 0) and return a (return code, stdout,
    stderr) tuple.

    See assert_python_ok() for more options.
    F)F)r9)r3r4rrr�assert_python_failure�sr;)r%r&cOsXtjg}t�s|jd�|j|�|jdttj��}d|d<t	j
|ft	j||d�|��S)z�Run a Python subprocess with the given arguments.

    kw is extra keyword args to pass to subprocess.Popen. Returns a Popen
    object.
    z-Er'Zvt100r")r$r%r&)r	r
r
r)r-�
setdefault�dictrrrr.r/)r%r&r3�kwrr'rrr�spawn_python�s

r?cCs2|jj�|jj�}|jj�|j�tj�|S)z?Run the given Popen process until completion and return stdout.)r$�closer%�read�waitrr1)�p�datarrr�kill_python�s


rEFcCsP|}|s|tjd7}tjj||�}t|ddd�}|j|�|j�tj�|S)N�py�wzutf-8)�encoding)	r�extsep�path�join�open�writer@�	importlib�invalidate_caches)Z
script_dir�script_basename�sourceZomit_suffixZscript_filename�script_nameZscript_filerrr�make_script�s
rSc	Cs�|tjd}tjj||�}tj|d�}|dkr~|jtj�}t|�dkrr|ddkrrt	t
|��}tjj|�}|}ntjj|�}|j||�|j
�|tjj||�fS)N�ziprG��__pycache__���)rrIrJrK�zipfile�ZipFile�split�seprrr�basenamerMr@)	�zip_dir�zip_basenamerRZname_in_zip�zip_filename�zip_name�zip_file�partsZ
legacy_pycrrr�make_zip_script�srcr#cCstj|�t|d|�dS)N�__init__)r�mkdirrS)Zpkg_dirZinit_sourcerrr�make_pkg�s
rf�cs0g}t|dd�}|j|�tjj|�}	t|||�}
|j|
�|rjtj|dd�}tj|
dd�}
|j||
f��fdd�td|d�D�}tjj	|d
tjj|
��}|tj
d}
tjj	||
�}tj|d	�}x&|D]}tjj	||	�}|j
||�q�W|j
|
|�|j�x|D]}tj|��q
W|tjj	||�fS)Nrdr#T)�doraisecsg|]}tjj�g|��qSr)rr[rK)�.0�i)�pkg_namerr�
<listcomp>�sz make_zip_pkg.<locals>.<listcomp>rgrTrG���)rSr)rrJr\�
py_compile�compiler-�rangerKrIrXrYrMr@�unlink)r]r^rkrPrQZdepthZcompiledrqZ	init_nameZ
init_basenamerRZ	pkg_namesZscript_name_in_zipr_r`ra�nameZinit_name_in_zipr)rkr�make_zip_pkg�s.



rs)rrr)F)N)r#)rgF) �collectionsrNr	rZos.pathZtempfilerrn�
contextlibZshutilrX�importlib.utilrZtest.supportrrrr
�
namedtuplerr7r9r:r;r/ZSTDOUTr?rErSrcrfrsrrrr�<module>s4$3




support/__pycache__/script_helper.cpython-36.pyc000064400000015702150532443020015764 0ustar003

Ow�h�)�@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZmZdadd�ZGdd�dejdd#��Zdd�Zd
d�Zdd�Zdd�Zejejd�dd�Zdd�Zd$dd�Zd%dd�Zd&dd�Zd'd!d"�ZdS)(�N)�source_from_cache)�make_legacy_pyc�strip_python_stderrcCsVtdkrRdtjkrdadSytjtjdddg�Wntjk
rLdaYnXdatS)a 
    Returns True if our sys.executable interpreter requires environment
    variables in order to be able to run at all.

    This is designed to be used with @unittest.skipIf() to annotate tests
    that need to use an assert_python*() function to launch an isolated
    mode (-I) or no environment mode (-E) sub-interpreter process.

    A normal build & test does not run into this situation but it can happen
    when trying to run the standard library test suite from an interpreter that
    doesn't have an obvious home with Python's current home finding logic.

    Setting PYTHONHOME is one way to get most of the testsuite to run in that
    situation.  PYTHONPATH or PYTHONUSERSITE are other common environment
    variables that might impact whether or not the interpreter can start.
    NZ
PYTHONHOMETz-Ez-czimport sys; sys.exit(0)F)�$__cached_interp_requires_environment�os�environ�
subprocessZ
check_call�sys�
executableZCalledProcessError�rr�2/usr/lib64/python3.6/test/support/script_helper.py� interpreter_requires_environments


r
c@seZdZdZdd�ZdS)�_PythonRunResultz2Helper for reporting Python subprocess run resultscCs�d	}|j|j}}t|�|kr0d||d�}t|�|krNd||d�}|jdd�j�}|jdd�j�}td|j|||f��dS)
z4Provide helpful details about failed subcommand runs�P�ds(... truncated stdout ...)Ns(... truncated stderr ...)�ascii�replacezRProcess return code is %d
command line: %r

stdout:
---
%s
---

stderr:
---
%s
---i@)�out�err�len�decode�rstrip�AssertionError�rc)�self�cmd_line�maxlenrrrrr�fail>sz_PythonRunResult.failN)�__name__�
__module__�__qualname__�__doc__rrrrrr;srrrrc
Ost�}d|kr|jd�}n|o$|}tjddg}|rB|jd�n|rX|rX|jd�|jdd�r�i}tjdkr�tjd|d<n
tjj�}d	|kr�d
|d	<|j	|�|j
|�tj|tj
tj
tj
|d�}|�*z|j�\}}Wd|j�tj�XWdQRX|j}	t|�}t|	||�|fS)NZ
__isolatedz-XZfaulthandlerz-Iz-EZ
__cleanenvZwin32Z
SYSTEMROOT�TERM�)�stdin�stdout�stderr�env)r
�popr	r
�append�platformrr�copy�update�extendr�Popen�PIPEZcommunicate�kill�_cleanup�
returncoderr)
�args�env_varsZenv_required�isolatedrr'�procrrrrrr�run_python_until_end[s:





r7cOs4t||�\}}|jr|s&|jr0|r0|j|�|S)N)r7rr)Zexpected_successr3r4�resrrrr�_assert_python�s
r9cOstd|�|�S)a|
    Assert that running the interpreter with `args` and optional environment
    variables `env_vars` succeeds (rc == 0) and return a (return code, stdout,
    stderr) tuple.

    If the __cleanenv keyword is set, env_vars is used as a fresh environment.

    Python is started in isolated mode (command line option -I),
    except if the __isolated keyword is set to False.
    T)T)r9)r3r4rrr�assert_python_ok�sr:cOstd|�|�S)z�
    Assert that running the interpreter with `args` and optional environment
    variables `env_vars` fails (rc != 0) and return a (return code, stdout,
    stderr) tuple.

    See assert_python_ok() for more options.
    F)F)r9)r3r4rrr�assert_python_failure�sr;)r%r&cOsXtjg}t�s|jd�|j|�|jdttj��}d|d<t	j
|ft	j||d�|��S)z�Run a Python subprocess with the given arguments.

    kw is extra keyword args to pass to subprocess.Popen. Returns a Popen
    object.
    z-Er'Zvt100r")r$r%r&)r	r
r
r)r-�
setdefault�dictrrrr.r/)r%r&r3�kwrr'rrr�spawn_python�s

r?cCs2|jj�|jj�}|jj�|j�tj�|S)z?Run the given Popen process until completion and return stdout.)r$�closer%�read�waitrr1)�p�datarrr�kill_python�s


rEFcCsP|}|s|tjd7}tjj||�}t|ddd�}|j|�|j�tj�|S)N�py�wzutf-8)�encoding)	r�extsep�path�join�open�writer@�	importlib�invalidate_caches)Z
script_dir�script_basename�sourceZomit_suffixZscript_filename�script_nameZscript_filerrr�make_script�s
rSc	Cs�|tjd}tjj||�}tj|d�}|dkr~|jtj�}t|�dkrr|ddkrrt	t
|��}tjj|�}|}ntjj|�}|j||�|j
�|tjj||�fS)N�ziprG��__pycache__���)rrIrJrK�zipfile�ZipFile�split�seprrr�basenamerMr@)	�zip_dir�zip_basenamerRZname_in_zip�zip_filename�zip_name�zip_file�partsZ
legacy_pycrrr�make_zip_script�srcr#cCstj|�t|d|�dS)N�__init__)r�mkdirrS)Zpkg_dirZinit_sourcerrr�make_pkg�s
rf�cs0g}t|dd�}|j|�tjj|�}	t|||�}
|j|
�|rjtj|dd�}tj|
dd�}
|j||
f��fdd�td|d�D�}tjj	|d
tjj|
��}|tj
d}
tjj	||
�}tj|d	�}x&|D]}tjj	||	�}|j
||�q�W|j
|
|�|j�x|D]}tj|��q
W|tjj	||�fS)Nrdr#T)�doraisecsg|]}tjj�g|��qSr)rr[rK)�.0�i)�pkg_namerr�
<listcomp>�sz make_zip_pkg.<locals>.<listcomp>rgrTrG���)rSr)rrJr\�
py_compile�compiler-�rangerKrIrXrYrMr@�unlink)r]r^rkrPrQZdepthZcompiledrqZ	init_nameZ
init_basenamerRZ	pkg_namesZscript_name_in_zipr_r`ra�nameZinit_name_in_zipr)rkr�make_zip_pkg�s.



rs)rrr)F)N)r#)rgF) �collectionsrNr	rZos.pathZtempfilerrn�
contextlibZshutilrX�importlib.utilrZtest.supportrrrr
�
namedtuplerr7r9r:r;r/ZSTDOUTr?rErSrcrfrsrrrr�<module>s4$3




support/__pycache__/testresult.cpython-36.pyc000064400000017130150532443020015334 0ustar003


 \
�@s6dZddlZddlZddlZddlZddlZddlZddljj	Z
ddlmZGdd�dej�Z
Gdd�d�Zdd	d
�Zddd�Zed
k�r2Gdd�dej�Zej�Zejeje��ej�Zeedd�ejD���Zeej�Zeje�Z e!dej"��e!ddd�x(e
j#e j$��D]Z%e!e%j&�dd��qWe!�dS)z=Test runner and result class for the regression test suite.

�N)�datetimecs�eZdZdddZdddZ�fdd�Zedd��Z�fd	d
�Zd$dd
�Z	dd�Z
edd��Z�fdd�Z�fdd�Z
�fdd�Z�fdd�Z�fdd�Z�fdd�Zdd�Zd d!�Zd"d#�Z�ZS)%�RegressionTestResult�=�F�
�-cs\t�j||dd�d|_tjd�|_|jjdtj�j	d��d|_
d|_g|_t
|�|_dS)Nr)�stream�descriptions�	verbosityTZ	testsuite�start� )�super�__init__�buffer�ETZElement�_RegressionTestResult__suite�setrZutcnowZ	isoformat�_RegressionTestResult__e�!_RegressionTestResult__start_timeZ_RegressionTestResult__results�bool�_RegressionTestResult__verbose)�selfrr	r
)�	__class__��//usr/lib64/python3.6/test/support/testresult.pyrszRegressionTestResult.__init__cCsLy
|j}Wntk
r"t|�SXy|�Stk
rBt|�SXt|�S)N)�id�AttributeError�str�	TypeError�repr)�cls�testZtest_idrrrZ__getIds


zRegressionTestResult.__getIdcsVt�j|�tj|jd�|_}tj�|_|j	rR|j
j|j|��d��|j
j
�dS)NZtestcasez ... )r
�	startTestr�
SubElementrr�time�perf_counterrrr�write�getDescription�flush)rr!�e)rrrr"+s
zRegressionTestResult.startTestFcKsP|j}d|_|dkrdS|jd|jd|j|���|jd|jdd��|jd|jdd��|jrz|jdtj�|jd��|r�|jdk	r�|jj�j	�}|t
j|d�_|j
dk	r�|j
j�j	�}|t
j|d	�_x�|j�D]t\}}|s�|r�q�t
j||�}	t|d
��r>xD|j�D],\}
}|
�r,|	j|
t|��n
t|�|	_�qWq�t|�|	_q�WdS)N�nameZstatus�run�resultZ	completedr$z0.6fz
system-outz
system-err�items)rr�pop�_RegressionTestResult__getIdrr$r%Z_stdout_buffer�getvalue�rstriprr#�textZ_stderr_bufferr-�hasattrr)rr!Zcapture�argsr)�stdout�stderr�k�vZe2Zk2Zv2rrr�_add_result3s4

z RegressionTestResult._add_resultcCs|jr|jj|�d��dS)Nr)rrr&)r�cZwordrrrZ__writeSszRegressionTestResult.__writecCslt|t�r0|jdkr|j}q8|j�d|j��}nt|�}tj||d�}tj|||�}|dj|�dj|�d�S)N�builtins�.�)�type�messager=)�
isinstancer>�
__module__�__name__r�	traceback�format_exception�join)r Zerr_typeZ	err_valueZerr_tb�typename�msg�tbrrrZ__makeErrorDictWs

z$RegressionTestResult.__makeErrorDictcs4|j|d|j|�d�t�j||�|jdd�dS)NT)�error�E�ERROR)r9�$_RegressionTestResult__makeErrorDictr
�addError�_RegressionTestResult__write)rr!�err)rrrrMjszRegressionTestResult.addErrorcs4|j|d|j|�d�t�j||�|jdd�dS)NT)�output�xzexpected failure)r9rLr
�addExpectedFailurerN)rr!rO)rrrrRosz'RegressionTestResult.addExpectedFailurecs4|j|d|j|�d�t�j||�|jdd�dS)NT)Zfailure�F�FAIL)r9rLr
�
addFailurerN)rr!rO)rrrrUtszRegressionTestResult.addFailurecs2|j||d�t�j||�|jdd|���dS)N)Zskipped�Szskipped )r9r
�addSkiprN)rr!�reason)rrrrWyszRegressionTestResult.addSkipcs&|j|�t�j|�|jdd�dS)Nr<�ok)r9r
�
addSuccessrN)rr!)rrrrZ~s
zRegressionTestResult.addSuccesscs*|j|dd�t�j|�|jdd�dS)NZUNEXPECTED_SUCCESS)Zoutcome�uzunexpected success)r9r
�addUnexpectedSuccessrN)rr!)rrrr\�sz)RegressionTestResult.addUnexpectedSuccesscCs2|jr|jjd�|jd|j�|jd|j�dS)NrrKrT)rrr&�printErrorList�errors�failures)rrrr�printErrors�sz RegressionTestResult.printErrorscCs`xZ|D]R\}}|jj|j�|jj|�d|j|��d��|jj|j�|jjd|�qWdS)Nz: rz%s
)rr&�
separator1r'�
separator2)rZflavorr^r!rOrrrr]�s
z#RegressionTestResult.printErrorListcCsH|j}|jdt|j��|jdtt|j���|jdtt|j���|S)NZtestsr^r_)rrrZtestsRun�lenr^r_)rr)rrr�get_xml_element�s
z$RegressionTestResult.get_xml_element)F)rBrA�__qualname__rarbr�classmethodr/r"r9rNrLrMrRrUrWrZr\r`r]rd�
__classcell__rr)rrrs"
 rc@seZdZddd�Zdd�ZdS)�QuietRegressionTestRunnerFcCst|dd�|_||j_dS)Nr)rr,r)rrrrrrr�sz"QuietRegressionTestRunner.__init__cCs||j�|jS)N)r,)rr!rrrr+�s
zQuietRegressionTestRunner.runN)F)rBrArerr+rrrrrh�s
rhFcCs&|rtjtjt||d�Stjt|d�S)N)Zresultclassrr
)r)�	functools�partial�unittestZTextTestRunnerrrh)r
rrrr�get_test_runner_class�srlcCst||�|�S)N)rl)rr
Zcapture_outputrrr�get_test_runner�srm�__main__c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�	TestTestscCsdS)Nr)rrrr�	test_pass�szTestTests.test_passcCstjd�dS)Ng�?)r$Zsleep)rrrr�test_pass_slow�szTestTests.test_pass_slowcCs*tdtjd�tdtjd�|jd�dS)Nr5)�filer6zfailure message)�print�sysr5r6Zfail)rrrr�	test_fail�szTestTests.test_failcCs(tdtjd�tdtjd�td��dS)Nr5)rrr6z
error message)rsrtr5r6�RuntimeError)rrrr�
test_error�szTestTests.test_errorN)rBrArerprqrurwrrrrro�sroccs|]}|dkVqdS)z-vNr)�.0�arrr�	<genexpr>�srzzOutput:zXML: r=)�end)F)F)'�__doc__ri�iortr$rCrkZxml.etree.ElementTreeZetreeZElementTreerrZTextTestResultrrhrlrmrBZTestCaseroZ	TestSuiteZsuiteZaddTestZ	makeSuite�StringIOr�sum�argvZ
runner_clsr5Zrunnerr+r,rsr0Ztostringlistrd�s�decoderrrr�<module>s4
	




support/__pycache__/testresult.cpython-36.opt-1.pyc000064400000017130150532443020016273 0ustar003


 \
�@s6dZddlZddlZddlZddlZddlZddlZddljj	Z
ddlmZGdd�dej�Z
Gdd�d�Zdd	d
�Zddd�Zed
k�r2Gdd�dej�Zej�Zejeje��ej�Zeedd�ejD���Zeej�Zeje�Z e!dej"��e!ddd�x(e
j#e j$��D]Z%e!e%j&�dd��qWe!�dS)z=Test runner and result class for the regression test suite.

�N)�datetimecs�eZdZdddZdddZ�fdd�Zedd��Z�fd	d
�Zd$dd
�Z	dd�Z
edd��Z�fdd�Z�fdd�Z
�fdd�Z�fdd�Z�fdd�Z�fdd�Zdd�Zd d!�Zd"d#�Z�ZS)%�RegressionTestResult�=�F�
�-cs\t�j||dd�d|_tjd�|_|jjdtj�j	d��d|_
d|_g|_t
|�|_dS)Nr)�stream�descriptions�	verbosityTZ	testsuite�start� )�super�__init__�buffer�ETZElement�_RegressionTestResult__suite�setrZutcnowZ	isoformat�_RegressionTestResult__e�!_RegressionTestResult__start_timeZ_RegressionTestResult__results�bool�_RegressionTestResult__verbose)�selfrr	r
)�	__class__��//usr/lib64/python3.6/test/support/testresult.pyrszRegressionTestResult.__init__cCsLy
|j}Wntk
r"t|�SXy|�Stk
rBt|�SXt|�S)N)�id�AttributeError�str�	TypeError�repr)�cls�testZtest_idrrrZ__getIds


zRegressionTestResult.__getIdcsVt�j|�tj|jd�|_}tj�|_|j	rR|j
j|j|��d��|j
j
�dS)NZtestcasez ... )r
�	startTestr�
SubElementrr�time�perf_counterrrr�write�getDescription�flush)rr!�e)rrrr"+s
zRegressionTestResult.startTestFcKsP|j}d|_|dkrdS|jd|jd|j|���|jd|jdd��|jd|jdd��|jrz|jdtj�|jd��|r�|jdk	r�|jj�j	�}|t
j|d�_|j
dk	r�|j
j�j	�}|t
j|d	�_x�|j�D]t\}}|s�|r�q�t
j||�}	t|d
��r>xD|j�D],\}
}|
�r,|	j|
t|��n
t|�|	_�qWq�t|�|	_q�WdS)N�nameZstatus�run�resultZ	completedr$z0.6fz
system-outz
system-err�items)rr�pop�_RegressionTestResult__getIdrr$r%Z_stdout_buffer�getvalue�rstriprr#�textZ_stderr_bufferr-�hasattrr)rr!Zcapture�argsr)�stdout�stderr�k�vZe2Zk2Zv2rrr�_add_result3s4

z RegressionTestResult._add_resultcCs|jr|jj|�d��dS)Nr)rrr&)r�cZwordrrrZ__writeSszRegressionTestResult.__writecCslt|t�r0|jdkr|j}q8|j�d|j��}nt|�}tj||d�}tj|||�}|dj|�dj|�d�S)N�builtins�.�)�type�messager=)�
isinstancer>�
__module__�__name__r�	traceback�format_exception�join)r Zerr_typeZ	err_valueZerr_tb�typename�msg�tbrrrZ__makeErrorDictWs

z$RegressionTestResult.__makeErrorDictcs4|j|d|j|�d�t�j||�|jdd�dS)NT)�error�E�ERROR)r9�$_RegressionTestResult__makeErrorDictr
�addError�_RegressionTestResult__write)rr!�err)rrrrMjszRegressionTestResult.addErrorcs4|j|d|j|�d�t�j||�|jdd�dS)NT)�output�xzexpected failure)r9rLr
�addExpectedFailurerN)rr!rO)rrrrRosz'RegressionTestResult.addExpectedFailurecs4|j|d|j|�d�t�j||�|jdd�dS)NT)Zfailure�F�FAIL)r9rLr
�
addFailurerN)rr!rO)rrrrUtszRegressionTestResult.addFailurecs2|j||d�t�j||�|jdd|���dS)N)Zskipped�Szskipped )r9r
�addSkiprN)rr!�reason)rrrrWyszRegressionTestResult.addSkipcs&|j|�t�j|�|jdd�dS)Nr<�ok)r9r
�
addSuccessrN)rr!)rrrrZ~s
zRegressionTestResult.addSuccesscs*|j|dd�t�j|�|jdd�dS)NZUNEXPECTED_SUCCESS)Zoutcome�uzunexpected success)r9r
�addUnexpectedSuccessrN)rr!)rrrr\�sz)RegressionTestResult.addUnexpectedSuccesscCs2|jr|jjd�|jd|j�|jd|j�dS)NrrKrT)rrr&�printErrorList�errors�failures)rrrr�printErrors�sz RegressionTestResult.printErrorscCs`xZ|D]R\}}|jj|j�|jj|�d|j|��d��|jj|j�|jjd|�qWdS)Nz: rz%s
)rr&�
separator1r'�
separator2)rZflavorr^r!rOrrrr]�s
z#RegressionTestResult.printErrorListcCsH|j}|jdt|j��|jdtt|j���|jdtt|j���|S)NZtestsr^r_)rrrZtestsRun�lenr^r_)rr)rrr�get_xml_element�s
z$RegressionTestResult.get_xml_element)F)rBrA�__qualname__rarbr�classmethodr/r"r9rNrLrMrRrUrWrZr\r`r]rd�
__classcell__rr)rrrs"
 rc@seZdZddd�Zdd�ZdS)�QuietRegressionTestRunnerFcCst|dd�|_||j_dS)Nr)rr,r)rrrrrrr�sz"QuietRegressionTestRunner.__init__cCs||j�|jS)N)r,)rr!rrrr+�s
zQuietRegressionTestRunner.runN)F)rBrArerr+rrrrrh�s
rhFcCs&|rtjtjt||d�Stjt|d�S)N)Zresultclassrr
)r)�	functools�partial�unittestZTextTestRunnerrrh)r
rrrr�get_test_runner_class�srlcCst||�|�S)N)rl)rr
Zcapture_outputrrr�get_test_runner�srm�__main__c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�	TestTestscCsdS)Nr)rrrr�	test_pass�szTestTests.test_passcCstjd�dS)Ng�?)r$Zsleep)rrrr�test_pass_slow�szTestTests.test_pass_slowcCs*tdtjd�tdtjd�|jd�dS)Nr5)�filer6zfailure message)�print�sysr5r6Zfail)rrrr�	test_fail�szTestTests.test_failcCs(tdtjd�tdtjd�td��dS)Nr5)rrr6z
error message)rsrtr5r6�RuntimeError)rrrr�
test_error�szTestTests.test_errorN)rBrArerprqrurwrrrrro�sroccs|]}|dkVqdS)z-vNr)�.0�arrr�	<genexpr>�srzzOutput:zXML: r=)�end)F)F)'�__doc__ri�iortr$rCrkZxml.etree.ElementTreeZetreeZElementTreerrZTextTestResultrrhrlrmrBZTestCaseroZ	TestSuiteZsuiteZaddTestZ	makeSuite�StringIOr�sum�argvZ
runner_clsr5Zrunnerr+r,rsr0Ztostringlistrd�s�decoderrrr�<module>s4
	




support/__pycache__/__init__.cpython-36.opt-2.pyc000064400000160126150532443020015621 0ustar003

Ow�h����@sX
edkred��ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
ZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z!ddl"Z"ddl#m$Z$yddl%Z%ddl&Z&Wnek
�r>dZ%dZ&YnXyddl'Z(Wnek
�rfdZ(YnXyddl)Z)Wnek
�r�dZ)YnXyddl*Z*Wnek
�r�dZ*YnXyddl+Z+Wnek
�r�dZ+YnXyddl,Z,Wnek
�rdZ,YnXyddl-Z-Wnek
�r.dZ-YnXyddl.Z.Wnek
�rVdZ.YnXdddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dag\Z/Gdbd�de0�Z1Gdcd�de1�Z2Gddd
�d
e1�Z3Gded�dej4�Z5ej6�dedgdh��Z7�dffdj�dkd�Z8dldm�Z9dndo�Z:dpd<�Z;dqd=�Z<ffdifdrd�Z=dsd8�Z>dZ?dZ@daAdaBdZCdiZDdaEdtd�ZFdud�ZGdvd�ZHdwdx�ZIejjJdy��r*�dgdzd{�ZKd|d}�ZLd~d�ZMd�d��ZNd�d��ZOnejPZLejQZMd�d��ZNd�d��ZOd�d�ZPd�d��ZQd�d�ZRd�d��ZSd�d�ZTd�d��ZUd�d"�ZV�dhd�d#�ZWd�d��ZXd�d$�ZYd�d%�ZZd�d&�Z[�did�d'�Z\d�Z]d�Z^ej_ej`fd�dI�Zae]fd�dJ�Zbd�dL�Zcd�d��Zded�Zed�d��Zf�dlZg�doZhejiejjkd��jJd��d��Zlejie)d��Zmejie*d��Znejie+d��Zoejie,d��ZpejjJd��Zqejrd��Zsesdk	�otesdkZtejd�k�r�et�r�d�nd�ZundZuejvd�k�r�d�Zwnd�Zwd�jxewejy��ZwdZzxL�dpD]BZ{yej|ej}e{��e{k�r�e~�Wne~k
�rYnXe{ZzP�q�Wewd�Zejd�k�r6ddl�Z�e�j�d�e�Zej��Z�dZ�ejvd�k�r�ej��jd�k�r�ewd�Z�ye�j�e��Wne�k
�r�YnXe�d�e�e�f�dZ�nBejd�k�r�yd�j�e��Wn&e�k
�r�ewd�j�e�dƃZ�YnXdZ�xF�dqD]<Zvyevj�e��Wn&e�k
�r(ej}ew�evZ�PYnX�q�Wez�rDewd�ezZ�ndZ�ej��Z�diZ�diZ�ej6�drd�d̈́�Z�ej6�dsd�dτ�Z�ej6�dtd�d��Z�e�ed҃�r�ej6d�dM��Z�ej�j�ej�j�e���Z�ej�j�e��Z�ej�j�e�dԃZ��dud�d�Z�d�d�Z�d�d]�Z�d�dلZ�dddڜd�d(�Z�d�dK�Z�Gd�dބd�e��Z��dvd�d�Z�ej6d�dT��Z�ej6d�e�difd�d��Z�ej6d�dU��Z�Gd�d�de��Z�Gd�dV�dVej�j��Z�Gd�d�d�e��Z�Gd�d)�d)e��Z�e�e�ej�d�Z�e�e�ej�d�Z�e�e�ej�d�Z�ej6d�fd�d�d-��Z�ej6d�d��Z�d�d�Z�d�d�Z�d�d�Z�d�d��Z�ej6d�d���Z�d�d��Z�d�Z�d�Z�e�ed���	rHd�e�Z�d�Z�e�d�Z��d�d�Zd�d�ZÐdwZĐdxZŐd�d�ZƐddW�Zǐd	d^�ZȐdyZ�d�e�Z�d�e�Z�d�e�Z�ej�Zΐd
d[�Z�G�d�d��d�ZАdz�d
d5�Zѐdd6�Z�G�dd.�d.�ZӐd�d�ZԐd�d�ZՐdd@�Z֐dd7�Zאd{�d�d�Z�daِddA�Zڐd�d�ZېddD�Zܐd�d�Zݐd�d�Zސd �d!�Zߐd"�d#�Z�da�da�d$�d%�Z�d&�d'�Z�d(�d)�Z�d*d/�Z�d+�d,�Z�e܃�
o�ejd�k�
o�ejr�d-�Z�e�j�dk	�oe�Z�ejie�d.�Z�d|�d/d0�Z�d0�d1�Z�d2�d3�Z�diZ�d4dP�Z�d5dQ�Z�d6dR�Z�ej6�d}�d8�d9��Z�d:dN�Z�ej6�d~�d;dS��Z�ej6�d<dY��Z�ej6�d=dX��Z��d>�d?�Z�ej�e�e�d@��dA�Z��dB�dC�Z��dD�dE�Z�G�dFdO�dOej�j��Z�G�dGdZ�dZe���Zd�a�dHd ��Z�dId1��Zd�a�dJ�dK��Z�dLd:��Z�dM�dN��Z�dOd!��Zf�dP��dQd>��Z	dfff�dRd?��Z
G�dSd\�d\��Z�dT�dU��Z�dV�dW��Z
ff�dX�dY��Zgf�dZd`��Zd�a�d[dF��Zej6�d\�d]���Z�d^da��ZG�d_�d`��d`��ZG�da�db��db��Zej6�dc�dd���ZdS(ztest.supportz.support must be imported from the test package�N�)�get_test_runner�
PIPE_MAX_SIZE�verbose�
max_memuse�
use_resources�failfast�Error�
TestFailed�
TestDidNotRun�ResourceDenied�
import_module�import_fresh_module�CleanImport�unload�forget�record_original_stdout�get_original_stdout�captured_stdout�captured_stdin�captured_stderr�TESTFN�SAVEDCWD�unlink�rmtree�temp_cwd�findfile�create_empty_file�can_symlink�fs_is_case_insensitive�is_resource_enabled�requires�requires_freebsd_version�requires_linux_version�requires_mac_ver�requires_hashdigest�check_syntax_error�TransientResource�time_out�socket_peer_reset�ioerror_peer_reset�transient_internet�BasicTestRunner�run_unittest�run_doctest�skip_unless_symlink�
requires_gzip�requires_bz2�
requires_lzma�
bigmemtest�bigaddrspacetest�cpython_only�
get_attribute�requires_IEEE_754�skip_unless_xattr�
requires_zlib�anticipate_failure�load_package_tests�detect_api_mismatch�check__all__�requires_android_level�requires_multiprocessing_queue�	is_jython�
is_android�check_impl_detail�
unix_shell�setswitchinterval�HOST�IPV6_ENABLED�find_unused_port�	bind_port�open_urlresource�bind_unix_socket�
temp_umask�
reap_children�TestHandler�threading_setup�threading_cleanup�reap_threads�
start_threads�check_warnings�check_no_resource_warning�EnvironmentVarGuard�run_with_locale�	swap_item�	swap_attr�Matcher�set_memlimit�SuppressCrashReport�sortdict�run_with_tz�PGO�missing_compiler_executable�fd_countc@seZdZdS)r	N)�__name__�
__module__�__qualname__�rcrc�-/usr/lib64/python3.6/test/support/__init__.pyr	|sc@seZdZdS)r
N)r`rarbrcrcrcrdr
sc@seZdZdS)rN)r`rarbrcrcrcrdr�sc@seZdZdS)rN)r`rarbrcrcrcrdr�sTccs8|r.tj��tjddt�dVWdQRXndVdS)N�ignorez.+ (module|package))�warnings�catch_warnings�filterwarnings�DeprecationWarning)rercrcrd�_ignore_deprecated_imports�s
rjF)�required_oncCsft|��Ty
tj|�Stk
rV}z&tjjt|��r8�tj	t
|���WYdd}~XnXWdQRXdS)N)rj�	importlibr
�ImportError�sys�platform�
startswith�tuple�unittest�SkipTest�str)�name�
deprecatedrk�msgrcrcrdr
�s	

cCs^|tjkrt|�tj|=x>ttj�D]0}||ks@|j|d�r&tj|||<tj|=q&WdS)N�.)rn�modules�
__import__�listrp)ru�orig_modules�modnamercrcrd�_save_and_remove_module�s
r~cCs>d}ytj|||<Wntk
r.d}YnXdtj|<|S)NTF)rnry�KeyError)rur|Zsavedrcrcrd�_save_and_block_module�s

r�cCs|r
tjSdd�S)NcSs|S)Nrc)�frcrcrd�<lambda>�sz$anticipate_failure.<locals>.<lambda>)rrZexpectedFailure)Z	conditionrcrcrdr:�scCsF|dkrd}tjjtjjtjjt���}|j|||d�}|j|�|S)Nztest*)Z	start_dirZ
top_level_dir�pattern)�os�path�dirname�__file__ZdiscoverZaddTests)Zpkg_dir�loaderZstandard_testsr�Ztop_dirZ
package_testsrcrcrdr;�s
cCs�t|���i}g}t||�zfyHx|D]}t||�q&Wx |D]}t||�s>|j|�q>Wtj|�}Wntk
r~d}YnXWdx|j�D]\}	}
|
tj	|	<q�Wx|D]}tj	|=q�WX|SQRXdS)N)
rjr~r��appendrlr
rm�itemsrnry)ruZfreshZblockedrvr|Znames_to_removeZ
fresh_nameZblocked_nameZfresh_moduleZ	orig_name�moduleZname_to_removercrcrdr�s$





cCs>yt||�}Wn&tk
r4tjd||f��YnX|SdS)Nzobject %r has no attribute %r)�getattr�AttributeErrorrrrs)�objruZ	attributercrcrdr6s
cCs|adS)N)�_original_stdout)�stdoutrcrcrdr0scCs
tptjS)N)r�rnr�rcrcrcrdr4scCs&ytj|=Wntk
r YnXdS)N)rnryr)rurcrcrdr7scGsny||�Stk
rh}zDtdkrHtd|jj|f�td|j|f�tj|tj�||�Sd}~XnXdS)N�z%s: %szre-run %s%r)	�OSErrorr�print�	__class__r`r��chmod�stat�S_IRWXU)r��func�args�errrcrcrd�
_force_run=sr��wincCs�||�|r|}ntjj|�\}}|p(d}d}x<|dkrjtj|�}|rJ|n||ksVdStj|�|d9}q0Wtjd|tdd�dS)Nrxg����MbP?g�?r�z)tests may fail, delete still pending for �)�
stacklevel)	r�r��split�listdir�time�sleeprf�warn�RuntimeWarning)r��pathname�waitallr�ru�timeout�Lrcrcrd�_waitforHs



r�cCsttj|�dS)N)r�r�r)�filenamercrcrd�_unlinkisr�cCsttj|�dS)N)r�r��rmdir)r�rcrcrd�_rmdirlsr�cs,�fdd��t�|dd�tdd�|�dS)Ncs�x�t|tj|�D]�}tjj||�}ytj|�j}Wn<tk
rn}z td||ft	j
d�d}WYdd}~XnXtj|�r�t
�|dd�t|tj|�qt|tj|�qWdS)Nz-support.rmtree(): os.lstat(%r) failed with %s)�filerT)r�)r�r�r�r��join�lstat�st_moder�r�rn�
__stderr__r��S_ISDIRr�r�r)r�ru�fullname�mode�exc)�
_rmtree_innerrcrdr�ps

z_rmtree.<locals>._rmtree_innerT)r�cSst|tj|�S)N)r�r�r�)�prcrcrdr�sz_rmtree.<locals>.<lambda>)r�)r�rc)r�rd�_rmtreeosr�c
Cs^yddl}Wntk
r Yn:X|jt|�d�}|jjj||t|��}|rZ|d|�S|S)Nrr�)�ctypesrmZcreate_unicode_buffer�len�windll�kernel32ZGetLongPathNameW)r�r��bufferZlengthrcrcrd�	_longpath�s
r�csFytj|�dStk
r"YnX�fdd���|�tj|�dS)Nc
s�x~t|tj|�D]l}tjj||�}ytj|�j}Wntk
rJd}YnXtj	|�rn�|�t|tj
|�qt|tj|�qWdS)Nr)r�r�r�r�r�r�r�r�r�r�r�r)r�rur�r�)r�rcrdr��s

z_rmtree.<locals>._rmtree_inner)�shutilrr�r�r�)r�rc)r�rdr��s
cCs|S)Nrc)r�rcrcrdr��scCs*yt|�Wnttfk
r$YnXdS)N)r��FileNotFoundError�NotADirectoryError)r�rcrcrdr�scCs&yt|�Wntk
r YnXdS)N)r�r�)r�rcrcrdr��sr�cCs&yt|�Wntk
r YnXdS)N)r�r�)r�rcrcrdr�scCsBtjj|�}tjjtjj|��}tjj||d�}tj||�|S)N�c)	rl�util�cache_from_sourcer�r�r��abspathr��rename)�sourceZpyc_fileZup_oneZ
legacy_pycrcrcrd�make_legacy_pyc�s
r�cCs\t|�xNtjD]D}tjj||d�}t|d�x dD]}ttjj||d��q8WqWdS)Nz.pyr��rr�)�optimization)r�rr�)	rrnr�r�r�rrlr�r�)r}r�r��optrcrcrdr�s
cs�ttd�rtjSd}tjjd�r�ddl�ddl�d}d}G�fdd�d�j�}�j	j
}|j�}|sj�j��|�}�j
j�}|j||�j|��j|��j|��}|s��j��t|j|@�s�d}n�tjdk�rVdd	lm}	m�m}
m}dd
lm}|	j|d��}
|
j�dk�rd}nFG�fd
d�d|�}|�}|
|�}|
j|�dk�sR|
j|�dk�rVd}|�s�y.ddlm}|�}|j�|j �|j!�Wn\t"k
�r�}z>t#|�}t$|�dk�r�|dd�d}dj%t&|�j'|�}WYdd}~XnX|t_(|t_tjS)N�resultr�rrcs.eZdZd�jjfd�jjfd�jjfgZdS)z*_is_gui_available.<locals>.USEROBJECTFLAGSZfInheritZ	fReserved�dwFlagsN)r`rarb�wintypesZBOOL�DWORD�_fields_rc)r�rcrd�USEROBJECTFLAGS�s

r�z,gui not available (WSF_VISIBLE flag not set)�darwin)�cdll�c_int�pointer�	Structure)�find_libraryZApplicationServicesz0gui tests cannot run without OS X window managercseZdZd�fd�fgZdS)z._is_gui_available.<locals>.ProcessSerialNumberZ
highLongOfPSNZlowLongOfPSNN)r`rarbr�rc)r�rcrd�ProcessSerialNumbersr�z#cannot run without OS X gui process)�Tk�2z [...]zTk unavailable due to {}: {}))�hasattr�_is_gui_availabler�rnrorpr�Zctypes.wintypesr�r�Zuser32ZGetProcessWindowStationZWinErrorr�r�ZGetUserObjectInformationWZbyrefZsizeof�boolr�r�r�r�Zctypes.utilr�ZLoadLibraryZCGMainDisplayIDZGetCurrentProcessZSetFrontProcessZtkinterr�Zwithdraw�updateZdestroy�	Exceptionrtr��format�typer`�reason)r�Z	UOI_FLAGSZWSF_VISIBLEr�Zdll�hZuofZneeded�resr�r�r�r�Zapp_servicesr�ZpsnZpsn_pr��root�eZ
err_stringrc)r�r�rdr��sh

r�cCstdkp|tkS)N)r)�resourcercrcrdr $scCs>t|�s |dkrd|}t|��|dkr:t�r:ttj��dS)Nz"Use of the %r resource not enabled�gui)r rr�r�)r�rwrcrcrdr!,scs��fdd�}|S)Ncs$tj�����fdd��}�|_|S)Nc
s�tj��krztj�jdd�d}yttt|jd���}Wntk
rLYn.X|�krzdjtt	���}t
jd�||f���||�S)N�-rrrxz(%s version %s or higher required, not %s)ro�system�releaser�rq�map�int�
ValueErrorr�rtrrrs)r��kw�version_txt�version�min_version_txt)r��min_version�sysnamercrd�wrapper=sz:_requires_unix_version.<locals>.decorator.<locals>.wrapper)�	functools�wrapsr�)r�r�)r�r�)r�rd�	decorator<sz)_requires_unix_version.<locals>.decoratorrc)r�r�r�rc)r�r�rd�_requires_unix_version5sr�cGs
td|�S)NZFreeBSD)r�)r�rcrcrdr"PscGs
td|�S)NZLinux)r�)r�rcrcrdr#Yscs�fdd�}|S)Ncs"tj����fdd��}�|_|S)Ncsxtjdkrntj�d}yttt|jd���}Wntk
rBYn,X|�krndjtt	���}t
jd||f���||�S)Nr�rrxz&Mac OS X %s or higher required, not %s)rnroZmac_verrqr�r�r�r�r�rtrrrs)r�r�r�r�r�)r�r�rcrdr�js
z4requires_mac_ver.<locals>.decorator.<locals>.wrapper)r�r�r�)r�r�)r�)r�rdr�isz#requires_mac_ver.<locals>.decoratorrc)r�r�rc)r�rdr$bscs��fdd�}|S)Ncstj�����fdd��}|S)NcsXy&�rtdk	rtj��n
tj��Wn&tk
rLtjd��d���YnX�||�S)Nz
hash digest 'z' is not available.)�_hashlib�new�hashlibr�rrrs)r��kwargs)�
digestnamer��opensslrcrdr��sz7requires_hashdigest.<locals>.decorator.<locals>.wrapper)r�r�)r�r�)r�r)r�rdr��sz&requires_hashdigest.<locals>.decoratorrc)r�rr�rc)r�rrdr%}s
z	127.0.0.1z::1cCs"tj||�}t|�}|j�~|S)N)�socketrH�close)�familyZsocktypeZtempsock�portrcrcrdrG�s
8cCs�|jtjkr�|jtjkr�ttd�r>|jtjtj�dkr>t	d��ttd�r~y |jtjtj
�dkrft	d��Wntk
r|YnXttd�r�|jtjtj
d�|j|df�|j�d}|S)N�SO_REUSEADDRrzHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets!�SO_REUSEPORTzHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!�SO_EXCLUSIVEADDRUSEr)rr�AF_INETr��SOCK_STREAMr�Z
getsockoptZ
SOL_SOCKETrr
rr�Z
setsockoptr�bindZgetsockname)�sock�hostrrcrcrdrH�s


cCs:y|j|�Wn&tk
r4|j�tjd��YnXdS)Nzcannot bind AF_UNIX sockets)r
�PermissionErrorrrrrs)rZaddrrcrcrdrJs
cCsZtjrVd}z<y"tjtjtj�}|jtdf�dStk
rBYnXWd|rT|j�XdS)NrTF)rZhas_ipv6ZAF_INET6r	r
�HOSTv6r�r)rrcrcrd�_is_ipv6_enableds

rcstj���fdd��}|S)NcsNy�||�Wn:tk
rH}zdt|�kr6tjd���WYdd}~XnXdS)NZCERTIFICATE_VERIFY_FAILEDz.system does not contain necessary certificates)�IOErrorrtrrrs)r�r�r�)r�rcrd�decs
z&system_must_validate_cert.<locals>.dec)r�r�)r�rrc)r�rd�system_must_validate_certs	rr�i�ZdoubleZIEEEztest requires IEEE 754 doublesz
requires zlibz
requires gzipzrequires bz2z
requires lzma�java�ANDROID_API_LEVEL�win32z/system/bin/shz/bin/shz$testz@testz	{}_{}_tmp�æ�İ�Ł�φ�К�א�،�ت�ก� �€u-àòɘŁğr�ZNFD�ntr�u-共Ł♡ͣ�ztWARNING: The filename %r CAN be encoded by the filesystem encoding (%s). Unicode filename tests may not be effective��s-��surrogateescape��w����������r�ccs�d}|dkr&tj�}d}tjj|�}nBytj|�d}Wn.tk
rf|sN�tjd|t	dd�YnX|rttj
�}z
|VWd|r�|tj
�kr�t|�XdS)NFTz+tests may fail, unable to create temp dir: �)r�)�tempfile�mkdtempr�r��realpath�mkdirr�rfr�r��getpidr)r��quietZdir_created�pidrcrcrd�temp_dir�s&


r1ccsftj�}ytj|�Wn.tk
rD|s,�tjd|tdd�YnXztj�VWdtj|�XdS)Nz)tests may fail, unable to change CWD to: r))r�)r��getcwd�chdirr�rfr�r�)r�r/Z	saved_dirrcrcrd�
change_cwd	s

r4�tempcwdccs:t||d��$}t||d��}|VWdQRXWdQRXdS)N)r�r/)r/)r1r4)rur/Z	temp_pathZcwd_dirrcrcrdr$s�umaskccs&tj|�}z
dVWdtj|�XdS)N)r�r6)r6ZoldmaskrcrcrdrK8s

�datacCsbtjj|�r|S|dk	r&tjj||�}tgtj}x*|D]"}tjj||�}tjj|�r8|Sq8W|S)N)r�r��isabsr��
TEST_HOME_DIRrn�exists)r�Zsubdirr�Zdn�fnrcrcrdrIs
cCs(tj|tjtjBtjB�}tj|�dS)N)r��open�O_WRONLY�O_CREAT�O_TRUNCr)r��fdrcrcrdr[scCs,t|j��}dd�|D�}dj|�}d|S)NcSsg|]}d|�qS)z%r: %rrc)�.0Zpairrcrcrd�
<listcomp>cszsortdict.<locals>.<listcomp>z, z{%s})�sortedr�r�)�dictr�Z	reprpairsZ
withcommasrcrcrdr[`s
cCs*ttd�}z|j�S|j�tt�XdS)N�wb)r<r�filenorr)r�rcrcrd�make_bad_fdgs

rG)�lineno�offsetcCsp|jt��}t|dd�WdQRX|j}|j|j�|dk	rJ|j|j|�|j|j�|dk	rl|j|j|�dS)Nz
<test string>�exec)�assertRaises�SyntaxError�compileZ	exceptionZassertIsNotNonerH�assertEqualrI)�testcaseZ	statementrHrI�cmr�rcrcrdr&sscsVddl}ddl}�jdd��|jj|�djd�d}tjjt	|�}���fdd�}tjj
|�r|||�}|dk	rt|St|�td�t
r�td	|t�d
�|jj�}tr�|jjd�|j|d
d�}tr�|jjd�dkr�tj|d�}zBt|d��.}	|j�}
x|
�r|	j|
�|j�}
�q�WWdQRXWd|j�X||�}|dk	�rF|Std|��dS)Nr�checkr��/rcs>t|f����}�dkr|S�|�r2|jd�|S|j�dS)Nr)r<�seekr)r;r�)r�rQr�rcrd�check_valid_file�s
z*open_urlresource.<locals>.check_valid_fileZurlfetchz	fetching %s ...)r��Accept-Encoding�gzip�)r�zContent-Encoding)ZfileobjrEzinvalid resource %r���)rUrV)Zurllib.requestZurllib.parse�pop�parseZurlparser�r�r�r��
TEST_DATA_DIRr:rr!rr�rZrequestZbuild_openerrVZ
addheadersr�r<Zheaders�getZGzipFile�read�writerr
)Zurlr�r��urllibr�r;rTr��opener�out�src)r�rQr�rdrI~s<	



c@s0eZdZdd�Zdd�Zedd��Zdd�Zd	S)
�WarningsRecordercCs||_d|_dS)Nr)�	_warnings�_last)�selfZ
warnings_listrcrcrd�__init__�szWarningsRecorder.__init__cCsDt|j�|jkr t|jd|�S|tjjkr0dStd||f��dS)Nrz%r has no attribute %rrX)r�rdrer�rf�WarningMessage�_WARNING_DETAILSr�)rf�attrrcrcrd�__getattr__�s
zWarningsRecorder.__getattr__cCs|j|jd�S)N)rdre)rfrcrcrdrf�szWarningsRecorder.warningscCst|j�|_dS)N)r�rdre)rfrcrcrd�reset�szWarningsRecorder.resetN)r`rarbrgrk�propertyrfrlrcrcrcrdrc�srcc
cs
tjd�}|jjd�}|r"|j�tjdd�� }tjdjd�t	|�VWdQRXt
|�}g}xz|D]r\}}d}	xH|dd�D]8}|j}
tj
|t|
�tj�r�t|
j|�r�d}	|j|�q�W|	rf|rf|j||jf�qfW|r�td|d	��|�rtd
|d	��dS)Nr�Z__warningregistry__T)�recordrf�alwaysFzunhandled warning %srz)filter (%r, %s) did not catch any warning)rn�	_getframe�	f_globalsr\�clearrfrgry�simplefilterrcr{�message�re�matchrt�I�
issubclassr��remover�r`�AssertionError)�filtersr/�frame�registry�wZreraiseZmissingrw�cat�seenZwarningrcrcrd�_filterwarnings�s0
r�cOs.|jd�}|s$dtff}|dkr$d}t||�S)Nr/r�T)r\�Warningr�)r{r�r/rcrcrdrR�s

r�ccsHtjdd��&}tjd||d�dV|r.t�WdQRX|j|g�dS)NT)rnro)rt�category)rfrgrh�
gc_collectrN)rOrtr�Zforce_gc�warnsrcrcrd�check_no_warningssr�ccsBtjdd�� }tjdtd�dVt�WdQRX|j|g�dS)NT)rnro)r�)rfrgrh�ResourceWarningr�rN)rOr�rcrcrdrSs
c@s$eZdZdd�Zdd�Zdd�ZdS)rcGsNtjj�|_x<|D]4}|tjkrtj|}|j|kr>tj|j=tj|=qWdS)N)rnry�copy�original_modulesr`)rfZmodule_namesZmodule_namer�rcrcrdrg?s




zCleanImport.__init__cCs|S)Nrc)rfrcrcrd�	__enter__LszCleanImport.__enter__cGstjj|j�dS)N)rnryr�r�)rf�
ignore_excrcrcrd�__exit__OszCleanImport.__exit__N)r`rarbrgr�r�rcrcrcrdr3s
c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)rTcCstj|_i|_dS)N)r��environ�_environ�_changed)rfrcrcrdrgXszEnvironmentVarGuard.__init__cCs
|j|S)N)r�)rf�envvarrcrcrd�__getitem__\szEnvironmentVarGuard.__getitem__cCs*||jkr|jj|�|j|<||j|<dS)N)r�r�r\)rfr��valuercrcrd�__setitem___s
zEnvironmentVarGuard.__setitem__cCs2||jkr|jj|�|j|<||jkr.|j|=dS)N)r�r�r\)rfr�rcrcrd�__delitem__es

zEnvironmentVarGuard.__delitem__cCs
|jj�S)N)r��keys)rfrcrcrdr�lszEnvironmentVarGuard.keyscCs
t|j�S)N)�iterr�)rfrcrcrd�__iter__oszEnvironmentVarGuard.__iter__cCs
t|j�S)N)r�r�)rfrcrcrd�__len__rszEnvironmentVarGuard.__len__cCs|||<dS)Nrc)rfr�r�rcrcrd�setuszEnvironmentVarGuard.setcCs
||=dS)Nrc)rfr�rcrcrd�unsetxszEnvironmentVarGuard.unsetcCs|S)Nrc)rfrcrcrdr�{szEnvironmentVarGuard.__enter__cGsJx<|jj�D].\}}|dkr0||jkr:|j|=q||j|<qW|jt_dS)N)r�r�r�r�r�)rfr��k�vrcrcrdr�~s

zEnvironmentVarGuard.__exit__N)r`rarbrgr�r�r�r�r�r�r�r�r�r�rcrcrcrdrTSsc@s$eZdZdd�Zdd�Zdd�ZdS)�
DirsOnSysPathcGs(tjdd�|_tj|_tjj|�dS)N)rnr��original_value�original_object�extend)rf�pathsrcrcrdrg�szDirsOnSysPath.__init__cCs|S)Nrc)rfrcrcrdr��szDirsOnSysPath.__enter__cGs|jt_|jtjdd�<dS)N)r�rnr�r�)rfr�rcrcrdr��szDirsOnSysPath.__exit__N)r`rarbrgr�r�rcrcrcrdr��sr�c@s&eZdZdd�Zdd�Zddd�ZdS)	r'cKs||_||_dS)N)r��attrs)rfr�r�rcrcrdrg�szTransientResource.__init__cCs|S)Nrc)rfrcrcrdr��szTransientResource.__enter__NcCsT|dk	rPt|j|�rPx:|jj�D]$\}}t||�s4Pt||�|kr Pq Wtd��dS)Nz%an optional resource is not available)rxr�r�r�r�r�r)rfZtype_r��	tracebackrjZ
attr_valuercrcrdr��s
zTransientResource.__exit__)NNN)r`rarbrgr�r�rcrcrcrdr'�s)�errnog>@)r��errnosc	#spd d!d"d#d$d%g}d'd)d+d-d.g}td|��|�g��sRdd�|D��dd�|D�����fdd�}tj�}z�y|dk	r�tj|�dVWn�tjk
�r�}z&tr�tjj	�j
dd��|�WYdd}~Xn�tk
�rZ}zpx^|j
}t|�dk�rt
|dt��r|d}n*t|�dk�r8t
|dt��r8|d}nP�q�W||��WYdd}~XnXWdtj|�XdS)/N�ECONNREFUSED�o�
ECONNRESET�h�EHOSTUNREACH�q�ENETUNREACH�e�	ETIMEDOUT�n�
EADDRNOTAVAIL�c�	EAI_AGAINr)�EAI_FAILr��
EAI_NONAMEr��
EAI_NODATA��
WSANO_DATA�*zResource %r is not availablecSsg|]\}}tt||��qSrc)r�r�)rAru�numrcrcrdrB�sz&transient_internet.<locals>.<listcomp>cSsg|]\}}tt||��qSrc)r�r)rArur�rcrcrdrB�scs�t|dd�}t|tj�s�t|tj�r,|�ks�t|tjj�rTd|jkoNdkns�t|tjj	�r�d|j
ks�d|j
ks�d|j
ks�|�kr�ts�tj
j�jdd��|�dS)	Nr�i�iW�ConnectionRefusedError�TimeoutError�EOFErrorr�
)r��
isinstancerr�Zgaierrorr_�errorZ	HTTPError�codeZURLErrorr�rrn�stderrr^r�)r��n)�captured_errnos�denied�
gai_errnosrcrd�filter_error�s


z(transient_internet.<locals>.filter_errorrr�r)r�r�)r�r�)r�r�)r�r�)r�r�)r�r����)r�r����)r�r����)r�r����)r�r�)r�r�)rrZgetdefaulttimeoutZsetdefaulttimeout�nntplibZNNTPTemporaryErrorrrnr�r^r�r�r�r�)	Z
resource_namer�r�Zdefault_errnosZdefault_gai_errnosr�Zold_timeoutr��arc)r�r�r�rdr+�sP



c
csFddl}tt|�}tt||j��ztt|�VWdtt||�XdS)Nr)�ior�rn�setattr�StringIO)Zstream_namer�Zorig_stdoutrcrcrd�captured_outputs
r�cCstd�S)Nr�)r�rcrcrcrdrscCstd�S)Nr�)r�rcrcrcrdr%scCstd�S)N�stdin)r�rcrcrcrdr.s
cCs*tj�trtjd�tj�tj�dS)Ng�������?)�gcZcollectr@r�r�rcrcrcrdr�;s


r�c
cs.tj�}tj�z
dVWd|r(tj�XdS)N)r��	isenabled�disable�enable)Zhave_gcrcrcrd�
disable_gcKs
r�cCs:tjd�pd}d}x|j�D]}|jd�r|}qW|dkS)N�	PY_CFLAGSr�z-O�-O0�-Og)r�r�r�)�	sysconfig�get_config_varr�rp)ZcflagsZ	final_optr�rcrcrd�python_is_optimizedVs
r�ZnPZ0n�gettotalrefcountZ2PZ0Pr�cCstjt|t�S)N)�struct�calcsize�_header�_align)�fmtrcrcrd�calcobjsizegsr�cCstjt|t�S)N)r�r��_vheaderr�)r�rcrcrd�calcvobjsizejsr���	cCspddl}tj|�}t|�tkr(|jt@sBt|�tkrLt|�jt@rL||j7}dt|�||f}|j|||�dS)Nrz&wrong size for %s: got %d, expected %d)	�	_testcapirn�	getsizeofr��	__flags__�_TPFLAGS_HEAPTYPE�_TPFLAGS_HAVE_GCZSIZEOF_PYGC_HEADrN)�test�o�sizer�r�rwrcrcrd�check_sizeofqs

r�cs��fdd�}|S)Ncs$���fdd�}�j|_�j|_|S)Ncs�y ddl}t|��}|j|�}Wn(tk
r6�YnBd}}Yn0Xx,�D]$}y|j||�PWqPYqPXqPWz
�||�S|r�|r�|j||�XdS)Nr)�localer��	setlocaler�)r��kwdsr�r�Zorig_locale�loc)�catstrr��localesrcrd�inner�s$



z1run_with_locale.<locals>.decorator.<locals>.inner)r`�__doc__)r�r�)r�r�)r�rdr��sz"run_with_locale.<locals>.decoratorrc)r�r�r�rc)r�r�rdrU�scs�fdd�}|S)Ncs"��fdd�}�j|_�j|_|S)Ncs�y
tj}Wntk
r(tjd��YnXdtjkr@tjd}nd}�tjd<|�z
�||�S|dkrrtjd=n
|tjd<tj�XdS)Nztzset requiredZTZ)r��tzsetr�rrrsr�r�)r�r�r�Zorig_tz)r��tzrcrdr��s





z-run_with_tz.<locals>.decorator.<locals>.inner)r`r�)r�r�)r�)r�rdr��szrun_with_tz.<locals>.decoratorrc)r�r�rc)r�rdr\�scCs�dttdtd�}tjd|tjtjB�}|dkr>td|f��tt|j	d��||j	d�j
��}|a|tkrrt}|t
dkr�td|f��|adS)Ni)r��m�g�tz(\d+(\.\d+)?) (K|M|G|T)b?$zInvalid memory limit %rrr)z$Memory limit %r too low to be useful)�_1M�_1Grurv�
IGNORECASE�VERBOSEr�r��float�group�lower�real_max_memuse�MAX_Py_ssize_t�_2Gr)�limitZsizesr�ZmemlimitrcrcrdrY�s$c@s$eZdZdd�Zdd�Zdd�ZdS)�_MemoryWatchdogcCsdjtj�d�|_d|_dS)Nz/proc/{pid}/statm)r0F)r�r�r.�procfile�started)rfrcrcrdrg�sz_MemoryWatchdog.__init__cCs�yt|jd�}Wn<tk
rL}z tjdj|�t�tjj	�dSd}~XnXt
d�}tjtj
|g|tjd�|_|j�d|_dS)N�rz!/proc not available for stats: {}zmemory_watchdog.py)r�r�T)r<r
r�rfr�r�r�rnr��flushr�
subprocess�Popen�
executableZDEVNULL�mem_watchdogrr)rfr�r�Zwatchdog_scriptrcrcrd�start�s
z_MemoryWatchdog.startcCs|jr|jj�|jj�dS)N)rrZ	terminate�wait)rfrcrcrd�stop�s
z_MemoryWatchdog.stopN)r`rarbrgrrrcrcrcrdr	�sr	cs���fdd�}|S)Ncs ���fdd����_��_�S)Nc
s��j}�j}tsd}n|}ts$�rFt||krFtjd||d��tr|tr|t�tdj||dd��t�}|j	�nd}z
�||�S|r�|j
�XdS)	Niz'not enough memory: %.1fG minimum neededir)z* ... expected peak memory use: {peak:.1f}G)Zpeaki@i@)r��memuserrrrsrr�r�r	rr)rfr�r�maxsizeZwatchdog)�dry_runr�r�rcrdr�s*


z.bigmemtest.<locals>.decorator.<locals>.wrapper)r�r)r�)rrr�)r�r�rdr�szbigmemtest.<locals>.decoratorrc)r�rrr�rc)rrr�rdr3s
!cs�fdd�}|S)NcsDttkr8td
kr$tdkr$tjd��q@tjdtd��n�|�SdS)
Nr��?r�z-not enough memory: try a 32-bit build insteadz'not enough memory: %.1fG minimum neededir)ll����li@)rrrrrs)rf)r�rcrdr�3sz!bigaddrspacetest.<locals>.wrapperrc)r�r�rc)r�rdr41sc@seZdZdd�ZdS)r,cCstj�}||�|S)N)rrZ
TestResult)rfr�r�rcrcrd�runDszBasicTestRunner.runN)r`rarbrrcrcrcrdr,CscCs|S)Nrc)r�rcrcrd�_idIsrcCs<|dkrt�rtjtj�St|�r(tStjdj|��SdS)Nr�zresource {0!r} is not enabled)r�rr�skipr�r rr�)r�rcrcrd�requires_resourceLs
rcCs&trt|krtjd|tf�StSdS)Nz%s at Android API level %d)rA�_ANDROID_API_LEVELrrrr)�levelr�rcrcrdr>TscCstdd�|�S)NT)�cpython)�impl_detail)r�rcrcrdr5[scKsVtf|�rtS|dkrLt|�\}}|r,d}nd}t|j��}|jdj|��}tj|�S)Nz*implementation detail not available on {0}z%implementation detail specific to {0}z or )	rBr�
_parse_guardsrCr�r�r�rrr)rw�guardsZ
guardnames�defaultrcrcrdr!as
r!cCsTtdkr:ddl}y|j�daWntk
r8daYnXd}trF|Stj|�|�S)NrTFz6requires a functioning shared semaphore implementation)�_have_mp_queue�multiprocessingZQueuermrrr)r�r&rwrcrcrdr?os
cCs*|sddidfSt|j��d}||fS)Nr TFr)r{�values)r#Zis_truercrcrdr"~sr"cKs t|�\}}|jtj�j�|�S)N)r"r\roZpython_implementationr)r#r$rcrcrdrB�scs,ttd�s�Stj���fdd��}|SdS)N�gettracecs.tj�}ztjd��||�Stj|�XdS)N)rnr(�settrace)r�r�Zoriginal_trace)r�rcrdr��s


zno_tracing.<locals>.wrapper)r�rnr�r�)r�r�rc)r�rd�
no_tracing�s
r*cCstt|��S)N)r*r5)r�rcrcrd�
refcount_test�sr+cCsRg}xB|jD]8}t|tj�r2t||�|j|�q||�r|j|�qW||_dS)N)Z_testsr�rr�	TestSuite�
_filter_suiter�)�suiteZpredZnewtestsr�rcrcrdr-�s
r-cCs�ttjttdk	d�}|j|�}tdk	r4tj|j��|js>t	�|j
�s�t|j�dkrl|j
rl|jdd}n6t|j
�dkr�|jr�|j
dd}nd}ts�|d7}t|��dS)N)�	verbosityZcapture_outputrrzmultiple errors occurredz!; run in verbose mode for details)rrnr�r�junit_xml_listrr�Zget_xml_elementZtestsRunrZ
wasSuccessfulr��errorsZfailuresr
)r.Zrunnerr�r�rcrcrd�
_run_suite�s"
r2cCstdkrdSt|j��SdS)NT)�_match_test_func�id)r�rcrcrd�
match_test�sr5cCsd|kotjd|�S)Nrxz[?*\[\]])ru�search)r�rcrcrd�_is_full_match_test�sr7csr|tkrdS|sd}f}nHttt|��r4t|�j}n.djttj|��}t	j
|�j��fdd�}|}t|�a|a
dS)N�|cs$�|�rdStt�|jd���SdS)NTrx)�anyr�r�)Ztest_id)�regex_matchrcrd�match_test_regex�sz)set_match_tests.<locals>.match_test_regex)�_match_test_patterns�allr�r7r��__contains__r��fnmatch�	translaterurMrvrqr3)Zpatternsr�Zregexr;rc)r:rd�set_match_tests�srAcGs�tjtjf}tj�}xh|D]`}t|t�rT|tjkrJ|jtjtj|��qzt	d��qt||�rj|j|�q|jtj
|��qWt|t�t
|�dS)Nz)str arguments must be keys in sys.modules)rrr,ZTestCaser�rtrnryZaddTestZ
findTestCasesr�Z	makeSuiter-r5r2)�classesZvalid_typesr.�clsrcrcrdr-s





cCsdS)Nrcrcrcrcrd�_check_docstrings(srD�WITH_DOC_STRINGSztest requires docstringscCs`ddl}|dkrt}nd}|j|||d�\}}|rBtd||f��trXtd|j|f�||fS)Nr)r�optionflagsz%d of %d doctests failedz,doctest (%s) ... %d tests with zero failures)�doctestrZtestmodr
r�r`)r�r/rFrGr�r�rcrcrdr.9scCstjj�fS)N)rnryr�rcrcrcrd�
modules_setupTsrHcCs:dd�tjj�D�}tjj�tjj|�tjj|�dS)NcSs"g|]\}}|jd�r||f�qS)z
encodings.)rp)rAr�r�rcrcrdrB[sz#modules_cleanup.<locals>.<listcomp>)rnryr�rrr�)Z
oldmodulesZ	encodingsrcrcrd�modules_cleanupWs
rIcCs"trtj�tjj�fSdffSdS)Nr)�_thread�_count�	threading�	_danglingr�rcrcrcrdrNzscGsJtsdSd}x8t|�D],}tj�tjf}||kr2Ptjd�t�qWdS)N�dg{�G�z�?)rJ�rangerKrLrMr�r�r�)Zoriginal_valuesZ
_MAX_COUNT�countr'rcrcrdrO�s
cs"ts�Stj���fdd��}|S)Ncst�}z�|�St|�XdS)N)rNrO)r��key)r�rcrdr��szreap_threads.<locals>.decorator)rJr�r�)r�r�rc)r�rdrP�s�N@ccs�tj�}z
dVWdtj�}||}xjtj�}||kr8Ptj�|kr|tj�|}d||�d|d�d|�d|�d�	}t|��tjd�t�q&WXdS)Nz!wait_threads() failed to cleanup z threads after z.1fz seconds (count: z
, old count: �)g{�G�z�?)rJrKr�Z	monotonicrzr�r�)r�Z	old_countZ
start_timeZdeadlinerPZdtrwrcrcrd�wait_threads_exit�s
$
rTc
CsZttd�rVd}xFy2tj|tj�\}}|dkr.Ptd|tjd�WqPYqXqWdS)N�waitpidrrz2Warning -- reap_children() reaped child process %s)r�rX)r�r�rU�WNOHANGr�rnr�)Zany_processr0ZstatusrcrcrdrL�s
ccs*t|�}g}zZy$x|D]}|j�|j|�qWWn*trVtdt|�t|�f��YnXdVWdz�|rt|�tj�}}xltdd�D]^}|d7}x$|D]}|jt	|tj�d��q�Wdd�|D�}|s�Ptr�tdt|�|f�q�WWdd	d�|D�}|�r"t
jtj
�td
t|���XXdS)Nz/Can't start %d threads, only %d threads startedrr�<g{�G�z�?cSsg|]}|j�r|�qSrc)�isAlive)rAr�rcrcrdrB�sz!start_threads.<locals>.<listcomp>z7Unable to join %d threads during a period of %d minutescSsg|]}|j�r|�qSrc)rX)rAr�rcrcrdrB�szUnable to join %d threads)r{rr�rr�r�r�rOr��max�faulthandlerZdump_tracebackrnr�rz)ZthreadsZunlockrr�ZendtimeZ	starttimer�rcrcrdrQ�s>


c
csnt||�r<t||�}t|||�z
|VWdt|||�Xn.t|||�z
dVWdt||�rht||�XdS)N)r�r�r��delattr)r�rj�new_val�real_valrcrcrdrW�s




ccsX||kr0||}|||<z
|VWd|||<Xn$|||<z
dVWd||krR||=XdS)Nrc)r��itemr\r]rcrcrdrV	s

cCstjdd|�j�}|S)Ns\[\d+ refs, \d+ blocks\]\r?\n?�)ru�sub�strip)r�rcrcrd�strip_python_stderr8	srbZ	getcountsz-types are immortal if COUNT_ALLOCS is definedcCstj�S)N)rZ_args_from_interpreter_flagsrcrcrcrd�args_from_interpreter_flagsE	srccCstj�S)N)rZ"_optim_args_from_interpreter_flagsrcrcrcrd�!optim_args_from_interpreter_flagsJ	srdc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rMcCstjjj|d�||_dS)Nr)�logging�handlers�BufferingHandlerrg�matcher)rfrhrcrcrdrgT	szTestHandler.__init__cCsdS)NFrc)rfrcrcrd�shouldFlush]	szTestHandler.shouldFlushcCs|j|�|jj|j�dS)N)r�r�r��__dict__)rfrnrcrcrd�emit`	s
zTestHandler.emitcKs.d}x$|jD]}|jj|f|�rd}PqW|S)NFT)r�rh�matches)rfr�r��drcrcrdrld	szTestHandler.matchesN)r`rarbrgrirkrlrcrcrcrdrMS	s	c@s eZdZdZdd�Zdd�ZdS)	rXrwrtcKs<d}x2|D]*}||}|j|�}|j|||�s
d}Pq
W|S)NTF)r\�match_value)rfrmr�r�r�r��dvrcrcrdrls	s

zMatcher.matchescCsHt|�t|�krd}n.t|�tk	s,||jkr6||k}n|j|�dk}|S)NFr)r�rt�_partial_matches�find)rfr�ror�r�rcrcrdrn�	s
zMatcher.match_valueN)rwrt)r`rarbrprlrnrcrcrcrdrXo	sc
CsZtdk	rtStd}ytjt|�d}Wntttfk
rFd}YnXtj|�|a|S)NrTF)�_can_symlinkrr��symlinkr��NotImplementedErrorr�ry)Zsymlink_path�canrcrcrdr�	s

cCs t�}d}|r|Stj|�|�S)Nz*Requires functional symlink implementation)rrrr)r��okrwrcrcrdr/�	scCs�tdk	rtSttd�sd}n�tj�}tj|d�\}}z�ttd���}y`tj|dd�tj|dd�tj|j	�dd�t
j�}tj
d	|�}|dkp�t|jd
��dk}Wntk
r�d}YnXWdQRXWdtt�t|�t|�X|a|S)N�setxattrF)�dirrEs	user.testr_strusted.foos42z
2.6.(\d{1,2})r�')�
_can_xattrr�r�r*r+Zmkstempr<rrwrFror�rurvr�rr�rr�)ruZtmp_dirZtmp_fpZtmp_name�fpZkernel_versionr�rcrcrd�	can_xattr�	s,

r|cCs t�}d}|r|Stj|�|�S)Nz(no non-broken extended attribute support)r|rrr)r�rvrwrcrcrdr8�	scCs$tpt}d}|r|Stj|�|�S)Nz#Not run for (non-extended) PGO task)r]�PGO_EXTENDEDrrr)r�rvrwrcrcrd�skip_if_pgo_task�	s
r~cCs^tj|d��H}|j}|j�}||kr,|j�}ytjj||�Stk
rNdSXWdQRXdS)N)rxF)	r*ZNamedTemporaryFileru�upperrr�r��samefiler�)Z	directory�base�	base_pathZ	case_pathrcrcrdr�	s)recCs>tt|��tt|��}|r(|t|�8}tdd�|D��}|S)Ncss(|] }|jd�s|jd�r|VqdS)�_�__N)rp�endswith)rAr�rcrcrd�	<genexpr>�	sz&detect_api_mismatch.<locals>.<genexpr>)r�rx)Zref_apiZ	other_apireZ
missing_itemsrcrcrdr<�	s
cCs�|dkr|jf}nt|t�r"|f}t|�}xbt|�D]V}|jd�s4||krLq4t||�}t|dd�|ks�t|d�r4t|tj	�r4|j
|�q4W|j|j|�dS)Nr�ra)
r`r�rtr�rxrpr�r��types�
ModuleType�addZassertCountEqual�__all__)Z	test_caser�Zname_of_moduleZextraZ	blacklistZexpectedrur�rcrcrdr=�	s)


c@s$eZdZdZdZdd�Zdd�ZdS)rZNc
Csrtjjd�r�ddl}|jj|_d}|jj|�|_|jj|j|B�yddl	}|j
Wnttfk
rlYnLXi|_
x�|j|j|jgD].}|j
||j�}|j||j�}||f|j
|<q�Wn�tdk	�r
y*tjtj�|_tjtjd|jdf�Wnttfk
�rYnXtjdk�rndddd	g}tj|tjtjd
�}|�|j�d}	WdQRX|	j�dk�rntdd
dd�|S)Nr�rr�rr�z/usr/bin/defaultsr]zcom.apple.CrashReporterZ
DialogType)r�r�s	developerz:this test triggers the Crash Reporter, that is intentionalr�T)�endr
) rnrorpr�r�r��_k32�SetErrorMode�	old_value�msvcrt�CrtSetReportModer�rm�	old_modes�CRT_WARN�	CRT_ERROR�
CRT_ASSERTZCRTDBG_MODE_FILE�CrtSetReportFileZCRTDBG_FILE_STDERRr�Z	getrlimit�RLIMIT_CORE�	setrlimitr�r�rr�PIPEZcommunicaterar�)
rfr�ZSEM_NOGPFAULTERRORBOXr��report_type�old_mode�old_file�cmd�procr�rcrcrdr�2
sN




zSuppressCrashReport.__enter__cGs�|jdkrdStjjd�rl|jj|j�|jr�ddl}xj|jj�D]$\}\}}|j	||�|j
||�qBWn6tdk	r�ytjtj
|j�Wnttfk
r�YnXdS)Nr�r)r�rnrorpr�r�r�r�r�r�r�r�r�r�r�r�)rfr�r�r�r�r�rcrcrdr�s
s
zSuppressCrashReport.__exit__)r`rarbr�r�r�r�rcrcrcrdrZ)
sAcsrt���d�y�j��Wn$ttfk
r@t��d��YnXd�����fdd�}|j|�t��|�dS)NFTcs �rt����n
t���dS)N)r�r[rc)�
attr_is_local�	attr_name�object_to_patchr�rcrd�cleanup�
szpatch.<locals>.cleanup)r�rjr�rZ
addCleanupr�)Z
test_instancer�r�Z	new_valuer�rc)r�r�r�r�rd�patch�
s


r�cCsFyddl}Wntk
r YnX|j�r4tjd��ddl}|j|�S)NrzUrun_in_subinterp() cannot be used if tracemalloc module is tracing memory allocations)�tracemallocrmZ
is_tracingrrrsr��run_in_subinterp)r�r�r�rcrcrdr��
s
r�csHG��fdd�d|�}d�|||���|jtt��t�|j��dS)NcseZdZ��fdd�ZdS)z%check_free_after_iterating.<locals>.Acs*d�yt��Wntk
r$YnXdS)NT)�next�
StopIteration)rf)�done�itrcrd�__del__�
s
z-check_free_after_iterating.<locals>.A.__del__N)r`rarbr�rc)r�r�rcrd�A�
sr�F)rKr�r�r�Z
assertTrue)r�r�rCr�r�rc)r�r�rd�check_free_after_iterating�
s	r�cCs|ddlm}m}m}|j�}|j|�xP|jD]F}|r@||kr@q.t||�}|rPn
|dkrZq.|j|d�dkr.|dSq.WdS)Nr)�	ccompilerr��spawn)	Z	distutilsr�r�r�Znew_compilerZcustomize_compilerZexecutablesr�Zfind_executable)Z	cmd_namesr�r�r�Zcompilerrur�rcrcrdr^�
s	

cCs@d}tr6||kr6tdkr.tjddg�j�dkatr6|}tj|�S)Ng�h㈵��>Zgetpropzro.kernel.qemu�1)rA�_is_android_emulatorrZcheck_outputrarnrD)ZintervalZminimum_intervalrcrcrdrD�
sc
cs>tjj�}tj�}ztj�dVWd|r8tj|dd�XdS)NT)r�Zall_threads)rnr�rFrZ�
is_enabledr�r�)r@r�rcrcrd�disable_faulthandler�
s

r�c	/Cs�tjjd
�r8ytjd�}t|�dStk
r6YnXd}ttd�rjytjd�}Wnt	k
rhYnXd}tjdkr�yd	dl
}|jWntt
fk
r�Yn0Xi}x(|j|j|jfD]}|j|d	�||<q�Wzpd	}xft|�D]Z}ytj|�}Wn4t	k
�r(}z|jtjk�r�WYdd}~Xq�Xtj|�|d7}q�WWd|dk	�rzx*|j|j|jfD]}|j|||��q`WX|S)N�linux�freebsdz
/proc/self/fdr��sysconf�SC_OPEN_MAXrr)r�r�)rnrorpr�r�r�r�r�r�r�r�r�r�rmr�r�r�rO�dupr�ZEBADFr)	�namesZMAXFDr�r�r�rPr@Zfd2r�rcrcrdr_	sP





c@s$eZdZdd�Zdd�Zdd�ZdS)�SaveSignalscCsjddl}||_ttd|j��|_x>dD]6}yt||�}Wntk
rNw&YnX|jj|�q&Wi|_dS)Nrr�SIGKILL�SIGSTOP)r�r�)	�signalr{rO�NSIG�signalsr�r�ryrf)rfr�Zsigname�signumrcrcrdrgMs
zSaveSignals.__init__cCs4x.|jD]$}|jj|�}|dkr"q||j|<qWdS)N)r�r��	getsignalrf)rfr��handlerrcrcrd�saveZs
zSaveSignals.savecCs*x$|jj�D]\}}|jj||�qWdS)N)rfr�r�)rfr�r�rcrcrd�restorefszSaveSignals.restoreN)r`rarbrgr�r�rcrcrcrdr�Ds	
r�c@s$eZdZdd�Zdd�Zdd�ZdS)�FakePathcCs
||_dS)N)r�)rfr�rcrcrdrgnszFakePath.__init__cCsd|j�d�S)Nz
<FakePath �>)r�)rfrcrcrd�__repr__qszFakePath.__repr__cCs6t|jt�s$t|jt�r,t|jt�r,|j�n|jSdS)N)r�r��
BaseExceptionr�rx)rfrcrcrd�
__fspath__ts
zFakePath.__fspath__N)r`rarbrgr�r�rcrcrcrdr�ksr�ccs.tj�}ztj|�dVWdtj|�XdS)N)rn�get_int_max_str_digits�set_int_max_str_digits)Z
max_digitsZcurrentrcrcrd�adjust_int_max_str_digits|s


r�)T)F)F)N)Nii@i@i@ii)rrrrrrrrrr r!)r%r#r&r'r()NF)F)r5F)N)Fi@ii)T)N)Nr)rR)N(r`rm�collections.abc�collections�
contextlibZdatetimer�rZr?r�r�r�rl�importlib.utilr�Zlogging.handlersrer�r�rorur�rr�r�rrnr�r*r�r�rrZurllib.errorr_rfZ
testresultrrJrLZmultiprocessing.processr&�zlibrV�bz2Zlzmar�r�r�r�r	r
rrsr�contextmanagerrjr
r~r�r:r;rr6rrrrr0rr�rrrr�rpr�r�r�r�r�rr�rr�rr�r r!r�r"r#r$r%rErrr	rGrHrJrrFrrZ
SOCK_MAX_SIZEZ
skipUnlessr�
__getformat__r7r9r0r1r2r@r�rrArCrurr�r.ZFS_NONASCII�	character�fsdecode�fsencode�UnicodeErrorZTESTFN_UNICODEZunicodedata�	normalize�getfilesystemencodingZTESTFN_ENCODINGZTESTFN_UNENCODABLEZgetwindowsversion�encode�UnicodeEncodeErrorr��decode�UnicodeDecodeErrorZTESTFN_UNDECODABLEZTESTFN_NONASCIIr2rr]r}r1r4rr�rKr�r�r�r�ZTEST_SUPPORT_DIRr9r�r[rrr[rGr&rI�objectrcr�rRr�r�rSr�abc�MutableMappingrTr�r'r�r�r(r�r)r*r+r�rrrr�r�r�r�r�r�r�r�r�r�r�rUr\r�r�rZ_4GrrrYr	r3r4r,rrr>r5r!r%r?r"rBr*r+r-r2r3r<r5r7rAr-rDZMISSING_C_DOCSTRINGSr�ZHAVE_DOCSTRINGSZrequires_docstringsr.rHrIZenvironment_alteredrNrOrPrTrLrQrWrVrbZskipIfZrequires_type_collectingrcrdrfrgrMrXrrrr/rzr|r8r~rr<r=rZr�r�r�r^r�rDr�r_r�r�r�rcrcrcrd�<module>s�











2	
!

J			>%	


%2' 5M		


$
#
0







(




"
#
	"
:_";'support/__pycache__/__init__.cpython-36.pyc000064400000236703150532443020014666 0ustar003

Ow�h����@s^
dZedkred��ddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZ
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl!Z"ddl#Z#ddl$m%Z%yddl&Z&ddl'Z'Wnek
�rBdZ&dZ'YnXyddl(Z)Wnek
�rjdZ)YnXyddl*Z*Wnek
�r�dZ*YnXyddl+Z+Wnek
�r�dZ+YnXyddl,Z,Wnek
�r�dZ,YnXyddl-Z-Wnek
�r
dZ-YnXyddl.Z.Wnek
�r2dZ.YnXyddl/Z/Wnek
�rZdZ/YnXddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbg\Z0Gdcd�de1�Z2Gddd
�d
e2�Z3Gded�de2�Z4Gdfd�de j5�Z6ej7�dfdhdi��Z8�dgfdk�dld�Z9dmdn�Z:dodp�Z;dqd=�Z<drd>�Z=ffdjfdsd�Z>dtd9�Z?dZ@dZAdaBdaCdZDdjZEdaFdud�ZGdvd�ZHdwd�ZIdxdy�ZJejjKdz��r.�dhd{d|�ZLd}d~�ZMdd��ZNd�d��ZOd�d��ZPnejQZMejRZNd�d��ZOd�d��ZPd�d�ZQd�d��ZRd�d�ZSd�d��ZTd�d�ZUd�d��ZVd�d#�ZW�did�d$�ZXd�d��ZYd�d%�ZZd�d&�Z[d�d'�Z\�djd�d(�Z]d�Z^d�Z_ej`ejafd�dJ�Zbe^fd�dK�Zcd�dM�Zdd�d��Zeee�Zfd�d��Zg�dmZh�dpZie jjekjld��jKd��d��Zme jje*d��Zne jje+d��Zoe jje,d��Zpe jje-d��ZqejjKd��Zrejsd��Ztetdk	�oxetdkZuejd�k�r�eu�r�d�nd�ZvndZvejwd�k�r�d�Zxnd�Zxd�jyexejz��ZxdZ{xL�dqD]BZ|yej}ej~e|��e|k�r�e�Wnek
�rYnXe|Z{P�q�Wexd�Z�ejd�k�r:ddl�Z�e�j�d�e��Z�ej��Z�dZ�ejwd�k�r�ej��jd�k�r�exd�Z�ye�j�e��Wne�k
�r�YnXe�d�e�e�f�dZ�nBejd�k�r�yd�j�e��Wn&e�k
�r�exd�j�e�dǃZ�YnXdZ�xF�drD]<Zwyewj�e��Wn&e�k
�r,ej~ex�ewZ�PYnX�q�We{�rHexd�e{Z�ndZ�ej��Z�djZ�djZ�ej7�dsd�d΄�Z�ej7�dtd�dЄ�Z�ej7�dud�d��Z�e�edӃ�r�ej7d�dN��Z�ej�j�ej�j�e���Z�ej�j�e��Z�ej�j�e�dՃZ��dvd�d�Z�d�d �Z�d�d^�Z�d�dڄZ�dddۜd�d)�Z�d�dL�Z�Gd�d߄d�e��Z��dwd�d�Z�ej7d�dU��Z�ej7d�e�djfd�d��Z�ej7d�dV��Z�Gd�d�de��Z�Gd�dW�dWej�j��Z�Gd�d�d�e��Z�Gd�d*�d*e��Z�e�e�ej�d�Z�e�e�ej�d�Z�e�e�ej�d�Z�ej7d�fd�d�d.��Z�ej7d�d��Z�d�d�Z�d�d�Z�d�d�Z�d�d��Z�ej7d�d���Z�d�d��Z�d�Z�d�Z�e�ed���	rLd�e�Z�d�Z�e��dZd�d�ZÐd�d�ZĐdxZŐdyZƐd�d�Zǐd	dX�ZȐd
d_�ZɐdzZ�d�e�Z�d�e�Z�d�e�Z�ej�Zϐdd\�Z�G�d�d
��d
�Zѐd{�dd6�ZҐdd7�Z�G�dd/�d/�ZԐd�d�ZՐd�d�Z֐ddA�Zאdd8�Zؐd|�d�d�Z�daڐddB�Zېd�d�ZܐddE�Zݐd�d�Zސd�d �Zߐd!�d"�Z�d#�d$�Z�da�da�d%�d&�Z�d'�d(�Z�d)�d*�Z�d+d0�Z�d,�d-�Z�e݃�
o�ejd�k�
o�ejs�d.�Z�e�jdk	�oe�Z�e jje�d/�Z�d}�d0d1�Z�d1�d2�Z�d3�d4�Z�djZ�d5dQ�Z�d6dR�Z�d7dS�Z�ej7�d~�d9�d:��Z�d;dO�Z�ej7�d�d<dT��Z�ej7�d=dZ��Z�ej7�d>dY��Z��d?�d@�Z�e j�e�e�dA��dB�Z��dC�dD�Z��dE�dF�Z�G�dGdP�dPej�j��Z�G�dHd[�d[e���Zd�a�dId!��Z�dJd2��Zd�a�dK�dL��Z�dMd;��Z�dN�dO��Z�dPd"��Zf�dQ��dRd?��Z	dfff�dSd@��Z
G�dTd]�d]��Z�dU�dV��Z�dW�dX��Z
ff�dY�dZ��Zgf�d[da��Zd�a�d\dG��Zej7�d]�d^���Z�d_db��ZG�d`�da��da��ZG�db�dc��dc��Zej7�dd�de���ZdS(�z7Supporting definitions for the Python regression tests.ztest.supportz.support must be imported from the test package�N�)�get_test_runner�
PIPE_MAX_SIZE�verbose�
max_memuse�
use_resources�failfast�Error�
TestFailed�
TestDidNotRun�ResourceDenied�
import_module�import_fresh_module�CleanImport�unload�forget�record_original_stdout�get_original_stdout�captured_stdout�captured_stdin�captured_stderr�TESTFN�SAVEDCWD�unlink�rmtree�temp_cwd�findfile�create_empty_file�can_symlink�fs_is_case_insensitive�is_resource_enabled�requires�requires_freebsd_version�requires_linux_version�requires_mac_ver�requires_hashdigest�check_syntax_error�TransientResource�time_out�socket_peer_reset�ioerror_peer_reset�transient_internet�BasicTestRunner�run_unittest�run_doctest�skip_unless_symlink�
requires_gzip�requires_bz2�
requires_lzma�
bigmemtest�bigaddrspacetest�cpython_only�
get_attribute�requires_IEEE_754�skip_unless_xattr�
requires_zlib�anticipate_failure�load_package_tests�detect_api_mismatch�check__all__�requires_android_level�requires_multiprocessing_queue�	is_jython�
is_android�check_impl_detail�
unix_shell�setswitchinterval�HOST�IPV6_ENABLED�find_unused_port�	bind_port�open_urlresource�bind_unix_socket�
temp_umask�
reap_children�TestHandler�threading_setup�threading_cleanup�reap_threads�
start_threads�check_warnings�check_no_resource_warning�EnvironmentVarGuard�run_with_locale�	swap_item�	swap_attr�Matcher�set_memlimit�SuppressCrashReport�sortdict�run_with_tz�PGO�missing_compiler_executable�fd_countc@seZdZdZdS)r	z*Base class for regression test exceptions.N)�__name__�
__module__�__qualname__�__doc__�rdrd�-/usr/lib64/python3.6/test/support/__init__.pyr	|sc@seZdZdZdS)r
zTest failed.N)r`rarbrcrdrdrdrer
sc@seZdZdZdS)rzTest did not run any subtests.N)r`rarbrcrdrdrdrer�sc@seZdZdZdS)rz�Test skipped because it requested a disallowed resource.

    This is raised when a test calls requires() for a resource that
    has not be enabled.  It is used to distinguish between expected
    and unexpected skips.
    N)r`rarbrcrdrdrdrer�sTccs8|r.tj��tjddt�dVWdQRXndVdS)z�Context manager to suppress package and module deprecation
    warnings when importing them.

    If ignore is False, this context manager has no effect.
    �ignorez.+ (module|package)N)�warnings�catch_warnings�filterwarnings�DeprecationWarning)rfrdrdre�_ignore_deprecated_imports�s
rkF)�required_oncCsft|��Ty
tj|�Stk
rV}z&tjjt|��r8�tj	t
|���WYdd}~XnXWdQRXdS)acImport and return the module to be tested, raising SkipTest if
    it is not available.

    If deprecated is True, any module or package deprecation messages
    will be suppressed. If a module is required on a platform but optional for
    others, set required_on to an iterable of platform prefixes which will be
    compared against sys.platform.
    N)rk�	importlibr
�ImportError�sys�platform�
startswith�tuple�unittest�SkipTest�str)�name�
deprecatedrl�msgrdrdrer
�s	

cCs^|tjkrt|�tj|=x>ttj�D]0}||ks@|j|d�r&tj|||<tj|=q&WdS)zyHelper function to save and remove a module from sys.modules

    Raise ImportError if the module can't be imported.
    �.N)ro�modules�
__import__�listrq)rv�orig_modules�modnamerdrdre�_save_and_remove_module�s
rcCs>d}ytj|||<Wntk
r.d}YnXdtj|<|S)z�Helper function to save and block a module in sys.modules

    Return True if the module was in sys.modules, False otherwise.
    TFN)rorz�KeyError)rvr}Zsavedrdrdre�_save_and_block_module�s

r�cCs|r
tjSdd�S)z�Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    cSs|S)Nrd)�frdrdre�<lambda>�sz$anticipate_failure.<locals>.<lambda>)rsZexpectedFailure)Z	conditionrdrdrer:�scCsF|dkrd}tjjtjjtjjt���}|j|||d�}|j|�|S)z�Generic load_tests implementation for simple test packages.

    Most packages can implement load_tests using this function as follows:

       def load_tests(*args):
           return load_package_tests(os.path.dirname(__file__), *args)
    Nztest*)Z	start_dirZ
top_level_dir�pattern)�os�path�dirname�__file__ZdiscoverZaddTests)Zpkg_dir�loaderZstandard_testsr�Ztop_dirZ
package_testsrdrdrer;�s
cCs�t|���i}g}t||�zfyHx|D]}t||�q&Wx |D]}t||�s>|j|�q>Wtj|�}Wntk
r~d}YnXWdx|j�D]\}	}
|
tj	|	<q�Wx|D]}tj	|=q�WX|SQRXdS)a�Import and return a module, deliberately bypassing sys.modules.

    This function imports and returns a fresh copy of the named Python module
    by removing the named module from sys.modules before doing the import.
    Note that unlike reload, the original module is not affected by
    this operation.

    *fresh* is an iterable of additional module names that are also removed
    from the sys.modules cache before doing the import.

    *blocked* is an iterable of module names that are replaced with None
    in the module cache during the import to ensure that attempts to import
    them raise ImportError.

    The named module and any modules named in the *fresh* and *blocked*
    parameters are saved before starting the import and then reinserted into
    sys.modules when the fresh import is complete.

    Module and package deprecation messages are suppressed during this import
    if *deprecated* is True.

    This function will raise ImportError if the named module cannot be
    imported.
    N)
rkrr��appendrmr
rn�itemsrorz)rvZfreshZblockedrwr}Znames_to_removeZ
fresh_nameZblocked_nameZfresh_moduleZ	orig_name�moduleZname_to_removerdrdrer�s$





cCs>yt||�}Wn&tk
r4tjd||f��YnX|SdS)z?Get an attribute, raising SkipTest if AttributeError is raised.zobject %r has no attribute %rN)�getattr�AttributeErrorrsrt)�objrvZ	attributerdrdrer6s
cCs|adS)N)�_original_stdout)�stdoutrdrdrer0scCs
tptjS)N)r�ror�rdrdrdrer4scCs&ytj|=Wntk
r YnXdS)N)rorzr�)rvrdrdrer7scGsny||�Stk
rh}zDtdkrHtd|jj|f�td|j|f�tj|tj�||�Sd}~XnXdS)N�z%s: %szre-run %s%r)	�OSErrorr�print�	__class__r`r��chmod�stat�S_IRWXU)r��func�args�errrdrdre�
_force_run=sr��wincCs�||�|r|}ntjj|�\}}|p(d}d}x<|dkrjtj|�}|rJ|n||ksVdStj|�|d9}q0Wtjd|tdd�dS)Nryg����MbP?g�?r�z)tests may fail, delete still pending for �)�
stacklevel)	r�r��split�listdir�time�sleeprg�warn�RuntimeWarning)r��pathname�waitallr�rv�timeout�Lrdrdre�_waitforHs



r�cCsttj|�dS)N)r�r�r)�filenamerdrdre�_unlinkisr�cCsttj|�dS)N)r�r��rmdir)r�rdrdre�_rmdirlsr�cs,�fdd��t�|dd�tdd�|�dS)Ncs�x�t|tj|�D]�}tjj||�}ytj|�j}Wn<tk
rn}z td||ft	j
d�d}WYdd}~XnXtj|�r�t
�|dd�t|tj|�qt|tj|�qWdS)Nz-support.rmtree(): os.lstat(%r) failed with %s)�filerT)r�)r�r�r�r��join�lstat�st_moder�r�ro�
__stderr__r��S_ISDIRr�r�r)r�rv�fullname�mode�exc)�
_rmtree_innerrdrer�ps

z_rmtree.<locals>._rmtree_innerT)r�cSst|tj|�S)N)r�r�r�)�prdrdrer�sz_rmtree.<locals>.<lambda>)r�)r�rd)r�re�_rmtreeosr�c
Cs^yddl}Wntk
r Yn:X|jt|�d�}|jjj||t|��}|rZ|d|�S|S)Nrr�)�ctypesrnZcreate_unicode_buffer�len�windll�kernel32ZGetLongPathNameW)r�r��bufferZlengthrdrdre�	_longpath�s
r�csFytj|�dStk
r"YnX�fdd���|�tj|�dS)Nc
s�x~t|tj|�D]l}tjj||�}ytj|�j}Wntk
rJd}YnXtj	|�rn�|�t|tj
|�qt|tj|�qWdS)Nr)r�r�r�r�r�r�r�r�r�r�r�r)r�rvr�r�)r�rdrer��s

z_rmtree.<locals>._rmtree_inner)�shutilrr�r�r�)r�rd)r�rer��s
cCs|S)Nrd)r�rdrdrer��scCs*yt|�Wnttfk
r$YnXdS)N)r��FileNotFoundError�NotADirectoryError)r�rdrdrer�scCs&yt|�Wntk
r YnXdS)N)r�r�)r�rdrdrer��sr�cCs&yt|�Wntk
r YnXdS)N)r�r�)r�rdrdrer�scCsBtjj|�}tjjtjj|��}tjj||d�}tj||�|S)aMove a PEP 3147/488 pyc file to its legacy pyc location.

    :param source: The file system path to the source file.  The source file
        does not need to exist, however the PEP 3147/488 pyc file must exist.
    :return: The file system path to the legacy pyc file.
    �c)	rm�util�cache_from_sourcer�r�r��abspathr��rename)�sourceZpyc_fileZup_oneZ
legacy_pycrdrdre�make_legacy_pyc�s
r�cCs\t|�xNtjD]D}tjj||d�}t|d�x dD]}ttjj||d��q8WqWdS)	z�'Forget' a module was ever imported.

    This removes the module from sys.modules and deletes any PEP 3147/488 or
    legacy .pyc files.
    z.pyr��rr�)�optimizationN)r�rr�)	rror�r�r�rrmr�r�)r~r�r��optrdrdrer�s
cs�ttd�rtjSd}tjjd�r�ddl�ddl�d}d}G�fdd�d�j�}�j	j
}|j�}|sj�j��|�}�j
j�}|j||�j|��j|��j|��}|s��j��t|j|@�s�d}n�tjdk�rVdd	lm}	m�m}
m}dd
lm}|	j|d��}
|
j�dk�rd}nFG�fd
d�d|�}|�}|
|�}|
j|�dk�sR|
j|�dk�rVd}|�s�y.ddlm}|�}|j�|j �|j!�Wn\t"k
�r�}z>t#|�}t$|�dk�r�|dd�d}dj%t&|�j'|�}WYdd}~XnX|t_(|t_tjS)N�resultr�rrcs.eZdZd�jjfd�jjfd�jjfgZdS)z*_is_gui_available.<locals>.USEROBJECTFLAGSZfInheritZ	fReserved�dwFlagsN)r`rarb�wintypesZBOOL�DWORD�_fields_rd)r�rdre�USEROBJECTFLAGS�s

r�z,gui not available (WSF_VISIBLE flag not set)�darwin)�cdll�c_int�pointer�	Structure)�find_libraryZApplicationServicesz0gui tests cannot run without OS X window managercseZdZd�fd�fgZdS)z._is_gui_available.<locals>.ProcessSerialNumberZ
highLongOfPSNZlowLongOfPSNN)r`rarbr�rd)r�rdre�ProcessSerialNumbersr�z#cannot run without OS X gui process)�Tk�2z [...]zTk unavailable due to {}: {}))�hasattr�_is_gui_availabler�rorprqr�Zctypes.wintypesr�r�Zuser32ZGetProcessWindowStationZWinErrorr�r�ZGetUserObjectInformationWZbyrefZsizeof�boolr�r�r�r�Zctypes.utilr�ZLoadLibraryZCGMainDisplayIDZGetCurrentProcessZSetFrontProcessZtkinterr�Zwithdraw�updateZdestroy�	Exceptionrur��format�typer`�reason)r�Z	UOI_FLAGSZWSF_VISIBLEr�Zdll�hZuofZneeded�resr�r�r�r�Zapp_servicesr�ZpsnZpsn_pr��root�eZ
err_stringrd)r�r�rer��sh

r�cCstdkp|tkS)z�Test whether a resource is enabled.

    Known resources are set by regrtest.py.  If not running under regrtest.py,
    all resources are assumed enabled unless use_resources has been set.
    N)r)�resourcerdrdrer $scCs>t|�s |dkrd|}t|��|dkr:t�r:ttj��dS)z@Raise ResourceDenied if the specified resource is not available.Nz"Use of the %r resource not enabled�gui)r rr�r�)r�rxrdrdrer!,scs��fdd�}|S)z�Decorator raising SkipTest if the OS is `sysname` and the version is less
    than `min_version`.

    For example, @_requires_unix_version('FreeBSD', (7, 2)) raises SkipTest if
    the FreeBSD version is less than 7.2.
    cs$tj�����fdd��}�|_|S)Nc
s�tj��krztj�jdd�d}yttt|jd���}Wntk
rLYn.X|�krzdjtt	���}t
jd�||f���||�S)N�-rrryz(%s version %s or higher required, not %s)rp�system�releaser�rr�map�int�
ValueErrorr�rursrt)r��kw�version_txt�version�min_version_txt)r��min_version�sysnamerdre�wrapper=sz:_requires_unix_version.<locals>.decorator.<locals>.wrapper)�	functools�wrapsr�)r�r�)r�r�)r�re�	decorator<sz)_requires_unix_version.<locals>.decoratorrd)r�r�r�rd)r�r�re�_requires_unix_version5sr�cGs
td|�S)z�Decorator raising SkipTest if the OS is FreeBSD and the FreeBSD version is
    less than `min_version`.

    For example, @requires_freebsd_version(7, 2) raises SkipTest if the FreeBSD
    version is less than 7.2.
    ZFreeBSD)r�)r�rdrdrer"PscGs
td|�S)z�Decorator raising SkipTest if the OS is Linux and the Linux version is
    less than `min_version`.

    For example, @requires_linux_version(2, 6, 32) raises SkipTest if the Linux
    version is less than 2.6.32.
    ZLinux)r�)r�rdrdrer#Yscs�fdd�}|S)z�Decorator raising SkipTest if the OS is Mac OS X and the OS X
    version if less than min_version.

    For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
    is lesser than 10.5.
    cs"tj����fdd��}�|_|S)Ncsxtjdkrntj�d}yttt|jd���}Wntk
rBYn,X|�krndjtt	���}t
jd||f���||�S)Nr�rryz&Mac OS X %s or higher required, not %s)rorpZmac_verrrr�r�r�r�r�rursrt)r�r�r�r�r�)r�r�rdrer�js
z4requires_mac_ver.<locals>.decorator.<locals>.wrapper)r�r�r�)r�r�)r�)r�rer�isz#requires_mac_ver.<locals>.decoratorrd)r�r�rd)r�rer$bscs��fdd�}|S)a�Decorator raising SkipTest if a hashing algorithm is not available

    The hashing algorithm could be missing or blocked by a strict crypto
    policy.

    If 'openssl' is True, then the decorator checks that OpenSSL provides
    the algorithm. Otherwise the check falls back to built-in
    implementations.

    ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS
    ValueError: unsupported hash type md4
    cstj�����fdd��}|S)NcsXy&�rtdk	rtj��n
tj��Wn&tk
rLtjd��d���YnX�||�S)Nz
hash digest 'z' is not available.)�_hashlib�new�hashlibr�rsrt)r��kwargs)�
digestnamer��opensslrdrer��sz7requires_hashdigest.<locals>.decorator.<locals>.wrapper)r�r�)r�r�)rr)r�rer��sz&requires_hashdigest.<locals>.decoratorrd)rrr�rd)rrrer%}s
z	127.0.0.1z::1cCs"tj||�}t|�}|j�~|S)a�
Returns an unused port that should be suitable for binding.  This is
    achieved by creating a temporary socket with the same family and type as
    the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to
    the specified host address (defaults to 0.0.0.0) with the port set to 0,
    eliciting an unused ephemeral port from the OS.  The temporary socket is
    then closed and deleted, and the ephemeral port is returned.

    Either this method or bind_port() should be used for any tests where a
    server socket needs to be bound to a particular port for the duration of
    the test.  Which one to use depends on whether the calling code is creating
    a python socket, or if an unused port needs to be provided in a constructor
    or passed to an external program (i.e. the -accept argument to openssl's
    s_server mode).  Always prefer bind_port() over find_unused_port() where
    possible.  Hard coded ports should *NEVER* be used.  As soon as a server
    socket is bound to a hard coded port, the ability to run multiple instances
    of the test simultaneously on the same host is compromised, which makes the
    test a ticking time bomb in a buildbot environment. On Unix buildbots, this
    may simply manifest as a failed test, which can be recovered from without
    intervention in most cases, but on Windows, the entire python process can
    completely and utterly wedge, requiring someone to log in to the buildbot
    and manually kill the affected process.

    (This is easy to reproduce on Windows, unfortunately, and can be traced to
    the SO_REUSEADDR socket option having different semantics on Windows versus
    Unix/Linux.  On Unix, you can't have two AF_INET SOCK_STREAM sockets bind,
    listen and then accept connections on identical host/ports.  An EADDRINUSE
    OSError will be raised at some point (depending on the platform and
    the order bind and listen were called on each socket).

    However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE
    will ever be raised when attempting to bind two identical host/ports. When
    accept() is called on each socket, the second caller's process will steal
    the port from the first caller, leaving them both in an awkwardly wedged
    state where they'll no longer respond to any signals or graceful kills, and
    must be forcibly killed via OpenProcess()/TerminateProcess().

    The solution on Windows is to use the SO_EXCLUSIVEADDRUSE socket option
    instead of SO_REUSEADDR, which effectively affords the same semantics as
    SO_REUSEADDR on Unix.  Given the propensity of Unix developers in the Open
    Source world compared to Windows ones, this is a common mistake.  A quick
    look over OpenSSL's 0.9.8g source shows that they use SO_REUSEADDR when
    openssl.exe is called with the 's_server' option, for example. See
    http://bugs.python.org/issue2550 for more info.  The following site also
    has a very thorough description about the implications of both REUSEADDR
    and EXCLUSIVEADDRUSE on Windows:
    http://msdn2.microsoft.com/en-us/library/ms740621(VS.85).aspx)

    XXX: although this approach is a vast improvement on previous attempts to
    elicit unused ports, it rests heavily on the assumption that the ephemeral
    port returned to us by the OS won't immediately be dished back out to some
    other process when we close and delete our temporary socket but before our
    calling code has a chance to bind the returned port.  We can deal with this
    issue if/when we come across it.
    )�socketrH�close)�familyZsocktypeZtempsock�portrdrdrerG�s
8cCs�|jtjkr�|jtjkr�ttd�r>|jtjtj�dkr>t	d��ttd�r~y |jtjtj
�dkrft	d��Wntk
r|YnXttd�r�|jtjtj
d�|j|df�|j�d}|S)a%Bind the socket to a free port and return the port number.  Relies on
    ephemeral ports in order to ensure we are using an unbound port.  This is
    important as many tests may be running simultaneously, especially in a
    buildbot environment.  This method raises an exception if the sock.family
    is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR
    or SO_REUSEPORT set on it.  Tests should *never* set these socket options
    for TCP/IP sockets.  The only case for setting these options is testing
    multicasting via multiple UDP sockets.

    Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e.
    on Windows), it will be set on the socket.  This will prevent anyone else
    from bind()'ing to our host/port for the duration of the test.
    �SO_REUSEADDRrzHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets!�SO_REUSEPORTzHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!�SO_EXCLUSIVEADDRUSEr)rr�AF_INETr��SOCK_STREAMr�Z
getsockoptZ
SOL_SOCKETrr
rr�Z
setsockoptr�bindZgetsockname)�sock�hostrrdrdrerH�s


cCsJ|jtjkst�y|j|�Wn&tk
rD|j�tjd��YnXdS)zBBind a unix socket, raising SkipTest if PermissionError is raised.zcannot bind AF_UNIX socketsN)	rrZAF_UNIX�AssertionErrorr�PermissionErrorrrsrt)rZaddrrdrdrerJscCsZtjrVd}z<y"tjtjtj�}|jtdf�dStk
rBYnXWd|rT|j�XdS)z+Check whether IPv6 is enabled on this host.NrTF)rZhas_ipv6ZAF_INET6r
r�HOSTv6r�r)rrdrdre�_is_ipv6_enableds

rcstj���fdd��}|S)z5Skip the test on TLS certificate validation failures.csNy�||�Wn:tk
rH}zdt|�kr6tjd���WYdd}~XnXdS)NZCERTIFICATE_VERIFY_FAILEDz.system does not contain necessary certificates)�IOErrorrursrt)r�r�r�)r�rdre�decs
z&system_must_validate_cert.<locals>.dec)r�r�)r�rrd)r�re�system_must_validate_certs	rr�i�ZdoubleZIEEEztest requires IEEE 754 doublesz
requires zlibz
requires gzipzrequires bz2z
requires lzma�java�ANDROID_API_LEVEL�win32z/system/bin/shz/bin/shz$testz@testz	{}_{}_tmp�æ�İ�Ł�φ�К�א�،�ت�ก� �€u-àòɘŁğr�ZNFD�ntr�u-共Ł♡ͣ�ztWARNING: The filename %r CAN be encoded by the filesystem encoding (%s). Unicode filename tests may not be effective��s-��surrogateescape��w����������r�ccs�d}|dkr&tj�}d}tjj|�}nBytj|�d}Wn.tk
rf|sN�tjd|t	dd�YnX|rttj
�}z
|VWd|r�|tj
�kr�t|�XdS)a�Return a context manager that creates a temporary directory.

    Arguments:

      path: the directory to create temporarily.  If omitted or None,
        defaults to creating a temporary directory using tempfile.mkdtemp.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, if the path is specified and cannot be
        created, only a warning is issued.

    FNTz+tests may fail, unable to create temp dir: �)r�)�tempfile�mkdtempr�r��realpath�mkdirr�rgr�r��getpidr)r��quietZdir_created�pidrdrdre�temp_dir�s&


r3ccsftj�}ytj|�Wn.tk
rD|s,�tjd|tdd�YnXztj�VWdtj|�XdS)agReturn a context manager that changes the current working directory.

    Arguments:

      path: the directory to use as the temporary current working directory.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, it issues only a warning and keeps the current
        working directory the same.

    z)tests may fail, unable to change CWD to: r+)r�N)r��getcwd�chdirr�rgr�r�)r�r1Z	saved_dirrdrdre�
change_cwd	s

r6�tempcwdccs:t||d��$}t||d��}|VWdQRXWdQRXdS)a�
    Context manager that temporarily creates and changes the CWD.

    The function temporarily changes the current working directory
    after creating a temporary directory in the current directory with
    name *name*.  If *name* is None, the temporary directory is
    created using tempfile.mkdtemp.

    If *quiet* is False (default) and it is not possible to
    create or change the CWD, an error is raised.  If *quiet* is True,
    only a warning is raised and the original CWD is used.

    )r�r1)r1N)r3r6)rvr1Z	temp_pathZcwd_dirrdrdrer$s�umaskccs&tj|�}z
dVWdtj|�XdS)z8Context manager that temporarily sets the process umask.N)r�r8)r8ZoldmaskrdrdrerK8s

�datacCsbtjj|�r|S|dk	r&tjj||�}tgtj}x*|D]"}tjj||�}tjj|�r8|Sq8W|S)a[Try to find a file on sys.path or in the test directory.  If it is not
    found the argument passed to the function is returned (this does not
    necessarily signal failure; could still be the legitimate path).

    Setting *subdir* indicates a relative path to use to find the file
    rather than looking directly in the path directories.
    N)r�r��isabsr��
TEST_HOME_DIRro�exists)r�Zsubdirr�Zdn�fnrdrdrerIs
cCs(tj|tjtjBtjB�}tj|�dS)z>Create an empty file. If the file already exists, truncate it.N)r��open�O_WRONLY�O_CREAT�O_TRUNCr)r��fdrdrdrer[scCs,t|j��}dd�|D�}dj|�}d|S)z%Like repr(dict), but in sorted order.cSsg|]}d|�qS)z%r: %rrd)�.0Zpairrdrdre�
<listcomp>cszsortdict.<locals>.<listcomp>z, z{%s})�sortedr�r�)�dictr�Z	reprpairsZ
withcommasrdrdrer[`s
cCs*ttd�}z|j�S|j�tt�XdS)z`
    Create an invalid file descriptor by opening and closing a file and return
    its fd.
    �wbN)r>r�filenorr)r�rdrdre�make_bad_fdgs

rI)�lineno�offsetcCsp|jt��}t|dd�WdQRX|j}|j|j�|dk	rJ|j|j|�|j|j�|dk	rl|j|j|�dS)Nz
<test string>�exec)�assertRaises�SyntaxError�compileZ	exceptionZassertIsNotNonerJ�assertEqualrK)�testcaseZ	statementrJrK�cmr�rdrdrer&sscsVddl}ddl}�jdd��|jj|�djd�d}tjjt	|�}���fdd�}tjj
|�r|||�}|dk	rt|St|�td�t
r�td	|t�d
�|jj�}tr�|jjd�|j|d
d�}tr�|jjd�dkr�tj|d�}zBt|d��.}	|j�}
x|
�r|	j|
�|j�}
�q�WWdQRXWd|j�X||�}|dk	�rF|Std|��dS)Nr�checkr��/rcs>t|f����}�dkr|S�|�r2|jd�|S|j�dS)Nr)r>�seekr)r=r�)r�rSr�rdre�check_valid_file�s
z*open_urlresource.<locals>.check_valid_fileZurlfetchz	fetching %s ...)r��Accept-Encoding�gzip�)r�zContent-Encoding)ZfileobjrGzinvalid resource %r���)rWrX)Zurllib.requestZurllib.parse�pop�parseZurlparser�r�r�r��
TEST_DATA_DIRr<rr!rr�rZrequestZbuild_openerrXZ
addheadersr�r>Zheaders�getZGzipFile�read�writerr
)Zurlr�r��urllibr�r=rVr��opener�out�srd)r�rSr�rerI~s<	



c@s4eZdZdZdd�Zdd�Zedd��Zdd	�Zd
S)�WarningsRecorderzyConvenience wrapper for the warnings list returned on
       entry to the warnings.catch_warnings() context manager.
    cCs||_d|_dS)Nr)�	_warnings�_last)�selfZ
warnings_listrdrdre�__init__�szWarningsRecorder.__init__cCsDt|j�|jkr t|jd|�S|tjjkr0dStd||f��dS)Nrz%r has no attribute %rrZ)r�rfrgr�rg�WarningMessage�_WARNING_DETAILSr�)rh�attrrdrdre�__getattr__�s
zWarningsRecorder.__getattr__cCs|j|jd�S)N)rfrg)rhrdrdrerg�szWarningsRecorder.warningscCst|j�|_dS)N)r�rfrg)rhrdrdre�reset�szWarningsRecorder.resetN)	r`rarbrcrirm�propertyrgrnrdrdrdrere�s
rec
cs
tjd�}|jjd�}|r"|j�tjdd�� }tjdjd�t	|�VWdQRXt
|�}g}xz|D]r\}}d}	xH|dd�D]8}|j}
tj
|t|
�tj�r�t|
j|�r�d}	|j|�q�W|	rf|rf|j||jf�qfW|r�td	|d
��|�rtd|d
��dS)z�Catch the warnings, then check if all the expected
    warnings have been raised and re-raise unexpected warnings.
    If 'quiet' is True, only re-raise the unexpected warnings.
    r�Z__warningregistry__T)�recordrg�alwaysNFzunhandled warning %srz)filter (%r, %s) did not catch any warning)ro�	_getframe�	f_globalsr^�clearrgrhrz�simplefilterrer|�message�re�matchru�I�
issubclassr��remover�r`r)�filtersr1�frame�registry�wZreraiseZmissingrx�cat�seenZwarningrdrdre�_filterwarnings�s0
r�cOs.|jd�}|s$dtff}|dkr$d}t||�S)a�Context manager to silence warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default True without argument,
         default False if some filters are defined)

    Without argument, it defaults to:
        check_warnings(("", Warning), quiet=True)
    r1r�NT)r^�Warningr�)r|r�r1rdrdrerR�s

r�ccsHtjdd��&}tjd||d�dV|r.t�WdQRX|j|g�dS)a�Context manager to check that no warnings are emitted.

    This context manager enables a given warning within its scope
    and checks that no warnings are emitted even with that warning
    enabled.

    If force_gc is True, a garbage collection is attempted before checking
    for warnings. This may help to catch warnings emitted when objects
    are deleted, such as ResourceWarning.

    Other keyword arguments are passed to warnings.filterwarnings().
    T)rprq)rv�categoryN)rgrhri�
gc_collectrP)rQrvr�Zforce_gc�warnsrdrdre�check_no_warningssr�ccsBtjdd�� }tjdtd�dVt�WdQRX|j|g�dS)a"Context manager to check that no ResourceWarning is emitted.

    Usage:

        with check_no_resource_warning(self):
            f = open(...)
            ...
            del f

    You must remove the object which may emit ResourceWarning before
    the end of the context manager.
    T)rprq)r�N)rgrhri�ResourceWarningr�rP)rQr�rdrdrerSs
c@s(eZdZdZdd�Zdd�Zdd�ZdS)	ra,Context manager to force import to return a new module reference.

    This is useful for testing module-level behaviours, such as
    the emission of a DeprecationWarning on import.

    Use like this:

        with CleanImport("foo"):
            importlib.import_module("foo") # new reference
    cGsNtjj�|_x<|D]4}|tjkrtj|}|j|kr>tj|j=tj|=qWdS)N)rorz�copy�original_modulesr`)rhZmodule_namesZmodule_namer�rdrdreri?s




zCleanImport.__init__cCs|S)Nrd)rhrdrdre�	__enter__LszCleanImport.__enter__cGstjj|j�dS)N)rorzr�r�)rh�
ignore_excrdrdre�__exit__OszCleanImport.__exit__N)r`rarbrcrir�r�rdrdrdrer3s

c@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)rTz_Class to help protect the environment variable properly.  Can be used as
    a context manager.cCstj|_i|_dS)N)r��environ�_environ�_changed)rhrdrdreriXszEnvironmentVarGuard.__init__cCs
|j|S)N)r�)rh�envvarrdrdre�__getitem__\szEnvironmentVarGuard.__getitem__cCs*||jkr|jj|�|j|<||j|<dS)N)r�r�r^)rhr��valuerdrdre�__setitem___s
zEnvironmentVarGuard.__setitem__cCs2||jkr|jj|�|j|<||jkr.|j|=dS)N)r�r�r^)rhr�rdrdre�__delitem__es

zEnvironmentVarGuard.__delitem__cCs
|jj�S)N)r��keys)rhrdrdrer�lszEnvironmentVarGuard.keyscCs
t|j�S)N)�iterr�)rhrdrdre�__iter__oszEnvironmentVarGuard.__iter__cCs
t|j�S)N)r�r�)rhrdrdre�__len__rszEnvironmentVarGuard.__len__cCs|||<dS)Nrd)rhr�r�rdrdre�setuszEnvironmentVarGuard.setcCs
||=dS)Nrd)rhr�rdrdre�unsetxszEnvironmentVarGuard.unsetcCs|S)Nrd)rhrdrdrer�{szEnvironmentVarGuard.__enter__cGsJx<|jj�D].\}}|dkr0||jkr:|j|=q||j|<qW|jt_dS)N)r�r�r�r�r�)rhr��k�vrdrdrer�~s

zEnvironmentVarGuard.__exit__N)r`rarbrcrir�r�r�r�r�r�r�r�r�r�rdrdrdrerTSsc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
DirsOnSysPatha�Context manager to temporarily add directories to sys.path.

    This makes a copy of sys.path, appends any directories given
    as positional arguments, then reverts sys.path to the copied
    settings when the context ends.

    Note that *all* sys.path modifications in the body of the
    context manager, including replacement of the object,
    will be reverted at the end of the block.
    cGs(tjdd�|_tj|_tjj|�dS)N)ror��original_value�original_object�extend)rh�pathsrdrdreri�szDirsOnSysPath.__init__cCs|S)Nrd)rhrdrdrer��szDirsOnSysPath.__enter__cGs|jt_|jtjdd�<dS)N)r�ror�r�)rhr�rdrdrer��szDirsOnSysPath.__exit__N)r`rarbrcrir�r�rdrdrdrer��s
r�c@s*eZdZdZdd�Zdd�Zd	dd�ZdS)
r'z�Raise ResourceDenied if an exception is raised while the context manager
    is in effect that matches the specified exception and attributes.cKs||_||_dS)N)r��attrs)rhr�r�rdrdreri�szTransientResource.__init__cCs|S)Nrd)rhrdrdrer��szTransientResource.__enter__NcCsT|dk	rPt|j|�rPx:|jj�D]$\}}t||�s4Pt||�|kr Pq Wtd��dS)z�If type_ is a subclass of self.exc and value has attributes matching
        self.attrs, raise ResourceDenied.  Otherwise let the exception
        propagate (if any).Nz%an optional resource is not available)rzr�r�r�r�r�r)rhZtype_r��	tracebackrlZ
attr_valuerdrdrer��s
zTransientResource.__exit__)NNN)r`rarbrcrir�r�rdrdrdrer'�s)�errnog>@)r��errnosc	#spd!d"d#d$d%d&g}d(d*d,d.d/g}td|��|�g��sRdd�|D��dd�|D�����fdd�}tj�}z�y|dk	r�tj|�dVWn�tjk
�r�}z&tr�tjj	�j
dd��|�WYdd}~Xn�tk
�rZ}zpx^|j
}t|�d k�rt
|dt��r|d}n*t|�dk�r8t
|d t��r8|d }nP�q�W||��WYdd}~XnXWdtj|�XdS)0z�Return a context manager that raises ResourceDenied when various issues
    with the Internet connection manifest themselves as exceptions.�ECONNREFUSED�o�
ECONNRESET�h�EHOSTUNREACH�q�ENETUNREACH�e�	ETIMEDOUT�n�
EADDRNOTAVAIL�c�	EAI_AGAINr+�EAI_FAILr��
EAI_NONAMEr��
EAI_NODATA��
WSANO_DATA�*zResource %r is not availablecSsg|]\}}tt||��qSrd)r�r�)rCrv�numrdrdrerD�sz&transient_internet.<locals>.<listcomp>cSsg|]\}}tt||��qSrd)r�r)rCrvr�rdrdrerD�scs�t|dd�}t|tj�s�t|tj�r,|�ks�t|tjj�rTd|jkoNdkns�t|tjj	�r�d|j
ks�d|j
ks�d|j
ks�|�kr�ts�tj
j�jdd��|�dS)	Nr�i�iW�ConnectionRefusedError�TimeoutError�EOFErrorr�
)r��
isinstancerr�Zgaierrorra�errorZ	HTTPError�codeZURLErrorr�rro�stderrr`r�)r��n)�captured_errnos�denied�
gai_errnosrdre�filter_error�s


z(transient_internet.<locals>.filter_errorNrr�r)r�r�)r�r�)r�r�)r�r�)r�r�)r�r����)r�r����)r�r����)r�r����)r�r�)r�r�)rrZgetdefaulttimeoutZsetdefaulttimeout�nntplibZNNTPTemporaryErrorrror�r`r�r�r�r�)	Z
resource_namer�r�Zdefault_errnosZdefault_gai_errnosr�Zold_timeoutr��ard)r�r�r�rer+�sP



c
csFddl}tt|�}tt||j��ztt|�VWdtt||�XdS)z�Return a context manager used by captured_stdout/stdin/stderr
    that temporarily replaces the sys stream *stream_name* with a StringIO.rN)�ior�ro�setattr�StringIO)Zstream_namer�Zorig_stdoutrdrdre�captured_outputs
r�cCstd�S)z�Capture the output of sys.stdout:

       with captured_stdout() as stdout:
           print("hello")
       self.assertEqual(stdout.getvalue(), "hello\n")
    r�)r�rdrdrdrerscCstd�S)z�Capture the output of sys.stderr:

       with captured_stderr() as stderr:
           print("hello", file=sys.stderr)
       self.assertEqual(stderr.getvalue(), "hello\n")
    r�)r�rdrdrdrer%scCstd�S)a	Capture the input to sys.stdin:

       with captured_stdin() as stdin:
           stdin.write('hello\n')
           stdin.seek(0)
           # call test code that consumes from sys.stdin
           captured = input()
       self.assertEqual(captured, "hello")
    �stdin)r�rdrdrdrer.s
cCs*tj�trtjd�tj�tj�dS)a�Force as many objects as possible to be collected.

    In non-CPython implementations of Python, this is needed because timely
    deallocation is not guaranteed by the garbage collector.  (Even in CPython
    this can be the case in case of reference cycles.)  This means that __del__
    methods may be called later than expected and weakrefs may remain alive for
    longer than expected.  This function tries its best to force all garbage
    objects to disappear.
    g�������?N)�gcZcollectr@r�r�rdrdrdrer�;s


r�c
cs.tj�}tj�z
dVWd|r(tj�XdS)N)r��	isenabled�disable�enable)Zhave_gcrdrdre�
disable_gcKs
r�cCs:tjd�pd}d}x|j�D]}|jd�r|}qW|dkS)z,Find if Python was built with optimizations.�	PY_CFLAGSr�z-O�-O0�-Og)r�r�r�)�	sysconfig�get_config_varr�rq)ZcflagsZ	final_optr�rdrdre�python_is_optimizedVs
r�ZnPZ0n�gettotalrefcountZ2PZ0Pr�cCstjt|t�S)N)�struct�calcsize�_header�_align)�fmtrdrdre�calcobjsizegsr�cCstjt|t�S)N)r�r��_vheaderr�)r�rdrdre�calcvobjsizejsr���	cCspddl}tj|�}t|�tkr(|jt@sBt|�tkrLt|�jt@rL||j7}dt|�||f}|j|||�dS)Nrz&wrong size for %s: got %d, expected %d)	�	_testcapiro�	getsizeofr��	__flags__�_TPFLAGS_HEAPTYPE�_TPFLAGS_HAVE_GCZSIZEOF_PYGC_HEADrP)�test�o�sizer�r�rxrdrdre�check_sizeofqs

r�cs��fdd�}|S)Ncs$���fdd�}�j|_�j|_|S)Ncs�y ddl}t|��}|j|�}Wn(tk
r6�YnBd}}Yn0Xx,�D]$}y|j||�PWqPYqPXqPWz
�||�S|r�|r�|j||�XdS)Nr)�localer��	setlocaler�)r��kwdsr�r�Zorig_locale�loc)�catstrr��localesrdre�inner�s$



z1run_with_locale.<locals>.decorator.<locals>.inner)r`rc)r�r�)r�r�)r�rer��sz"run_with_locale.<locals>.decoratorrd)r�r�r�rd)r�r�rerU�scs�fdd�}|S)Ncs"��fdd�}�j|_�j|_|S)Ncs�y
tj}Wntk
r(tjd��YnXdtjkr@tjd}nd}�tjd<|�z
�||�S|dkrrtjd=n
|tjd<tj�XdS)Nztzset requiredZTZ)r��tzsetr�rsrtr�r�)r�r�r�Zorig_tz)r��tzrdrer��s





z-run_with_tz.<locals>.decorator.<locals>.inner)r`rc)r�r�)r�)r�rer��szrun_with_tz.<locals>.decoratorrd)r�r�rd)r�rer\�scCs�dttdtd�}tjd|tjtjB�}|dkr>td|f��tt|j	d��||j	d�j
��}|a|tkrrt}|t
dkr�td|f��|adS)Ni)r��m�g�tz(\d+(\.\d+)?) (K|M|G|T)b?$zInvalid memory limit %rrr+z$Memory limit %r too low to be useful)�_1M�_1Grwrx�
IGNORECASE�VERBOSEr�r��float�group�lower�real_max_memuse�MAX_Py_ssize_t�_2Gr)�limitZsizesr�ZmemlimitrdrdrerY�s$c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_MemoryWatchdogz`An object which periodically watches the process' memory consumption
    and prints it out.
    cCsdjtj�d�|_d|_dS)Nz/proc/{pid}/statm)r2F)r�r�r0�procfile�started)rhrdrdreri�sz_MemoryWatchdog.__init__cCs�yt|jd�}Wn<tk
rL}z tjdj|�t�tjj	�dSd}~XnXt
d�}tjtj
|g|tjd�|_|j�d|_dS)N�rz!/proc not available for stats: {}zmemory_watchdog.py)r�r�T)r>r
r�rgr�r�r�ror��flushr�
subprocess�Popen�
executableZDEVNULL�mem_watchdogrr)rhr�r�Zwatchdog_scriptrdrdre�start�s
z_MemoryWatchdog.startcCs|jr|jj�|jj�dS)N)rrZ	terminate�wait)rhrdrdre�stop�s
z_MemoryWatchdog.stopN)r`rarbrcrirrrdrdrdrer	�sr	cs���fdd�}|S)atDecorator for bigmem tests.

    'size' is a requested size for the test (in arbitrary, test-interpreted
    units.) 'memuse' is the number of bytes per unit for the test, or a good
    estimate of it. For example, a test that needs two byte buffers, of 4 GiB
    each, could be decorated with @bigmemtest(size=_4G, memuse=2).

    The 'size' argument is normally passed to the decorated test method as an
    extra argument. If 'dry_run' is true, the value passed to the test method
    may be less than the requested value. If 'dry_run' is false, it means the
    test doesn't support dummy runs when -M is not specified.
    cs ���fdd����_��_�S)Nc
s��j}�j}tsd}n|}ts$�rFt||krFtjd||d��tr|tr|t�tdj||dd��t�}|j	�nd}z
�||�S|r�|j
�XdS)	Niz'not enough memory: %.1fG minimum neededir+z* ... expected peak memory use: {peak:.1f}G)Zpeaki@i@)r��memuserrsrtrr�r�r	rr)rhr�r�maxsizeZwatchdog)�dry_runr�r�rdrer�s*


z.bigmemtest.<locals>.decorator.<locals>.wrapper)r�r)r�)rrr�)r�r�rer�szbigmemtest.<locals>.decoratorrd)r�rrr�rd)rrr�rer3s
!cs�fdd�}|S)z0Decorator for tests that fill the address space.csDttkr8td
kr$tdkr$tjd��q@tjdtd��n�|�SdS)
Nr��?r�z-not enough memory: try a 32-bit build insteadz'not enough memory: %.1fG minimum neededir+ll����li@)rrrsrt)rh)r�rdrer�3sz!bigaddrspacetest.<locals>.wrapperrd)r�r�rd)r�rer41sc@seZdZdd�ZdS)r,cCstj�}||�|S)N)rsZ
TestResult)rhr�r�rdrdre�runDszBasicTestRunner.runN)r`rarbrrdrdrdrer,CscCs|S)Nrd)r�rdrdre�_idIsrcCs<|dkrt�rtjtj�St|�r(tStjdj|��SdS)Nr�zresource {0!r} is not enabled)r�rs�skipr�r rr�)r�rdrdre�requires_resourceLs
rcCs&trt|krtjd|tf�StSdS)Nz%s at Android API level %d)rA�_ANDROID_API_LEVELrsrr)�levelr�rdrdrer>TscCstdd�|�S)z9
    Decorator for tests only applicable on CPython.
    T)�cpython)�impl_detail)r�rdrdrer5[scKsVtf|�rtS|dkrLt|�\}}|r,d}nd}t|j��}|jdj|��}tj|�S)Nz*implementation detail not available on {0}z%implementation detail specific to {0}z or )	rBr�
_parse_guardsrEr�r�r�rsr)rx�guardsZ
guardnames�defaultrdrdrer!as
r!cCsTtdkr:ddl}y|j�daWntk
r8daYnXd}trF|Stj|�|�S)z8Skip decorator for tests that use multiprocessing.Queue.NrTFz6requires a functioning shared semaphore implementation)�_have_mp_queue�multiprocessingZQueuernrsr)r�r&rxrdrdrer?os
cCsH|sddidfSt|j��d}t|j��|gt|�ks>t�||fS)Nr TFr)r|�valuesr�r)r#Zis_truerdrdrer"~s
r"cKs t|�\}}|jtj�j�|�S)a5This function returns True or False depending on the host platform.
       Examples:
          if check_impl_detail():               # only on CPython (default)
          if check_impl_detail(jython=True):    # only on Jython
          if check_impl_detail(cpython=False):  # everywhere except on CPython
    )r"r^rpZpython_implementationr)r#r$rdrdrerB�scs,ttd�s�Stj���fdd��}|SdS)zEDecorator to temporarily turn off tracing for the duration of a test.�gettracecs.tj�}ztjd��||�Stj|�XdS)N)ror(�settrace)r�r�Zoriginal_trace)r�rdrer��s


zno_tracing.<locals>.wrapperN)r�ror�r�)r�r�rd)r�re�
no_tracing�s
r*cCstt|��S)aDecorator for tests which involve reference counting.

    To start, the decorator does not run the test if is not run by CPython.
    After that, any trace function is unset during the test to prevent
    unexpected refcounts caused by the trace function.

    )r*r5)r�rdrdre�
refcount_test�sr+cCsRg}xB|jD]8}t|tj�r2t||�|j|�q||�r|j|�qW||_dS)z>Recursively filter test cases in a suite based on a predicate.N)Z_testsr�rs�	TestSuite�
_filter_suiter�)�suiteZpredZnewtestsr�rdrdrer-�s
r-cCs�ttjttdk	d�}|j|�}tdk	r4tj|j��|js>t	�|j
�s�t|j�dkrl|j
rl|jdd}n6t|j
�dkr�|jr�|j
dd}nd}ts�|d7}t|��dS)z2Run tests from a unittest.TestSuite-derived class.N)�	verbosityZcapture_outputrrzmultiple errors occurredz!; run in verbose mode for details)rror�r�junit_xml_listrr�Zget_xml_elementZtestsRunrZ
wasSuccessfulr��errorsZfailuresr
)r.Zrunnerr�r�rdrdre�
_run_suite�s"
r2cCstdkrdSt|j��SdS)NT)�_match_test_func�id)r�rdrdre�
match_test�sr5cCsd|kotjd|�S)Nryz[?*\[\]])rw�search)r�rdrdre�_is_full_match_test�sr7csr|tkrdS|sd}f}nHttt|��r4t|�j}n.djttj|��}t	j
|�j��fdd�}|}t|�a|a
dS)N�|cs$�|�rdStt�|jd���SdS)NTry)�anyr�r�)Ztest_id)�regex_matchrdre�match_test_regex�sz)set_match_tests.<locals>.match_test_regex)�_match_test_patterns�allr�r7r��__contains__r��fnmatch�	translaterwrOrxrrr3)Zpatternsr�Zregexr;rd)r:re�set_match_tests�srAcGs�tjtjf}tj�}xh|D]`}t|t�rT|tjkrJ|jtjtj|��qzt	d��qt||�rj|j|�q|jtj
|��qWt|t�t
|�dS)z1Run tests from unittest.TestCase-derived classes.z)str arguments must be keys in sys.modulesN)rsr,ZTestCaser�rurorzZaddTestZ
findTestCasesr�Z	makeSuiter-r5r2)�classesZvalid_typesr.�clsrdrdrer-s





cCsdS)z,Just used to check if docstrings are enabledNrdrdrdrdre�_check_docstrings(srD�WITH_DOC_STRINGSztest requires docstringscCs`ddl}|dkrt}nd}|j|||d�\}}|rBtd||f��trXtd|j|f�||fS)aRun doctest on the given module.  Return (#failures, #tests).

    If optional argument verbosity is not specified (or is None), pass
    support's belief about verbosity on to doctest.  Else doctest's
    usual behavior is used (it searches sys.argv for -v).
    rN)r�optionflagsz%d of %d doctests failedz,doctest (%s) ... %d tests with zero failures)�doctestrZtestmodr
r�r`)r�r/rFrGr�r�rdrdrer.9scCstjj�fS)N)rorzr�rdrdrdre�
modules_setupTsrHcCs:dd�tjj�D�}tjj�tjj|�tjj|�dS)NcSs"g|]\}}|jd�r||f�qS)z
encodings.)rq)rCr�r�rdrdrerD[sz#modules_cleanup.<locals>.<listcomp>)rorzr�rtr�)Z
oldmodulesZ	encodingsrdrdre�modules_cleanupWs
rIcCs"trtj�tjj�fSdffSdS)Nr)�_thread�_count�	threading�	_danglingr�rdrdrdrerNzscGsJtsdSd}x8t|�D],}tj�tjf}||kr2Ptjd�t�qWdS)N�dg{�G�z�?)rJ�rangerKrLrMr�r�r�)Zoriginal_valuesZ
_MAX_COUNT�countr'rdrdrerO�s
cs"ts�Stj���fdd��}|S)z�Use this function when threads are being used.  This will
    ensure that the threads are cleaned up even when the test fails.
    If threading is unavailable this function does nothing.
    cst�}z�|�St|�XdS)N)rNrO)r��key)r�rdrer��szreap_threads.<locals>.decorator)rJr�r�)r�r�rd)r�rerP�s�N@ccs�tj�}z
dVWdtj�}||}xjtj�}||kr8Ptj�|kr|tj�|}d||�d|d�d|�d|�d�	}t|��tjd�t�q&WXdS)	aH
    bpo-31234: Context manager to wait until all threads created in the with
    statement exit.

    Use _thread.count() to check if threads exited. Indirectly, wait until
    threads exit the internal t_bootstrap() C function of the _thread module.

    threading_setup() and threading_cleanup() are designed to emit a warning
    if a test leaves running threads in the background. This context manager
    is designed to cleanup threads started by the _thread.start_new_thread()
    which doesn't allow to wait for thread exit, whereas thread.Thread has a
    join() method.
    Nz!wait_threads() failed to cleanup z threads after z.1fz seconds (count: z
, old count: �)g{�G�z�?)rJrKr�Z	monotonicrr�r�)r�Z	old_countZ
start_timeZdeadlinerPZdtrxrdrdre�wait_threads_exit�s
$
rTc
CsZttd�rVd}xFy2tj|tj�\}}|dkr.Ptd|tjd�WqPYqXqWdS)z�Use this function at the end of test_main() whenever sub-processes
    are started.  This will help ensure that no extra children (zombies)
    stick around to hog resources and create problems when looking
    for refleaks.
    �waitpidrrz2Warning -- reap_children() reaped child process %s)r�NrZ)r�r�rU�WNOHANGr�ror�)Zany_processr2ZstatusrdrdrerL�s
ccs*t|�}g}zZy$x|D]}|j�|j|�qWWn*trVtdt|�t|�f��YnXdVWdz�|rt|�tj�}}xltdd�D]^}|d7}x$|D]}|jt	|tj�d��q�Wdd�|D�}|s�Ptr�tdt|�|f�q�WWdd	d�|D�}|�r"t
jtj
�td
t|���XXdS)Nz/Can't start %d threads, only %d threads startedrr�<g{�G�z�?cSsg|]}|j�r|�qSrd)�isAlive)rCr�rdrdrerD�sz!start_threads.<locals>.<listcomp>z7Unable to join %d threads during a period of %d minutescSsg|]}|j�r|�qSrd)rX)rCr�rdrdrerD�szUnable to join %d threads)r|rr�rr�r�r�rOr��max�faulthandlerZdump_tracebackror�r)ZthreadsZunlockrr�ZendtimeZ	starttimer�rdrdrerQ�s>


c
csnt||�r<t||�}t|||�z
|VWdt|||�Xn.t|||�z
dVWdt||�rht||�XdS)a�Temporary swap out an attribute with a new object.

    Usage:
        with swap_attr(obj, "attr", 5):
            ...

        This will set obj.attr to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `attr` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.

        The old value (or None if it doesn't exist) will be assigned to the
        target of the "as" clause, if there is one.
    N)r�r�r��delattr)r�rl�new_val�real_valrdrdrerW�s




ccsX||kr0||}|||<z
|VWd|||<Xn$|||<z
dVWd||krR||=XdS)a�Temporary swap out an item with a new object.

    Usage:
        with swap_item(obj, "item", 5):
            ...

        This will set obj["item"] to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `item` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.

        The old value (or None if it doesn't exist) will be assigned to the
        target of the "as" clause, if there is one.
    Nrd)r��itemr\r]rdrdrerV	s

cCstjdd|�j�}|S)z�Strip the stderr of a Python process from potential debug output
    emitted by the interpreter.

    This will typically be run on the result of the communicate() method
    of a subprocess.Popen object.
    s\[\d+ refs, \d+ blocks\]\r?\n?�)rw�sub�strip)r�rdrdre�strip_python_stderr8	srbZ	getcountsz-types are immortal if COUNT_ALLOCS is definedcCstj�S)znReturn a list of command-line arguments reproducing the current
    settings in sys.flags and sys.warnoptions.)rZ_args_from_interpreter_flagsrdrdrdre�args_from_interpreter_flagsE	srccCstj�S)zgReturn a list of command-line arguments reproducing the current
    optimization settings in sys.flags.)rZ"_optim_args_from_interpreter_flagsrdrdrdre�!optim_args_from_interpreter_flagsJ	srdc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rMcCstjjj|d�||_dS)Nr)�logging�handlers�BufferingHandlerri�matcher)rhrhrdrdreriT	szTestHandler.__init__cCsdS)NFrd)rhrdrdre�shouldFlush]	szTestHandler.shouldFlushcCs|j|�|jj|j�dS)N)r�r�r��__dict__)rhrprdrdre�emit`	s
zTestHandler.emitcKs.d}x$|jD]}|jj|f|�rd}PqW|S)zW
        Look for a saved dict whose keys/values match the supplied arguments.
        FT)r�rh�matches)rhr�r��drdrdrerld	szTestHandler.matchesN)r`rarbririrkrlrdrdrdrerMS	s	c@s eZdZdZdd�Zdd�ZdS)	rXrxrvcKs<d}x2|D]*}||}|j|�}|j|||�s
d}Pq
W|S)a.
        Try to match a single dict with the supplied arguments.

        Keys whose values are strings and which are in self._partial_matches
        will be checked for partial (i.e. substring) matches. You can extend
        this scheme to (for example) do regular expression matching, etc.
        TF)r^�match_value)rhrmr�r�r�r��dvrdrdrerls	s

zMatcher.matchescCsHt|�t|�krd}n.t|�tk	s,||jkr6||k}n|j|�dk}|S)zT
        Try to match a single stored value (dv) with a supplied value (v).
        Fr)r�ru�_partial_matches�find)rhr�ror�r�rdrdrern�	s
zMatcher.match_valueN)rxrv)r`rarbrprlrnrdrdrdrerXo	sc
CsZtdk	rtStd}ytjt|�d}Wntttfk
rFd}YnXtj|�|a|S)NrTF)�_can_symlinkrr��symlinkr��NotImplementedErrorr�r{)Zsymlink_path�canrdrdrer�	s

cCs t�}d}|r|Stj|�|�S)z8Skip decorator for tests that require functional symlinkz*Requires functional symlink implementation)rrsr)r��okrxrdrdrer/�	scCs�tdk	rtSttd�sd}n�tj�}tj|d�\}}z�ttd���}y`tj|dd�tj|dd�tj|j	�dd�t
j�}tj
d	|�}|dkp�t|jd
��dk}Wntk
r�d}YnXWdQRXWdtt�t|�t|�X|a|S)N�setxattrF)�dirrGs	user.testr_strusted.foos42z
2.6.(\d{1,2})r�')�
_can_xattrr�r�r,r-Zmkstempr>rrwrHrpr�rwrxr�rr�rr�)ruZtmp_dirZtmp_fpZtmp_name�fpZkernel_versionr�rdrdre�	can_xattr�	s,

r|cCs t�}d}|r|Stj|�|�S)zDSkip decorator for tests that require functional extended attributesz(no non-broken extended attribute support)r|rsr)r�rvrxrdrdrer8�	scCs$tpt}d}|r|Stj|�|�S)z;Skip decorator for tests not run in (non-extended) PGO taskz#Not run for (non-extended) PGO task)r]�PGO_EXTENDEDrsr)r�rvrxrdrdre�skip_if_pgo_task�	s
r~cCs^tj|d��H}|j}|j�}||kr,|j�}ytjj||�Stk
rNdSXWdQRXdS)zKDetects if the file system for the specified directory is case-insensitive.)rxFN)	r,ZNamedTemporaryFilerv�upperrr�r��samefiler�)Z	directory�base�	base_pathZ	case_pathrdrdrer�	s)rfcCs>tt|��tt|��}|r(|t|�8}tdd�|D��}|S)aReturns the set of items in ref_api not in other_api, except for a
    defined list of items to be ignored in this check.

    By default this skips private attributes beginning with '_' but
    includes all magic methods, i.e. those starting and ending in '__'.
    css(|] }|jd�s|jd�r|VqdS)�_�__N)rq�endswith)rCr�rdrdre�	<genexpr>�	sz&detect_api_mismatch.<locals>.<genexpr>)r�rx)Zref_apiZ	other_apirfZ
missing_itemsrdrdrer<�	s
cCs�|dkr|jf}nt|t�r"|f}t|�}xbt|�D]V}|jd�s4||krLq4t||�}t|dd�|ks�t|d�r4t|tj	�r4|j
|�q4W|j|j|�dS)aAssert that the __all__ variable of 'module' contains all public names.

    The module's public names (its API) are detected automatically based on
    whether they match the public name convention and were defined in
    'module'.

    The 'name_of_module' argument can specify (as a string or tuple thereof)
    what module(s) an API could be defined in in order to be detected as a
    public API. One case for this is when 'module' imports part of its public
    API from other modules, possibly a C backend (like 'csv' and its '_csv').

    The 'extra' argument can be a set of names that wouldn't otherwise be
    automatically detected as "public", like objects without a proper
    '__module__' attribute. If provided, it will be added to the
    automatically detected ones.

    The 'blacklist' argument can be a set of names that must not be treated
    as part of the public API even though their names indicate otherwise.

    Usage:
        import bar
        import foo
        import unittest
        from test import support

        class MiscTestCase(unittest.TestCase):
            def test__all__(self):
                support.check__all__(self, foo)

        class OtherTestCase(unittest.TestCase):
            def test__all__(self):
                extra = {'BAR_CONST', 'FOO_CONST'}
                blacklist = {'baz'}  # Undocumented name.
                # bar imports part of its API from _bar.
                support.check__all__(self, bar, ('bar', '_bar'),
                                     extra=extra, blacklist=blacklist)

    Nr�ra)
r`r�rur�rxrqr�r��types�
ModuleType�addZassertCountEqual�__all__)Z	test_caser�Zname_of_moduleZextraZ	blacklistZexpectedrvr�rdrdrer=�	s)


c@s(eZdZdZdZdZdd�Zdd�ZdS)rZz�Try to prevent a crash report from popping up.

    On Windows, don't display the Windows Error Reporting dialog.  On UNIX,
    disable the creation of coredump file.
    Nc
Csrtjjd�r�ddl}|jj|_d}|jj|�|_|jj|j|B�yddl	}|j
Wnttfk
rlYnLXi|_
x�|j|j|jgD].}|j
||j�}|j||j�}||f|j
|<q�Wn�tdk	�r
y*tjtj�|_tjtjd|jdf�Wnttfk
�rYnXtjdk�rnddd	d
g}tj|tjtjd�}|�|j�d}	WdQRX|	j�dk�rntd
ddd�|S)z�On Windows, disable Windows Error Reporting dialogs using
        SetErrorMode.

        On UNIX, try to save the previous core file size limit, then set
        soft limit to 0.
        r�rNr�rr�z/usr/bin/defaultsr_zcom.apple.CrashReporterZ
DialogType)r�r�s	developerz:this test triggers the Crash Reporter, that is intentionalr�T)�endr
) rorprqr�r�r��_k32�SetErrorMode�	old_value�msvcrt�CrtSetReportModer�rn�	old_modes�CRT_WARN�	CRT_ERROR�
CRT_ASSERTZCRTDBG_MODE_FILE�CrtSetReportFileZCRTDBG_FILE_STDERRr�Z	getrlimit�RLIMIT_CORE�	setrlimitr�r�rr�PIPEZcommunicaterar�)
rhr�ZSEM_NOGPFAULTERRORBOXr��report_type�old_mode�old_file�cmd�procr�rdrdrer�2
sN




zSuppressCrashReport.__enter__cGs�|jdkrdStjjd�rl|jj|j�|jr�ddl}xj|jj�D]$\}\}}|j	||�|j
||�qBWn6tdk	r�ytjtj
|j�Wnttfk
r�YnXdS)zARestore Windows ErrorMode or core file behavior to initial value.Nr�r)r�rorprqr�r�r�r�r�r�r�r�r�r�r�r�)rhr�r�r�r�r�rdrdrer�s
s
zSuppressCrashReport.__exit__)r`rarbrcr�r�r�r�rdrdrdrerZ)
s
Acsrt���d�y�j��Wn$ttfk
r@t��d��YnXd�����fdd�}|j|�t��|�dS)z�Override 'object_to_patch'.'attr_name' with 'new_value'.

    Also, add a cleanup procedure to 'test_instance' to restore
    'object_to_patch' value for 'attr_name'.
    The 'attr_name' should be a valid attribute for 'object_to_patch'.

    FNTcs �rt����n
t���dS)N)r�r[rd)�
attr_is_local�	attr_name�object_to_patchr�rdre�cleanup�
szpatch.<locals>.cleanup)r�rjr�r�Z
addCleanupr�)Z
test_instancer�r�Z	new_valuer�rd)r�r�r�r�re�patch�
s


r�cCsFyddl}Wntk
r YnX|j�r4tjd��ddl}|j|�S)zi
    Run code in a subinterpreter. Raise unittest.SkipTest if the tracemalloc
    module is enabled.
    rNzUrun_in_subinterp() cannot be used if tracemalloc module is tracing memory allocations)�tracemallocrnZ
is_tracingrsrtr��run_in_subinterp)r�r�r�rdrdrer��
s
r�csHG��fdd�d|�}d�|||���|jtt��t�|j��dS)NcseZdZ��fdd�ZdS)z%check_free_after_iterating.<locals>.Acs*d�yt��Wntk
r$YnXdS)NT)�next�
StopIteration)rh)�done�itrdre�__del__�
s
z-check_free_after_iterating.<locals>.A.__del__N)r`rarbr�rd)r�r�rdre�A�
sr�F)rMr�r�r�Z
assertTrue)r�r�rCr�r�rd)r�r�re�check_free_after_iterating�
s	r�cCs�ddlm}m}m}|j�}|j|�xd|jD]Z}|r@||kr@q.t||�}|rd|dk	sntd|��n
|dkrnq.|j	|d�dkr.|dSq.WdS)a<Check if the compiler components used to build the interpreter exist.

    Check for the existence of the compiler executables whose names are listed
    in 'cmd_names' or all the compiler executables when 'cmd_names' is empty
    and return the first missing executable or None when none is found
    missing.

    r)�	ccompilerr��spawnNz%the '%s' executable is not configured)
Z	distutilsr�r�r�Znew_compilerZcustomize_compilerZexecutablesr�rZfind_executable)Z	cmd_namesr�r�r�Zcompilerrvr�rdrdrer^�
s	


cCs@d}tr6||kr6tdkr.tjddg�j�dkatr6|}tj|�S)Ng�h㈵��>Zgetpropzro.kernel.qemu�1)rA�_is_android_emulatorrZcheck_outputrarorD)ZintervalZminimum_intervalrdrdrerD�
sc
cs>tjj�}tj�}ztj�dVWd|r8tj|dd�XdS)NT)r�Zall_threads)ror�rHrZ�
is_enabledr�r�)rBr�rdrdre�disable_faulthandler�
s

r�c	/Cs�tjjd�r8ytjd�}t|�dStk
r6YnXd}ttd�rjytjd�}Wnt	k
rhYnXd}tjd	kr�yd
dl
}|jWntt
fk
r�Yn0Xi}x(|j|j|jfD]}|j|d
�||<q�Wzpd
}xft|�D]Z}ytj|�}Wn4t	k
�r(}z|jtjk�r�WYdd}~Xq�Xtj|�|d7}q�WWd|dk	�rzx*|j|j|jfD]}|j|||��q`WX|S)z/Count the number of open file descriptors.
    �linux�freebsdz
/proc/self/fdr��sysconf�SC_OPEN_MAXNrr)r�r�)rorprqr�r�r�r�r�r�r�r�r�r�rnr�r�r�rO�dupr�ZEBADFr)	�namesZMAXFDr�r�r�rPrBZfd2r�rdrdrer_	sP





c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�SaveSignalsz�
    Save an restore signal handlers.

    This class is only able to save/restore signal handlers registered
    by the Python signal module: see bpo-13285 for "external" signal
    handlers.
    cCsjddl}||_ttd|j��|_x>dD]6}yt||�}Wntk
rNw&YnX|jj|�q&Wi|_dS)Nrr�SIGKILL�SIGSTOP)r�r�)	�signalr|rO�NSIG�signalsr�r�r{rf)rhr�Zsigname�signumrdrdreriMs
zSaveSignals.__init__cCs4x.|jD]$}|jj|�}|dkr"q||j|<qWdS)N)r�r��	getsignalrf)rhr��handlerrdrdre�saveZs
zSaveSignals.savecCs*x$|jj�D]\}}|jj||�qWdS)N)rfr�r�)rhr�r�rdrdre�restorefszSaveSignals.restoreN)r`rarbrcrir�r�rdrdrdrer�Ds
r�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�FakePathz.Simple implementing of the path protocol.
    cCs
||_dS)N)r�)rhr�rdrdrerinszFakePath.__init__cCsd|j�d�S)Nz
<FakePath �>)r�)rhrdrdre�__repr__qszFakePath.__repr__cCs6t|jt�s$t|jt�r,t|jt�r,|j�n|jSdS)N)r�r��
BaseExceptionr�rz)rhrdrdre�
__fspath__ts
zFakePath.__fspath__N)r`rarbrcrir�r�rdrdrdrer�ksr�ccs.tj�}ztj|�dVWdtj|�XdS)z>Temporarily change the integer string conversion length limit.N)ro�get_int_max_str_digits�set_int_max_str_digits)Z
max_digitsZcurrentrdrdre�adjust_int_max_str_digits|s


r�)T)F)F)N)Nii@i@i@ii)rrrrrrrr r!r"r#)r'r%r(r)r*)NF)F)r7F)N)Fi@ii)T)N)Nr)rR)N(rcr`rn�collections.abc�collections�
contextlibZdatetimer�rZr?r�r�r�rm�importlib.utilr�Zlogging.handlersrer�r�rprwr�rr�r�rror�r,r�r�rsZurllib.errorrargZ
testresultrrJrLZmultiprocessing.processr&�zlibrX�bz2Zlzmar�r�r�r�r	r
rrtr�contextmanagerrkr
rr�r:r;rr6rrrrr0rr�rrrr�rqr�r�r�r�r�rr�rr�rr�r r!r�r"r#r$r%rErr	r
rGrHrJrrFrrZ
SOCK_MAX_SIZEZ
skipUnlessr�
__getformat__r7r9r0r1r2r@r�rrArCrvrr�r0ZFS_NONASCII�	character�fsdecode�fsencode�UnicodeErrorZTESTFN_UNICODEZunicodedata�	normalize�getfilesystemencodingZTESTFN_ENCODINGZTESTFN_UNENCODABLEZgetwindowsversion�encode�UnicodeEncodeErrorr��decode�UnicodeDecodeErrorZTESTFN_UNDECODABLEZTESTFN_NONASCIIr4rr]r}r3r6rr�rKr�r�r�r�ZTEST_SUPPORT_DIRr;r�r]rrr[rIr&rI�objectrer�rRr�r�rSr�abc�MutableMappingrTr�r'r�r�r(r�r)r*r+r�rrrr�r�r�r�r�r�r�r�r�r�r�rUr\r�r�rZ_4GrrrYr	r3r4r,rrr>r5r!r%r?r"rBr*r+r-r2r3r<r5r7rAr-rDZMISSING_C_DOCSTRINGSZHAVE_DOCSTRINGSZrequires_docstringsr.rHrIZenvironment_alteredrNrOrPrTrLrQrWrVrbZskipIfZrequires_type_collectingrcrdrfrgrMrXrrrr/rzr|r8r~rr<r=rZr�r�r�r^r�rDr�r_r�r�r�rdrdrdre�<module>s�











2	
!

J			>%	


%2' 5M		



$
#
0







(




"
#
	"
:_";'support/__pycache__/script_helper.cpython-36.opt-2.pyc000064400000012366150532443020016727 0ustar003

Ow�h�)�@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZmZdadd�ZGdd�dejdd#��Zdd�Zd
d�Zdd�Zdd�Zejejd�dd�Zdd�Zd$dd�Zd%dd�Zd&dd�Zd'd!d"�ZdS)(�N)�source_from_cache)�make_legacy_pyc�strip_python_stderrcCsVtdkrRdtjkrdadSytjtjdddg�Wntjk
rLdaYnXdatS)NZ
PYTHONHOMETz-Ez-czimport sys; sys.exit(0)F)�$__cached_interp_requires_environment�os�environ�
subprocessZ
check_call�sys�
executableZCalledProcessError�rr�2/usr/lib64/python3.6/test/support/script_helper.py� interpreter_requires_environments


r
c@seZdZdd�ZdS)�_PythonRunResultcCs�d}|j|j}}t|�|kr0d||d�}t|�|krNd||d�}|jdd�j�}|jdd�j�}td|j|||f��dS)	N�P�ds(... truncated stdout ...)s(... truncated stderr ...)�ascii�replacezRProcess return code is %d
command line: %r

stdout:
---
%s
---

stderr:
---
%s
---i@)�out�err�len�decode�rstrip�AssertionError�rc)�self�cmd_line�maxlenrrrrr�fail>sz_PythonRunResult.failN)�__name__�
__module__�__qualname__rrrrrr;srrrrc
Ost�}d|kr|jd�}n|o$|}tjddg}|rB|jd�n|rX|rX|jd�|jdd�r�i}tjdkr�tjd|d<n
tjj�}d	|kr�d
|d	<|j	|�|j
|�tj|tj
tj
tj
|d�}|�*z|j�\}}Wd|j�tj�XWdQRX|j}	t|�}t|	||�|fS)NZ
__isolatedz-XZfaulthandlerz-Iz-EZ
__cleanenvZwin32Z
SYSTEMROOT�TERM�)�stdin�stdout�stderr�env)r
�popr	r
�append�platformrr�copy�update�extendr�Popen�PIPEZcommunicate�kill�_cleanup�
returncoderr)
�args�env_varsZenv_required�isolatedrr&�procrrrrrr�run_python_until_end[s:





r6cOs4t||�\}}|jr|s&|jr0|r0|j|�|S)N)r6rr)Zexpected_successr2r3�resrrrr�_assert_python�s
r8cOstd|�|�S)NT)T)r8)r2r3rrr�assert_python_ok�sr9cOstd|�|�S)NF)F)r8)r2r3rrr�assert_python_failure�sr:)r$r%cOsXtjg}t�s|jd�|j|�|jdttj��}d|d<t	j
|ft	j||d�|��S)Nz-Er&Zvt100r!)r#r$r%)r	r
r
r(r,�
setdefault�dictrrrr-r.)r$r%r2�kwrr&rrr�spawn_python�s

r>cCs2|jj�|jj�}|jj�|j�tj�|S)N)r#�closer$�read�waitrr0)�p�datarrr�kill_python�s


rDFcCsP|}|s|tjd7}tjj||�}t|ddd�}|j|�|j�tj�|S)N�py�wzutf-8)�encoding)	r�extsep�path�join�open�writer?�	importlib�invalidate_caches)Z
script_dir�script_basename�sourceZomit_suffixZscript_filename�script_nameZscript_filerrr�make_script�s
rRc	Cs�|tjd}tjj||�}tj|d�}|dkr~|jtj�}t|�dkrr|ddkrrt	t
|��}tjj|�}|}ntjj|�}|j||�|j
�|tjj||�fS)N�ziprF��__pycache__���)rrHrIrJ�zipfile�ZipFile�split�seprrr�basenamerLr?)	�zip_dir�zip_basenamerQZname_in_zip�zip_filename�zip_name�zip_file�partsZ
legacy_pycrrr�make_zip_script�srbr"cCstj|�t|d|�dS)N�__init__)r�mkdirrR)Zpkg_dirZinit_sourcerrr�make_pkg�s
re�cs0g}t|dd�}|j|�tjj|�}	t|||�}
|j|
�|rjtj|dd�}tj|
dd�}
|j||
f��fdd�td|d�D�}tjj	|d
tjj|
��}|tj
d}
tjj	||
�}tj|d	�}x&|D]}tjj	||	�}|j
||�q�W|j
|
|�|j�x|D]}tj|��q
W|tjj	||�fS)Nrcr"T)�doraisecsg|]}tjj�g|��qSr)rrZrJ)�.0�i)�pkg_namerr�
<listcomp>�sz make_zip_pkg.<locals>.<listcomp>rfrSrF���)rRr(rrIr[�
py_compile�compiler,�rangerJrHrWrXrLr?�unlink)r\r]rjrOrPZdepthZcompiledrpZ	init_nameZ
init_basenamerQZ	pkg_namesZscript_name_in_zipr^r_r`�nameZinit_name_in_zipr)rjr�make_zip_pkg�s.



rr)rrr)F)N)r")rfF) �collectionsrMr	rZos.pathZtempfilerrm�
contextlibZshutilrW�importlib.utilrZtest.supportrrrr
�
namedtuplerr6r8r9r:r.ZSTDOUTr>rDrRrbrerrrrrr�<module>s4$3




support/__pycache__/testresult.cpython-36.opt-2.pyc000064400000017012150532443020016273 0ustar003


 \
�@s2ddlZddlZddlZddlZddlZddlZddljjZ	ddl
m
Z
Gdd�dej�ZGdd�d�Z
ddd	�Zdd
d�Zedk�r.Gd
d�dej�Zej�Zejeje��ej�Zeedd�ejD���Zeej�Zeje�Ze dej!��e ddd�x(e	j"ej#��D]Z$e e$j%�dd��qWe �dS)�N)�datetimecs�eZdZdddZdddZ�fdd�Zedd��Z�fd	d
�Zd$dd
�Z	dd�Z
edd��Z�fdd�Z�fdd�Z
�fdd�Z�fdd�Z�fdd�Z�fdd�Zdd�Zd d!�Zd"d#�Z�ZS)%�RegressionTestResult�=�F�
�-cs\t�j||dd�d|_tjd�|_|jjdtj�j	d��d|_
d|_g|_t
|�|_dS)Nr)�stream�descriptions�	verbosityTZ	testsuite�start� )�super�__init__�buffer�ETZElement�_RegressionTestResult__suite�setrZutcnowZ	isoformat�_RegressionTestResult__e�!_RegressionTestResult__start_timeZ_RegressionTestResult__results�bool�_RegressionTestResult__verbose)�selfrr	r
)�	__class__��//usr/lib64/python3.6/test/support/testresult.pyrszRegressionTestResult.__init__cCsLy
|j}Wntk
r"t|�SXy|�Stk
rBt|�SXt|�S)N)�id�AttributeError�str�	TypeError�repr)�cls�testZtest_idrrrZ__getIds


zRegressionTestResult.__getIdcsVt�j|�tj|jd�|_}tj�|_|j	rR|j
j|j|��d��|j
j
�dS)NZtestcasez ... )r
�	startTestr�
SubElementrr�time�perf_counterrrr�write�getDescription�flush)rr!�e)rrrr"+s
zRegressionTestResult.startTestFcKsP|j}d|_|dkrdS|jd|jd|j|���|jd|jdd��|jd|jdd��|jrz|jdtj�|jd��|r�|jdk	r�|jj�j	�}|t
j|d�_|j
dk	r�|j
j�j	�}|t
j|d	�_x�|j�D]t\}}|s�|r�q�t
j||�}	t|d
��r>xD|j�D],\}
}|
�r,|	j|
t|��n
t|�|	_�qWq�t|�|	_q�WdS)N�nameZstatus�run�resultZ	completedr$z0.6fz
system-outz
system-err�items)rr�pop�_RegressionTestResult__getIdrr$r%Z_stdout_buffer�getvalue�rstriprr#�textZ_stderr_bufferr-�hasattrr)rr!Zcapture�argsr)�stdout�stderr�k�vZe2Zk2Zv2rrr�_add_result3s4

z RegressionTestResult._add_resultcCs|jr|jj|�d��dS)Nr)rrr&)r�cZwordrrrZ__writeSszRegressionTestResult.__writecCslt|t�r0|jdkr|j}q8|j�d|j��}nt|�}tj||d�}tj|||�}|dj|�dj|�d�S)N�builtins�.�)�type�messager=)�
isinstancer>�
__module__�__name__r�	traceback�format_exception�join)r Zerr_typeZ	err_valueZerr_tb�typename�msg�tbrrrZ__makeErrorDictWs

z$RegressionTestResult.__makeErrorDictcs4|j|d|j|�d�t�j||�|jdd�dS)NT)�error�E�ERROR)r9�$_RegressionTestResult__makeErrorDictr
�addError�_RegressionTestResult__write)rr!�err)rrrrMjszRegressionTestResult.addErrorcs4|j|d|j|�d�t�j||�|jdd�dS)NT)�output�xzexpected failure)r9rLr
�addExpectedFailurerN)rr!rO)rrrrRosz'RegressionTestResult.addExpectedFailurecs4|j|d|j|�d�t�j||�|jdd�dS)NT)Zfailure�F�FAIL)r9rLr
�
addFailurerN)rr!rO)rrrrUtszRegressionTestResult.addFailurecs2|j||d�t�j||�|jdd|���dS)N)Zskipped�Szskipped )r9r
�addSkiprN)rr!�reason)rrrrWyszRegressionTestResult.addSkipcs&|j|�t�j|�|jdd�dS)Nr<�ok)r9r
�
addSuccessrN)rr!)rrrrZ~s
zRegressionTestResult.addSuccesscs*|j|dd�t�j|�|jdd�dS)NZUNEXPECTED_SUCCESS)Zoutcome�uzunexpected success)r9r
�addUnexpectedSuccessrN)rr!)rrrr\�sz)RegressionTestResult.addUnexpectedSuccesscCs2|jr|jjd�|jd|j�|jd|j�dS)NrrKrT)rrr&�printErrorList�errors�failures)rrrr�printErrors�sz RegressionTestResult.printErrorscCs`xZ|D]R\}}|jj|j�|jj|�d|j|��d��|jj|j�|jjd|�qWdS)Nz: rz%s
)rr&�
separator1r'�
separator2)rZflavorr^r!rOrrrr]�s
z#RegressionTestResult.printErrorListcCsH|j}|jdt|j��|jdtt|j���|jdtt|j���|S)NZtestsr^r_)rrrZtestsRun�lenr^r_)rr)rrr�get_xml_element�s
z$RegressionTestResult.get_xml_element)F)rBrA�__qualname__rarbr�classmethodr/r"r9rNrLrMrRrUrWrZr\r`r]rd�
__classcell__rr)rrrs"
 rc@seZdZddd�Zdd�ZdS)�QuietRegressionTestRunnerFcCst|dd�|_||j_dS)Nr)rr,r)rrrrrrr�sz"QuietRegressionTestRunner.__init__cCs||j�|jS)N)r,)rr!rrrr+�s
zQuietRegressionTestRunner.runN)F)rBrArerr+rrrrrh�s
rhFcCs&|rtjtjt||d�Stjt|d�S)N)Zresultclassrr
)r)�	functools�partial�unittestZTextTestRunnerrrh)r
rrrr�get_test_runner_class�srlcCst||�|�S)N)rl)rr
Zcapture_outputrrr�get_test_runner�srm�__main__c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�	TestTestscCsdS)Nr)rrrr�	test_pass�szTestTests.test_passcCstjd�dS)Ng�?)r$Zsleep)rrrr�test_pass_slow�szTestTests.test_pass_slowcCs*tdtjd�tdtjd�|jd�dS)Nr5)�filer6zfailure message)�print�sysr5r6Zfail)rrrr�	test_fail�szTestTests.test_failcCs(tdtjd�tdtjd�td��dS)Nr5)rrr6z
error message)rsrtr5r6�RuntimeError)rrrr�
test_error�szTestTests.test_errorN)rBrArerprqrurwrrrrro�sroccs|]}|dkVqdS)z-vNr)�.0�arrr�	<genexpr>�srzzOutput:zXML: r=)�end)F)F)&ri�iortr$rCrkZxml.etree.ElementTreeZetreeZElementTreerrZTextTestResultrrhrlrmrBZTestCaseroZ	TestSuiteZsuiteZaddTestZ	makeSuite�StringIOr�sum�argvZ
runner_clsr5Zrunnerr+r,rsr0Ztostringlistrd�s�decoderrrr�<module>s2
	




__pycache__/__init__.cpython-36.opt-1.pyc000064400000000170150532443020014074 0ustar003


 \/�@sdS)N�rrr�%/usr/lib64/python3.6/test/__init__.py�<module>s__pycache__/__init__.cpython-36.opt-2.pyc000064400000000170150532443020014075 0ustar003


 \/�@sdS)N�rrr�%/usr/lib64/python3.6/test/__init__.py�<module>s__pycache__/__init__.cpython-36.pyc000064400000000170150532443020013135 0ustar003


 \/�@sdS)N�rrr�%/usr/lib64/python3.6/test/__init__.py�<module>susr/bin/test000075500000153200150532716750007046 0ustar00ELF>�@��@8@@@@hh���x�x� ���� �� �h �� � �����  ���DDS�td���  P�td<�<�<���Q�tdR�td���� �� pp/lib64/ld-linux-x86-64.so.2GNU�GNUGNU`m�	'�g��"�V����B��o|��1~ ����"�A��bQ)9������� ����4C~]tK*):��� ;�k�"Ohlibc.so.6fflush__printf_chksetlocalembrtowcstrncmpstrrchrdcgettexterror__stack_chk_fail__lxstatiswprintreallocabort_exitprogram_invocation_nameerror_at_line__ctype_get_mb_cur_maxstrtolisattycallocstrlenmemset__errno_locationmemcmp__fprintf_chkstdoutlseekmemcpyfcloseeuidaccessmallocmbsinitnl_langinfo__ctype_b_loc__freadingstderr__snprintf_chkgetegidfilenofwritegeteuid__fpendingprogram_invocation_short_name__cxa_finalize__xstatbindtextdomainstrcmp__libc_start_mainfseekofputs_unlockedfree__progname__progname_full__cxa_atexitGLIBC_2.3GLIBC_2.14GLIBC_2.4GLIBC_2.3.4GLIBC_2.2.5_ITM_deregisterTMCloneTable__gmon_start___ITM_registerTMCloneTableii
G���Qii
\ti	fui	r�� ��� p�� �� �� 1�Ȼ 9�л ?�ػ L�� Y�� m�� o��� R�� ��� w�`� p� x� �� �� �� 	�� �� ȿ "п 5ؿ 7� 9� ; � (� 0� 8� @� H� P� 
X� `� h� 
p� x� �� �� �� �� �� �� �� �� �� Ⱦ о ؾ � � �  �� !� #� $� %� & � '(� (0� )8� *@� +H� ,P� -X� /`� 0h� 1p� 2x� 3�� 4�� 6�� 8�� 9�� :��H��H�I� H��t��H����5z� �%{� ��h�������h��������h�������h�������h�������h�������h�������h��q������h��a������h	��Q������h
��A������h��1������h��!������h
��������h��������h������h�������h��������h�������h�������h�������h�������h�������h��q������h��a������h��Q������h��A������h��1������h��!������h��������h��������h������h �������h!��������h"�������h#�������h$�������h%�������h&�������h'��q������h(��a������h)��Q������h*��A������h+��1������h,��!������h-��������h.��������h/������h0��������%e� D���%]� D���%U� D���%M� D���%E� D���%=� D���%5� D���%-� D���%%� D���%� D���%� D���%
� D���%� D���%�� D���%�� D���%� D���%� D���%ݦ D���%զ D���%ͦ D���%Ŧ D���%�� D���%�� D���%�� D���%�� D���%�� D���%�� D���%�� D���%�� D���%}� D���%u� D���%m� D���%e� D���%]� D���%U� D���%M� D���%E� D���%=� D���%5� D���%-� D���%%� D���%� D���%� D���%
� D���%� D���%�� D���%�� D���%� D���%� D�����������������������������UH��S��H��H�>�9H�5Yk�����H�5[kH�=Fk�5���H�=:k�	���H�ƥ H�=���@iH�-1� �3� �-� ��~$�{���Hc� ;� u����H��[]ø��H�� H�<��;H�5�j1��H�����H��H��1��ffD��1�I��^H��H���PTL��hH�
hH�=������� �H�=y� H�r� H9�tH��� H��t	�����H�=I� H�5B� H)�H��H��H��?H�H�tH�u� H��t��fD�����=� u+UH�=Z� H��tH�=� �	����d����ݤ ]������w����SH���H�=�gH�޸��€���t�H�=�gH����€���u	[���H�=�gH����€���tܹH�=�gH����€���t��H�=�gH����€���t��H�=mgH����€���t��H�=VgH����€����l����H�=;gH����€����M����H�= gH����€����.����H�=gH����€�������H�5�fH���A����¸����H��H�5�f�#���[�����ff.��PXH���H�t$(H�T$0H�L$8L�D$@L�L$H��t7)D$P)L$`)T$p)�$�)�$�)�$�)�$�)�$�dH�%(H�D$1�H��$�H��H��H�D$1�H�D$ 1��$�D$0H�D$�;��t���@SH������L�H���H��A�Hut��+t1ɀ�-��H��1H�Q��0��	wn�q���0��	w�H���2���0��	v���A�ptDH���2H��A�pu��u$[�f�H���v����H�HH���H���7H�5Ve1��H������H��H��1��|���ff.��Hcɡ H��� SH�|��w7H�5!e1��H�����H��H��1��4���@��� �P;�� �� }
���t� �P���f�USH��HcT� dH�%(H��$�1�H�.� H���@��G<3wH�0f��Hc�H�>��1�fDH��$�dH3%(���GH�Ĩ[]�D�K���Hcؠ H�Š H�D��8����+���Hc�� �H��� H�|��>������������Hc�� �H�p� H�|����������\���@����Hc
X� H��H�B� �H�t��+���1҅��)����T$��������f����Hc� H�� H�|��S���H���K����
1�H���H�����1҃;"����H=����������e�����������#���Hc
�� H��H��� �H�t����1҅������H�|$0���s������Hcp� �H�X� H�|���������D���@���Hc
@� H��H�*� �H�t�����1҅������D$%�=������k���Hc�� H�� H�D��8������D�C���Hc
О H��H��� �H�t����1҅�������T$��	�����f.����Hc
�� H��H�r� �H�t��[���1҅��Y����T$��
���J���f����Hc
H� H��H�2� �H�t�����1҅������D$%�=��������s���Hc
� H��H�� �H�t�����1҅������D$%�=@������+���Hc
�� H��H��� �H�t����1҅�������D$%�= ���s������Hc
p� H��H�Z� �H�t��C���1҅��A����D$%�=`���+������Hc
(� H��H�� �H�t�����������k���Hc
�� H��H�� �H�t����1҅������D$%�=�������#���Hc
�� H��H��� �H�t�����{�������H���������9D$���[�������Hc
X� H��H�B� �H�t��K�1҅��)����D$%�=����������Hc
� H��H��� �H�t����������6��H������t9D$ ������31҅�������G����1҅�����������AU��ATUSH��h�
�� dH�%(H��$X1ۍQ@��t	�n� �Q�=a� H�R� Hc�E1�O�9�~!H�t��H�=�^���������H�4�L�,����-����=���H�=3^������ �Hc� H��H��H�4�H�|�����A�ă��-ɚ H��$XdH3%(D���;H��h[]A\A]�D��� A��[�����F��t<=�e����~�[���fDHc]� H��H��H�4�H�|������A�ă��-9� �k����V��l�[��g�R��e����n���o���~t���~���� A���H��$�J�t+��H����J�L+����H�1H��L��$�H��$��������H��$�H��$�L9��:)��L9�DM����f��V��q�p��f�+�~�!�=� A���J�t+�H������Q���J�t+H��$�������2���H��$�H9$� ���H��$�H9D$A���
�����N��et	��t������~����n�������tu�~uy��� A��H��$�J�t+��H���^�J�L+���!H�1H��L��$�H��$��1���1A��i���fD��e�wH����-H�5�[1��H�����H��H��1���@�N��e�@����~u�J�|+�������H��$ H���H��H��� E����J�|(��H��$@H����H��H���S-H�t� H��ye�I�ƒj� ��l����g������8�A������@H�1H��� ��f���H�1H������A���H���DH��$�L;�$��-���A��!���)Å�A������f�J�|(��H���3���fD��H�����V�L������9�A������f.����9�A��������H�5�Y1��8�1�H��1����H�5�Y�ߺH�5�Y���O1���G��3wH����{�H��H�����f�Hc�� L�
� �H�=�YM��H��L��L�������t)SA�8-u7A�xt0A�xu)L���|�����t"[�B�f�K�D����� �8������A+H�5hY1��H���K�H��H��1���ff.�H������~q��������Hc,� L�
� �H�=YM��H��L��L����€�������;� �� ������H��Ð��u+HcȔ �P��� H��� H�€8��H���D��� ;�� }|H���|@H����H���o�����H�=fXL����€���u�K�t�H�=o��€���u����+� �"����� �@����A�AWAVAUATUSH���� D�-�� �D$�D$D9���f�L�ѓ Lc�O�<�E�'A��!��A�������� D9��dLc�1���&A��UI����E9������O�<�D��D��A�7@��!tɄ�tD�5Z� A��A��(�A���S�9� D9����CD9��pH�E�M�M��A)ٸI�2�H�=�m�������t������I��A9�u�fD�����Hc
Β H��� H�4�H��H���_�>)��~���D�-�� ��� 1� D$A9���H�r� HcùH�=�VH��H��������5���P� D9��c����n�fD��tD�51� D��)؃����L��H�=�U�����uK�|�L�$�'�L�$���K�|�������A��-tKE������1�Ƒ  D$A9��4����D$D$�D$H��[]A\A]A^A_��t�A��-u�A�t�A�u�L���B������E��c� D�-X� ����D��)��n���fD1�����7� D�-,� �����H�=EUH���D$D$������M������� �����>����ܐ D�-ѐ �<���@1��n����1����f������fD�
�� �����;&H�5]k1�H���*&�H�5�T1�H���D�H��H��H��1����H�=&k�&�H�5HTH��1���H��H��1������%�H�5TH����ff.�@AUATUSH��Hc� H�-� H��H��L�l�L�$�L��������J�T%��H�=�SH�������u-��;�� ��� �������H��[]A\A]�D�H�=vSH�������u6J�t%�H�=&j�����uA�}�����5� ���H�=JSL�������t�H�=3SL�������u-;� }PH��[]A\A]����DH��1�[]A\A]�'�L���$H�5�R1��H����H��H��1��<�������ATU��SH�ĀdH�%(H�D$x1���t@H�� �H�5;T1�H��1��H��H��� H��H�81��������H�G� �1�H�5!TL�#���H��L����L�#�1�H�5UT���L��H���u�L�#�1�H�5lT��L��H���T�L�#�1�H�5{T��L��H���3�L�#�1�H�5�T�m�L��H����L�#�1�H�5�T�L�L��H�����L�#�1�H�5�U�+�L��H�����L�#�1�H�5�V�
�L��H����L�#�1�H�5�W���L��H����L�#�1�H�5�X���L��H���m�L�#�1�H�5,Y��L��H���L�L�#�1�H�5#Z��L��H���+�L�#�1�H�5*[�e�L��H���
�L�#�1�H�5)\�D�L��H�����L�#�1�H�5�\�#�L��H�����H��1�H�5O]��H��H�����H�5aP1�����H�5�]1�H�����H�ڿH�0PH��1��E�H�0PH�
jPH�D$`H�$H�PH�D$H��PH�L$0H�
HPH�D$H�PH�L$@H�
:PH�D$H�PH�L$PH�D$hH�D$ H��OH�D$(H�D$8H�D$HH�D$XH��fDH��H�8H��t�H����€���u�L�`�H�5�O1�M��������H�
d]H��OH��1��S�1���7�H��t�H�5�OH���.����1��H�5�]��H�
�N�H�]H��1���I9�H�
SOH��NHE�1�H�5h]��>�H��L��H��1����������H�
�\H�OH��1���1���v�H��t�H�5�NH���m���uC�H�5�\1����H�
0NH�H\�H��1�L�%N�2�H�9N�E���L�%N1��H�59\�|�H��M�H��1����������H�=�� �@��@�=m� �@��USH��H�o� H�8�7(��t����=?� H��t�8 uH�~� H�8�(��uFH��[]�1��H�58\����H�=	� H��H��t+��3I��1�H��H�\1��T�H�A� �8�F���3H��H��[1�1��1���f.�D��H�N�FH�����������H��H��I��H��H��H��H��H�I)�L����0�H��	w�H�����SH�����/H���u��H��tXL�@L��H)�H��~HH�p��H�=�[��€���u,�H�=�[L��L����€���uH�XH�#� H�H�� H�H��� H�[�H�� �7�H�=�ZH��r�����f.�UH��S��H���@'���߀�UuM�P��߀�Tu^�P��߀�FuR�x-uL�x8uF�xu@�}`H��ZH��ZHE�H��[]�fD��Gu�P��߀�Bu�x1u�x8t#��	H��ZH��ZHE�H��[]���x0u׀x3uрx0uˀxuŀ}`H�\ZH�NZHE�H��[]�AWAVI��AUATI��UH��SD��H���H��$H�T$D�D$H�D$ H��$D��$�H�D$hH��$H�D$`dH�%(H��$�1��2��D�\$��H�D$X�D$CA��
�[��H�
ZD��Hc�H�>���D$AE1�Ƅ$�H�D$P�D$C�D$BH�}YE1�A�H�D$H�D$HE1�D��E��I��L��A���I9�A��I���u
H�D$�<(A��E����A��H�|$��"D$BL�/�D$��H�D$H���1H�\I���u-H��v'D�T$8D�D$0L�L$(�D��D�T$8D�D$0L�L$(I��L9���H�T$H�t$HL��D�T$DL�\$8D�D$0L�L$(���L�L$(D�D$0��L�\$8D�T$D���|$C��A���~��H�
�X��Hc�H�>��f��D$I����I���uH�D$�x��A��������H�����|$Ct�����T$B����FH�t$ H��t�ډ���ҋ����u�|$�5A���€|$C���kD���� �t/M9�vC�>'I�WI9�vC�D>$I�WI9�vC�D>'I��A��M9�sC�>\I��H��M9�sC�>�|$AI���E��D�@�|$A��f��D$A����A����A���?��E1������D$A���1D��$�1��'���D�D$�\$C�\$BtH�|$�q�\�\f��|$B�E1�1��|$C������|$������H��D!��C�D$1�E1��q���f��rE1�A���€|$C�������@ D$BL��E�Ӏ|$B�DE�H��E��H��t$hL��L���t$xjD��$�H�T$0A�����H�� I��H��$�dH3%(L���:H���[]A\A]A^A_�D�fA�����|$C�i���E1��/�����n�;���fD�D$�	�t����@�b붐�a�f��|$C�!
�D$A��D���ƒ� ���M9�vC�>'I�OI9�vC�D>$I�OI9�vC�D>'I�OI9��@A�\A��L�yA���q
H�E�0L9�sH�D$�D(�D$(��0<	��	�D$B���D��A���������D$H�|$X�wD�T$8L�\$0D�D$(�����D�D$(L�\$0H�D�T$8��Pf%@A����"T$B���*A�����I����A���~w�H�
�V��Hc�H�>���
�rA����"T$C�T$�Q���L��A������v�1������f�!�����
�n�@�	�t�@��b�����a�����|$B�%����D$1��$�����H�������A��������|$C�~
H��D��E1�\@������M9�vC�>'I�GI9�vC�D>'I��E1����A����E1����f�A��� �������A�������@A���~����H�
8W��Hc�H�>���1�D�l$�D$1����D1�H����D�l$�D$1��t���@1�� ��A��E��L����M��u
�T$C�h
�D$C�� ��w	��$��g	�|$A�
M����H�|$P�� ���	L�d$PA�'H��QA�A�H�\$HH�D$�D$C��$��`�����|$C��M���P1�H�|$P�BL�d$PI��1�E1�D��$�I�Ի'�����$�tH�EL9�sH�\$�|+?��D1�E1�?�I�����|$C�hE1�1��?�\���fDH��$�HDŽ$�H�D$pI���u,H�|$D�T$8D�D$0L�L$(�X��D�T$8D�D$0L�L$(I��1�H��$���$�L�t$xH��L�t$pH�D$8D��$�H�l$0L��$�L��$�L��$�L�\$(D�T$D�+���$�����L�����DD�H�������hH�D$0H�T$(L��H�|$8L�<H�D$L)�N�$8L���lH��H���2H����H����V�|$Du��|$C�z���H���p���H�|$H�4/J�D?L��DH��H9��K������[��!w�H�+�H��H��t�L�t$xL��$�A�H�l$(�V���@�D$E1�1����f.�L��M9��f���D���V���M9�vC�>'I�GI9�vC�D>\I�GI9���L��C�D>'L�d$P����T$BE1�H��D�l$(1�D�l$CH��|$L�L$�f�A����E���D�ƃ�@ �t/M9�vC�>'I�wI9�vC�D>$I�wI9�vC�D>'I��A��M9�vC�>\I�GI9�v
�����0C�D>I�GI9�v�������0C�D>��H��I����0H9��V��M9�vC�>A�)I�����J������D!�@��tM9�vC�>\I��H��H9�s,���M9�vC�>'I�GI9�vC�D>'I��1�E1��D�l$(���L�݈D$BE������v�k���I��A��E1�0��������D$BM����H��M�D$AE1�A�H�D$PA�Ƅ$��D$CH�D$H�D$H����CM����A�"E1��D$AƄ$�H�D$PH�&M�D$CA��D$BH�D$H�D$H��A��
tjH�5M1��D�\$�2��D�\$H��H�D$hH��LH9��uH�5�L1��D�\$���D�\$H��H�D$`H��LH9��$E1����JH�\$`D�\$E1�H������H�\$HD�\$H�D$�D$AƄ$�H�D$P�D$B���H�=L�D$AE1�E1�Ƅ$�A�H�D$P�D$C�D$BH�D$H�D$H���D$AE1�E1�Ƅ$�H�D$P�D$C�D$BH�D$H�D$H�]��D$AE1�E1�Ƅ$�H�D$P�D$C�D$BH�D$H�D$H� ��D$AE1�Ƅ$�H�D$P�D$C�D$B����D$����D$����D$����M9�vC�>0H�AI9�vA�D0L�y�0�K������t�D$B�]���f�D�l$(��1����H��D��H�l$0L�t$x��$�L�\$(��D��$�L��$�L��$�D�T$D"T$BH��������H���H�D$PE1��D$AƄ$��U���D��0E1������>����H���pH��������|$C��M9�vC�>?I�WI9�vC�D>"I�WI9�vC�D>"I�WI9�vC�D>?I��1�E1�H���2���H��H�l$0L�t$xE1�D��$���$�L��$�L��$�L�\$(D�T$D�T$B�
���L�\$(L��L��H��H��H�l$0D��$���$�L��$�L��$�L�t$xL��$�D�T$DL9�s �>u
��A�<tH��H�TI9�w�H���T$BE1����H�T$h��������M9�vC�>I��B�:��u����H�	I�D$AE1�E1�Ƅ$�H�D$P�D$C�D$BH�D$H�D$H�l�L��E����L��E�����H�\$HH��t,��t(�H�؄�tL��L)�I9�vA�H�����u�I��M9����C�>�{�H�|$`D���?�D�\$H�D$`���H�|$hD���#�D�\$H�D$h�o���A��L��E���D$B�����$��^���H��A�H��L���t$h�t$x�t$8D��$�H�T$0H�t$p��H�� I�����A���E1��D$A1�H�D$P���L��L�d$P�������B��(��H��G�D$AE1�E1�Ƅ$�H�D$P�D$C�D$BH�D$H�D$H���AWLc�AVI��AUATUH��SH��(H�t$����H�hs I�ŋ�D$E������D9=Gs bA������QE�gH�Es Ic�H��H9��H����H�s H��Hc=s D��1�)�H��Hc�H�H�����D�%�r �EI��H��D�EL�L�}L���L�L�c�D$$A���u0L��L��u(AWH�T$(L�\$0�$�H�� L�\$I9�wgH�pH��r H�3I9�tL��H�t$����H�t$H��H�t$�H��L��H�CD�EH��I��u0�u(AWD�L$<H�T$(H�t$0��H�� �D$A�EH��(L��[]A\A]A^A_�D1��for H��H��q �����
f.���ATUSH���P��H�۾8D� H��H�s HD�H���
D�e[]A\�fD��H��H��r HD���ff.���H��H��r HD��7�ff.���H��H��r ��HD��������H�|��7����1ƒ�����1�����H��H�rr HD��G�w����H��H�Rr HD��
H��tH��t	H�w(H�W0�P�?��ff.�@��AWH�r I��AVI��AUI��ATUSL��H��M��HD�H�L$�
��H��L��L��D� H��H�CD�K�s0L��s(PD�H�L$(���D�eH��8[]A\A]A^A_����AWH��q I��AVI��AUATI��USH��H��8H��HD�1����M��L��L��I�ŋ@��L�SH��k1�1��D$A��s0�s(ARD�L�T$@�P�H�pH�D$HH�� H��H�t$�	A��L��L��H�D$H��H��s0�s(L�T$8ARH�t$8D����D$,H�� A�EM��t	L�\$(M�$H�D$H��8[]A\A]A^A_�f���H��1�����f����.o ATL�%-o US��~'��I�\$H��I�l(DH�;H���d��H9�u�I�|$H�So H9�t�I��H��n H��n H��n I9�tL���#��H��n ��n []A\�ff.�f���H�
�o H��������f���H�
�o �����H��1�����f���H��H��1�����ff.�@��H��HH��dH�%(H�T$81҃�
�����4$H��H��H������D$H�D$H�D$H�D$H�D$ H�D$(H�D$0�9���H�L$8dH3%(uH��H����ff.�@��H��HH��H��dH�%(H�L$81Ƀ�
�����4$H��H���D$H�D$H�D$H�D$H�D$ H�D$(H�D$0���H�T$8dH3%(uH��H��c����H��1������H��H��1��M���ff.�f���ATI����UH��SH��@fon fo
&n dH�%(H�D$81�fon H�'n H��H��)$)L$)T$ H�D$0����H��1�L��H������H�L$8dH3%(u	H��@[]A\����ff.���@��H������L���ff.�����:����f����:�"���f���ATUSH��@dH�%(H�D$81���
�T��H��I�ԉ4$��:H���D$H�D$H�D$H�D$H�D$ H�D$(H�D$0� ���H��L���H���������H�L$8dH3%(u	H��@[]A\����ff.���AUM��ATI��U��SH��Hfo�l fo
�l dH�%(H�D$81�fo�l H��l H��H��)$)L$)T$ H�D$0����H��L��L����=���H�L$8dH3%(uH��H[]A\A]����ff.�f���I������P�����H��H��H��1�����ff.����I��H��H��H��1�����f���H�
j �����H��H��1�����ff.�@��H����������H��1����f�������-����-��@��0����0����D�@�8�u#A��	��H��H����D�@�8�t�)�A��	��E1��B�LI����0��	v��0��	��1��TH����0��	v�I9��N����H���<0t�D��E�HЀ�-thA��	�ZfD��0���01���	����ÐH���<0t��Pи��	w��H�����0t��01���	����H�����0t�8�u"A��	�H��H��D��E�H�A8�t��ʉ�D)�A��	��E1�f�B�TI����0��	v�QЃ�	��1��TH����0��	v�L9�tRI9�������fDH����U���@H����<���@H������@M���D��@H�ɺD��@1�M�����1�M������ø�����fD)Ѓ�0E1���	�E���1��@�ʉ�D)��Q�E1���	�7��������AVA��AUA��L��ATA��L��UH��S�H��t_H��H��t0D��I��D��H��D��L��:1��ӽ��H��[]A\A]A^铽��D��H��D��1�H��:�ɿ��H��[]A\A]A^�i����H�5eA1�����H���n���H��1��01�萿���K���ff.���I��I��1�1��-���f.���SH���Ӿ��H��uH��u[��Rf���H��H��H����H��x
��H��u���P�(���������SH��H��uH��uH��趾��H��uH��u[�f.��{���1�[���f���H��H��H����H��x
��H��u���P����I��H�H��t1H�TUUUUUUU1�I��H9�v8H��H��H�LH�I��H���S���H��t#H��I������H��xH��t�P�?�1Ҹ�E1�I��I���A��I��f.���H�H��t,H�SUUUUUUUH9�w7H��H��H�DH�H�������H��u��H�H�����y�P����SH���3���H��1�H���f���[�@��H��H��H����H��x��H��u�}���H��tH����^ff.���UH��H��SH��H������H��H��H���j���H��[]���SH��胻��H��[H�p���fD��PX�H�5�>1�H���3���H��c 1�H��1��:H�7跼���r���f�AWAVAUATUSH��(dH�%(H�D$1��o$L�~L�|$H����I��I��H��1�I������$@�ƒ��$L�H�:�ͺ��H�IB�H��t �$��/v�H�T$H�BH�D$���H�������H�{���H��H���5f��ƒ�IT$A�$L�:L���g���H��L��I��H���&���L�I��t-A�$��/v�I�T$H�BI�D$��@��F���H��H���H�L$dH3%(H��u!H��([]A\A]A^A_��C���1��K������@��H��dH�%(H�D$1����twI��<%u2�su,1��
��%u#A�|xsuH��A�x��u��a�����H��H��L������xH�$H�T$dH3%(uH���D裸���8t
1���1���a�������f.�f���AUI��ATI��USH��H��dH�%(H�D$1�H��H�D$HD�H���%���H��H���vM��u'H�T$dH3%(H��u-H��[]A\A]�f�1����u�A�E����¸��f���SH��H��1�H��dH�%(H�L$1�H��H��H���H��tBH�$H�����wH���H�\$dH3%(u'H��[�H���l���臷���K������и�������>���f.�@��ATUH��S萷���]H��I�ă� ����u#��tM��u0�-����8	������[]A\�D��u�����������������f.����H��1���H�¸H��t�H�=�:H�������1���uH���f��H�=�:H���������H�����H����N���H��t�8H��:HD�H���fDH�z:H���@��ATUSH���з��H�߅�xX�$�����u0H���h��t@����H��D� H��聶��E��u<[]A\��H��舷��1�������H���u�H��[]A\�H����D�e������D��SH��H��t螷����t�uH��[�Y���f�H�ߺ1��H��[�8������H�GH9Gt
靷��DH�G H9G(u�H�Hu�ATA��UH��SH���Ŷ��D��H����(���H���t�#�H���1�[]A\Ð��UH��AWAVL��P���AUATI��SH��L��H��H��8���H��H����H��@���dH�%(H�E�1�L���H����������L��L���k����
H��P���H�����H��H��HF�H�X�����H��E1�H��A����H�����L��0���H��������H�����H���uH�����L��0���E1�H��8���t
H����L� L��H���L��8���H��D���M��I��H�����I�L��HDž���L9��L)�L��H�I���I9�sgM���H���A�H;�8�����H���)���!L��H��L��(���H��0����`���H����H��0���L��(���H��J�<;H��L��跴��H�����H9�@����+A�VHI�FP��%��H����
���L��X���H��L��8��(�����n�H�����A�FL�y�%�tH������G'L��tA�-I���tA�+I���tA� I���tA�#I���@tA�II��� tA�0I��I�vI�V H9�t0H��L��L�� ���H)�H��H��0����ϳ��H��0���L�� ���I�I�v0I�V8H9�t0H��L��L�� ���H)�H��H��0���蒳��H��0���L�� ���Iϋ�(�����w.���H�ੀA����X�����A�FHA�GA�I�F(H�����	H��L��8�����Dž ����@��H���I�F@H���t+H��I�A�8�r����� ���A�P���H����@�� ���L��H����
I9���	M���VH���ZA�H;�8�����H���#	���	L��H������I��H���TC�*L��������L�����L�����H��0���������fDH��0���L��A����DžD�������L)����(���H�����LF��������H�5�4Hc�H�>��f�H��H��H��H%�H)�H���H��H9���H��H��$���H����1���L��H��I���~I9�sKM���`H���r	A�H;�8�����H��������L��H���ڱ��H���H��B�+%M�FI��XI�H�����L9����M���n���DI����&I��L��(���臯��L��(���H��0���M��fDL;�8���t	M����H�����H��tH���*���H������H��H���H�� H9�t����H���H��X���H��H9�t��H��0���E1��H�}�dH3<%(L����H�e�[A\A]A^A_]�D�������ȱ��H�=33H�@Hc�H�>��D諮��H��0����U����E1����M�I9����H�������H;�8���I����H������fDL��L�� �����(���H��0������H��0�����(���H��I��L�� ����{M�������H��L��H��L��(���H��0����n���H��0���L��(���H������A�lI��A�lI����I��L��8���謭��L��8���H��0���M��L���p����-���I�FPK�<*H��H�X���L�H�� ���L�������+���
H�������L�����L���1�H��������L����^_��D������8Hc�L9�sL�B�<)����9�}��D����BL9��>H������Q�B1�L���M����K�$H����H9�HC�I9����M�L9���@L;�8�����M�������}L��L��L�����k���L����H���KI�����I�FPH��H�X���D�H�� ���K�<*L�����������rH�������L�����H�����L��1���ë��Z��D���YL����������H��������������H��0���M�׋��uA�FH�T���<c�E�L;�8���t
M��tL���f���H�����H��tH���R���H������H��H���H�� H9�t�6���H���H��X���H��H9�t����H��0���E1ɉ�'���f�I�FPK�<*L����H��H�X����h�� ����������{H��L������<$����I�FPK�<*L����H��H�X����@�� �����������L�����L������L��H�������B���L�����D���fDI�FPH��H�X���D�H�
����I�FPH��H�X���D�H����I�FPH��H�X���D�H�����I�FPH��H�X���D�H����x>M�I9������H����2���I�����L�(M�����D�
f.�I��L��(���I��莩��H��0�������f����dHDž���H�D$H���H������=���@D�(M���|���DfD�(M���k���@D�(M���\���DI����V���fDM������L��L����衪��L����H��H��t�M��������L��L��H���C���I�����H���t�I������DH�������AQ��L���PD��H����L��1�L�����H������A���H�� L�����?���������AQD��H����<���@H�������AQ�f.������AQ��fD�G�W����I���H����Dž ����g����L�爕0���蒩����0���H��I���/���M������������L��H��H���0���I������I�����I��M����������DI������M���"��L�爕0���������0���H��H�������M���6���.H��L��H��蠨��H���J����L������H������H��H���H�� H9�t�Ħ��H���H��X���H��H9�t訦���æ��E1�����DM�������M�I9������H�����I�����f�A�LI����H���������L���H�����D��H����L��L�����H���|$P1�����H��0L��������H�������H���<$�u���f.���L��������PD��H���L������L��H������蜥��AXL����AY���@H��������@�����H��0���Lc�M�L������L;�8���t
M��tL���R���H�����H��tH���>���H������H��H���H�� H9�t�"���H���H��X���H��H9�t����H��0���E1��K�����H)�H�L����f�H���*���I��L��H����I9�s[M���IH���QA�L;�8���A��M����E����L��L��L��0���蛦��L��0���H������I��C�)L;�8���t%I9�v L��H��L��8����c���L��8���H��LE�H�����H��tL��8�������L��8���H������H��H���H�� H9�tL��8�����L��8���H���H��X���H��H9�tL��8����ɣ��L��8���H����L�(���L��L��0����t���L��0���H��H����M��t?E��t:L��L��H������I���	������M�I9������H������I�����I������I�������I��M������������I����������fD��H�>H�Ft]1�L��'L�(L�
�'�8���Ic�L�>�����/��A�Ӄ�L_�I�H�PH��H�� H9w�1��f����/wqA�Ӄ�L_�A��P��D���/wyA�Ӄ�L_�A�f�P�@���/wIA�Ӄ�L_�A��P�DL�_I�SH�W�v����L�_I�SH�W�f.�L�_I�SH�W�f�L�_I�SH�W�f��W�����A�Ӄ�L_�W�A�@����DH�WH��H���L�ZL�_�*�x��f����/��A�Ӄ�L_�I�H��ID�H�P����fD���/w9A�Ӄ�L_�I�H��ID�H�P���f.�������f.�L�_I�SH�W��f�L�_I�SH�W�;����L�_I�SH�W�n������AWH�F I��A�AVA�I�����AUI��ATUSH��XH�FH�D$(H�BH�H�D$H�H�BH�NH�D$L�6H�D$H�D$ �f�H�o<%t9H�����u�K��I�FH�<�H�D$I�@H�D$I�@1�H��X[]A\A]A^A_�K��M��I�FL�$�I�<$A�D$I�D$I�D$ M�T$(I�D$0I�D$8M�T$@M�T$P�_�C�<	w3���-t;��+tF�� tQ��#t\��0tg��IujA�L$@@�H��H�M��'u�A�L$��A�L$���A�L$���A�L$��A�L$��A�L$ 렀�*tp�C�<	����.�1���=fD��L����lt"��jt�ڃ�߀�Zt��t��f.����]H����hu��������	���H�t$�I�l$I�L$ H��HE�H�D$�E�PЀ�	�2I�\$(H�����M�uI9��,I�EH9�w'fDH�PH��I�UA�I�EM�uH9�v�H��I��������H��H����.������}*I�l$0�zH�t$�H�MI�L$8H��HC�H�D$�E�PЀ�	��I�\$@H�����M�uI9��JI�UH9�w)�H�BH��I�EA�I�UM�uH9�v�H��H��L������H����K���f.����{����Sۀ�S��H�
�"��Hc�H�>��1Ƀ�����
I����gM�|$PM�uM9���I�EL9�w)�H�PH��I�UA�I�EM�uL9�v�I��K�>����w�A�\$HI�l$I�L�pM�0M9�v	I�H�Q���M����H��袋.��K�H9���K��M�`L�D$8I�4CL�L$0H��L9d$(��L��茞��L�L$0L�D$8I�����H��H���VM�`M�0L9d$(��I�HI������H��fDH����JЀ�	v�M�׀�$�k���1��
@��	�JH����������L�փ�0Hc�H9�wH�4�H�H��1��]H�@��H��H���s�H��t�@��	���L��H���0Hc����E��0<	�r@H�����0<	v�H��H)�H��H�t$I�L$8�H9�HC�H�D$�,���M�H�CI9�LF�H��������I9��kL��L�D$HH��L9t$L�L$@L�\$8H�L$0�/L���,���I�UH�L$0I�����H��I��L�\$8L�L$@L�D$H�I�EH9T$�M�u�F���H�t$ H�FI�t$(H����	H�\$ H�D$ ����H���j���L�L$0L�D$8H��H���K��H��L��L�D$8I�FL�L$0H������L�D$8L�L$0I�����H��M�0�
����	��������������������������Ƀ�������1Ƀ����������c�����������1ɨ��������
���y�����q�������c������V�������Ƀ����C�����s�4���H��H���2�~�@��	v�@��$�����1��	��	�WH����������0L��H�H9�wH��H�H��1�H�@��H���H�֍X�H��t���	w^��0L��H��H��ӹ��������������������������������1ɨ�����r����M�uL9t$tL��L�D$萘��L�D$I�xH9|$(t�{���薘���������(���9�������@M�I�GM9�LF�H��������I9��hL��L�D$HH��L9t$L�L$@L�\$8�L$0��L���*����L$0L�\$8I�����H��I��L�L$@L�D$H��H�D$I;E�M�u���H�t$ H�FI�t$PH�������L�|$ H�D$ �w���I�l$�E��0<	w5H���H���AH�Q��0<	v�H�t$H��H��H)�H��H9�HC�H�D$I�l$ �]������������H��H������H�������L$0L�\$8H��L�L$@L�D$HtdI�UL��H��L�D$HL�L$@I��H��L�\$8�L$0葘��L�D$H�L$0I�����L�L$@L�\$8���I��L9t$tL��L�D$軖��L�D$I�xH9|$(t視������H��X�����[]A\A]A^A_�M�H�CI9�LF�H��������I9�w�L��L�D$HH��L9t$L�L$@L�\$8H�L$0��L���\���I�uH�L$0I�����H��I��L�\$8L�L$@L�D$H�?���I�UH9t$��M�u�,������L����H�����H��譗��H�L$0L�\$8H��H��L�L$@L�D$H����I�EH��L��H��L�D$HH��L�L$@I��L�\$8H�L$0�0���I�EL�D$HI�����L�L$@L�\$8H�L$0���M�uL9t$��������H�t$ H�FI�t$@H��������H�\$ H�D$ �S���H��H���2�~�@��	v�@��$�'���1��	��	��H����������0L��H�H9�wH��H�H��1�H�@��H���H�֍X�H��t���	������0L��H��H���I��I��I��������H�i�Y��H���_���H�L$0L�\$8H��L�L$@L�D$H�����I�UH�t$I��H��L��L�D$HL�L$@L�\$8H�L$0���I�UL�D$HI�����L�L$@L�\$8H�L$0� ���H�͸���H�Z�H����_���I�\$@H�O����M�u�!���H�Z�H����:���I�\$(H�O�@���L��L�t$���I����L��L�t$���f���AWI��AVI��AUA��ATL�%d8 UH�-d8 SL)�H���'���H��t1��L��L��D��A��H��H9�u�H��[]A\A]A^A_�ff.����f.����H�8 1�鞕����H��H���!===-nt-ot-ef-eq-ne-lt-le-gt-geinvalid integer %smissing argument after %s-nt does not accept -l-ef does not accept -l-ot does not accept -l%s: unknown binary operator!%s: unary operator expected(%s expected%s expected, found %s-a-o%s: binary operator expectedtesttest and/or [test invocationMulti-call invocationsha224sumsha2 utilitiessha256sumsha384sumsha512sum
%s online help: <%s>
GNU coreutilsen_/usr/share/localeextra argument %s؞������������������8����������������������������������������x���0�������������`���������������������������x���8���К��������`���0��������Try '%s --help' for more information.
Usage: test EXPRESSION
  or:  test
  or:  [ EXPRESSION ]
  or:  [ ]
  or:  [ OPTION
Exit with the status determined by EXPRESSION.

      --help     display this help and exit
      --version  output version information and exit

An omitted EXPRESSION defaults to false.  Otherwise,
EXPRESSION is true or false and sets exit status.  It is one of:

  ( EXPRESSION )               EXPRESSION is true
  ! EXPRESSION                 EXPRESSION is false
  EXPRESSION1 -a EXPRESSION2   both EXPRESSION1 and EXPRESSION2 are true
  EXPRESSION1 -o EXPRESSION2   either EXPRESSION1 or EXPRESSION2 is true

  -n STRING            the length of STRING is nonzero
  STRING               equivalent to -n STRING
  -z STRING            the length of STRING is zero
  STRING1 = STRING2    the strings are equal
  STRING1 != STRING2   the strings are not equal

  INTEGER1 -eq INTEGER2   INTEGER1 is equal to INTEGER2
  INTEGER1 -ge INTEGER2   INTEGER1 is greater than or equal to INTEGER2
  INTEGER1 -gt INTEGER2   INTEGER1 is greater than INTEGER2
  INTEGER1 -le INTEGER2   INTEGER1 is less than or equal to INTEGER2
  INTEGER1 -lt INTEGER2   INTEGER1 is less than INTEGER2
  INTEGER1 -ne INTEGER2   INTEGER1 is not equal to INTEGER2

  FILE1 -ef FILE2   FILE1 and FILE2 have the same device and inode numbers
  FILE1 -nt FILE2   FILE1 is newer (modification date) than FILE2
  FILE1 -ot FILE2   FILE1 is older than FILE2

  -b FILE     FILE exists and is block special
  -c FILE     FILE exists and is character special
  -d FILE     FILE exists and is a directory
  -e FILE     FILE exists
  -f FILE     FILE exists and is a regular file
  -g FILE     FILE exists and is set-group-ID
  -G FILE     FILE exists and is owned by the effective group ID
  -h FILE     FILE exists and is a symbolic link (same as -L)
  -k FILE     FILE exists and has its sticky bit set
  -L FILE     FILE exists and is a symbolic link (same as -h)
  -O FILE     FILE exists and is owned by the effective user ID
  -p FILE     FILE exists and is a named pipe
  -r FILE     FILE exists and read permission is granted
  -s FILE     FILE exists and has a size greater than zero
  -S FILE     FILE exists and is a socket
  -t FD       file descriptor FD is opened on a terminal
  -u FILE     FILE exists and its set-user-ID bit is set
  -w FILE     FILE exists and write permission is granted
  -x FILE     FILE exists and execute (or search) permission is granted

Except for -h and -L, all FILE-related tests dereference symbolic links.
Beware that parentheses need to be escaped (e.g., by backslashes) for shells.
INTEGER may also be -l STRING, which evaluates to the length of STRING.

NOTE: Binary -a and -o are inherently ambiguous.  Use 'test EXPR1 && test
EXPR2' or 'test EXPR1 || test EXPR2' instead.

NOTE: [ honors the --help and --version options, but test does not.
test treats each of those as it treats any other nonempty STRING.

NOTE: your shell may have its own version of %s, which usually supersedes
the version described here.  Please refer to your shell's documentation
for details about the options it supports.
https://www.gnu.org/software/coreutils/Report %s translation bugs to <https://translationproject.org/team/>
Full documentation at: <%s%s>
or available locally via: info '(coreutils) %s%s'
write error%s: %sA NULL argv[0] was passed through an exec system call.
/.libs/lt-’��"'�e‘`literalshellshell-alwaysshell-escapeshell-escape-alwayscc-maybeclocale���������������H���_�������������������$���Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ�����������ԩ�������������Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��Ѫ��/���������%������������y������������������������������������������������������������������������I���Ѫ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������9������9���%�����ը��ը��ը��ը��ը��ը��ة��ȩ������������������X���ը��ը��ը��ը��ը��ը��ը��ը��ը��ը��ը��ը��ը��ը��ը��ը��ը��ը������p���p�������p���+���p���}���p���p���p���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���p���p���p���p���M���ը��+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���p������+���p���+���p���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���+���=���p���=����������Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ����������ܥ�������������Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ��Ԧ���������������ܨ�����|������������ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��������������L���Ԧ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ���������ܨ�����ܨ�����ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��ܨ��<������<����	unable to display error messagememory exhaustedCPOSIXASCII�~�����������x��������P��P��P��P�������������P��P��P��`��P��@��������(NULL)��������������������������������`�����������������������������������(NULL)���,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,���,���,�������,�,�,�,�,�,�,�,�,�,�,�T�,�,�,�,��,�,�,�,�,�,�,�,���,������������,���,�,�,�,������,�,���,��,�,��;�^Tv��,ty��T�|����|��l�|���|��8
�|��h
�|��h�|��,�|����}���~��l��������������ā���������$$����T��������D���T���LĔ���ԙ������$����T���lě�������������D���$����P����dı��x����$����d������	Գ��t	���	�����	�����	�����	Ĵ���	��
����L
���|
$����
D����
���
����
���$�����|���������������Ը�����������0$���D����\T����t���������ļ���Լ��
���,
D���@
Խ��X
4���p
T����
�����
ľ���
���
$���t���X$���t�����D��������,T��L����4�������t��D���\���D�T�$zRx�xz��/D$4 s�� FJw�?:*3$"\v�� t{��dA�
H�\|���AAG���|���A��
J��}��<O���}��'b(�}���A�A�G�o
AAF8,����pB�D�A �A(�G��
(A ABBF zRx������(�w�������'������x�a�\�0�0���?Dz
Bj
FR
FD
LD
LH<���B�B�B �B(�A0�A8�DP_
8A0A(B BBBI\T���iB�B�A �A(�D0r
(A ABBF�
(A ABBJD
(C ABBE ����F�A�C �D�(��v���E�D�F �
AAAГ��̓��,,ȓ���E�A�D @
AAA\X���Pt�����E��
A<�0����A�D�F T
AAGv
AAHrAAt����B�B�E �B(�D0�D8�J���J�J�B�Z�d
8A0A(B BBBF�
�P�D�D�[�$zRx��������,u��h�����B�E�E �B(�A0�D8�D`�hbpIxB�S`@hTpCxB�X`L
8D0A(B BBBF zRx�`������(vt��(,���:F�A�A �nABX,���l8����D���9�p����|���1lP�����xF�L�E �E(�A0�A8�GPUXW`FhApU8A0A(B BBBhԩ���F�L�E �B(�D0�A8�GphxQ�C�B�Zp_xF�C�G�Up[8A0A(B BBB|X���(�T����L�H�A �zAB�Ȫ���Ԫ���Ъ���̪��ت���HP�
AzRx�PSr��T0����HP
AL(r������������0������F�L�D �D`q
 AABA�����������0����F�A�A �D`�
 AABAzRx�`���$-q��8�`����F�E�D �C(�Dpq
(A ABBA�Ĭ��������̬���ج��	Ԭ��$	��8	ܬ��L	ج��iLd	0����F�E�H �G(�D0�s
(A BBBH[
(A BBBE�	�����	����E�S
A�	����(c�	ȯ��	 
�>E�`
KH
A4
��(cH
�����\L`
t���XSx
����E�V�
����2Ka
A$�
��-E�G�G WAA�
��E�L�
�>EARH���LB�B�B �B(�A0�A8�D`
8A0A(B BBBD`����H z
F<|�����F�E�D �A(�G@I
(A ABBJ$������E�L I
AA,�`���eF�A�D �t
ABF����`Hu
C_4��<Ha
GK4T����F�A�A �}
ABH`
ABM�X���HE�]
NS,�����_k�D�D �hAB,������E�C
D��K��D�
F$zRx�������,nl��
L
(��dd
0��>
F�O�O �E(�A0�A8�D��
8A0A(B BBBA�	
8F0A(B BBBAD�
��eF�E�E �E(�H0�H8�G@n8A0A(B BBB0��,(���p�� 1�9�?�L�Y�m�o�R���w�h
���� �� ���o0�P
�� ���@	���o���o0���o�o����o� ������ 0@P`p�������� 0@P`p�������� 0@P`p���p� �� GA$3a1h�GA$3p1067���GA*GA$annobin gcc 8.5.0 20210514GA$running gcc 8.5.0 20210514GA*GA!
GA*FORTIFYGA+GLIBCXX_ASSERTIONSGA*cf_protectionGA+omit_frame_pointerGA+stack_clashGA!stack_realignGA$plugin name: gcc-annobin��uGA*GA*GOW*�GA$3a1��GA$3p10677��GA*GA$annobin gcc 8.5.0 20210514GA$running gcc 8.5.0 20210514GA*GA!
GA*FORTIFYGA+GLIBCXX_ASSERTIONSGA*cf_protectionGA+omit_frame_pointerGA+stack_clashGA!stack_realignGA$plugin name: gcc-annobin7�GA*GA*GOW*�GA$plugin name: annobin���GA*GA*GOW*GA$plugin name: annobin����GA*GA*GOW*GA+GLIBCXX_ASSERTIONS��]
GA*FORTIFY7��GA+GLIBCXX_ASSERTIONS
GA*FORTIFY��]test-8.30-15.el8.x86_64.debug��N�7zXZ�ִF!t/���
]?�E�h=��ڊ�2N�`�:. ��ۺP��jgW�Ϟ�@��ĭj�*
>��B��.�Ps�_��W���0o�s*i3�t�\D}� ��:�m8�VN�(��\���5�/8�����-�?{k!p�c��/��]�����+
�ە�7a^���1�͎ܱ�"P���0E���\�z�HU�����T�4V���utA�&ZK8�7�e1�d_�Ɋ����ެ
�F���gV���X5vD�H`�xE��UZ�:�:�`��s��1�ݍ�ש�0����?^_�S,�J����s�&�ӎ�>r���ApϼK�1�26iQ�\��	v���GX}�<����C϶�#�4ƜϷ�L�B�1�d�JR|��Ug���!�Vo�jR�
r���U+(eJ���b���\��0|�0����@�9Q�&)���ĺv��,XUyr4�O�;7m��D�
�����k��
��3*��RYŒ����8(��p�+�q���`���%
�(��}rD8W�
7��(��S���2z�T�F�M�ߑ��q�6����ao���!�$��! b-�H���3l�׳�0�'�"E@�]q�Ol
#��9�d�a�6��h@Ւ�U���'���C���g�JΫL��;:g"ObܮQ��*����e�7>0Z}u��t���y����eTuN_{N��)����`�^k���_k�=��cN�����$��L�	����ę
�,�f_�*j��t^��}��^����8�q��\�8A@0��G�a/��p�k_��޲���'4���h�J��yuL-��繼���cҭg^*��m�%M<���N��ZsU�{M�g>?��{�vS~���)-4��&C���Jaةo�1��w�L����v}&�Ħ1-�95Ty.E�#�_�i#�7M�/�•��jT�]?��#�|H�.Ȗ�K;�?z$�ow���̍�7����xV�yz�"Ol&)��E��#�'Eأ�~��gxCv6��*&���f�|���P�4������yM�����y�67�ÊO1�:�@��[ZVT�����6Wz�-,ÿ'�E1w�T`�`KZ�*"Ls�����j��������s�ek?��>_0*;����Uc`XM�ӕ�8{�H�$Z��DϨC
���G�
0.���0ٳ�k��"ʙ���
�8�	"f���>���O���1,��:�?q�w��}��+��4���x�s����0��E�	�Ggp"���6��>/�lU� x��IL?�B�?N���t�v�>s�
`g��9m�u���k���,�@����V�*�[>V>�؛#�1�-n�A#82���|0�(�N�W5�j 8:v�B�Ğl/��ʋ��ڷPy���ɭ��/+֍��(�T�}h��莭1.*�<���@��+^�a���j�%YQ�i�����)Wvm�ց8�Ii̒����y'��jR��~�a4�'��>g s��{��xi�7�l�y�k�������/��֔����	EP��y�rvř����u��t!���‘-1)a��5�6l�6�����Xc@����c>���(��T�N��%�=������"�ڦ�L�&��|���<��B�K.4}E�y����p�V5��^L+V[
�;�ؼ(�O�u����2�ˬ�Al�0���m��"��N3;+��n��ٶ��,A��Q?Z�懊s��@�cXB��~c��$�R��˽c���ʑ�9 ������#�:W�Bl\��Y�m�yȓ.2����9"���g�YZ.shstrtab.interp.note.gnu.property.note.ABI-tag.note.gnu.build-id.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rela.dyn.rela.plt.init.plt.sec.text.fini.rodata.eh_frame_hdr.eh_frame.init_array.fini_array.data.rel.ro.dynamic.got.data.bss.gnu.build.attributes.gnu_debuglink.gnu_debugdata���� &�� 4$G���o00QPP�Y���a���o��xn���o00`}��@�B����hh��� �������i�����
�����| �<�<���8�8�@��� ����� ����� ��x �� ���� ���� �� �� ��x 
��`��� �$/,�P|�>qtestroot/plugins.qmltypes000064400000001403150561114020012062 0ustar00import QtQuick.tooling 1.2

// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
// This file was auto-generated by qmltyperegistrar.

Module {
    dependencies: ["QtQuick 2.0"]
    Component {
        file: "private/quicktest_p.h"
        name: "QTestRootObject"
        prototype: "QObject"
        exports: ["Qt.test.qtestroot/QTestRootObject 1.0"]
        isCreatable: false
        isSingleton: true
        exportMetaObjectRevisions: [0]
        Property { name: "windowShown"; type: "bool"; isReadonly: true }
        Property { name: "hasTestCase"; type: "bool" }
        Property { name: "defined"; type: "QObject"; isReadonly: true; isPointer: true }
        Method { name: "quit" }
    }
}
qtestroot/qmldir000064400000000063150561114020010015 0ustar00module Qt.test.qtestroot
typeinfo plugins.qmltypes