Your IP : 216.73.216.52


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_pydoc.cpython-35.opt-2.pyc



���]ޝ�
@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ddlm*Z*yddl+Z+Wne,k
r�dZ+YnXGdd�d�Z-ej.j/r�d9Z0nd:Z0d
j1�Z2e3dd�e0D��Z4dj1�Z5e3dd�e0D��Z6dj7dej8�Z9dZ:dj1�Z;dj1�Z<dj1�Z=dj1�Z>dj1�Z?dd�Z@dd�ZAdd�ZBd d!�ZCd"d#�ZDGd$d%�d%ejE�ZFGd&d'�d'ejE�ZGGd(d)�d)eF�ZHGd*d+�d+ejE�ZIejJe+d,�Gd-d.�d.ejE��ZKGd/d0�d0eF�ZLGd1d2�d2ejE�ZMGd3d4�d4ejE�ZNe$d5d6��ZOePd7kr�eO�dS);�N)�StringIO)�
namedtuple)�assert_python_ok)	�TESTFN�rmtree�
reap_children�reap_threads�captured_output�captured_stdout�captured_stderr�unlink�requires_docstrings)�	pydoc_modc@seZdZdS)�nonasciiN)�__name__�
__module__�__qualname__�rr�//opt/alt/python35/lib64/python3.5/test_pydoc.pyr'sr�.dictionary for instance variables (if defined)�2list of weak references to the object (if defined)��a0
NAME
    test.pydoc_mod - This is a test module for test_pydoc
%s
CLASSES
    builtins.object
        A
        B
        C
    
    class A(builtins.object)
     |  Hello and goodbye
     |  
     |  Methods defined here:
     |  
     |  __init__()
     |      Wow, I have no function!
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __dict__%s
     |  
     |  __weakref__%s
    
    class B(builtins.object)
     |  Data descriptors defined here:
     |  
     |  __dict__%s
     |  
     |  __weakref__%s
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |  
     |  NO_MEANING = 'eggs'
    
    class C(builtins.object)
     |  Methods defined here:
     |  
     |  get_answer(self)
     |      Return say_no()
     |  
     |  is_it_true(self)
     |      Return self.get_answer()
     |  
     |  say_no(self)
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)

FUNCTIONS
    doc_func()
        This function solves all of the world's problems:
        hunger
        lack of Python
        war
    
    nodoc_func()

DATA
    __xyz__ = 'X, Y and Z'

VERSION
    1.2.3.4

AUTHOR
    Benjamin Peterson

CREDITS
    Nobody

FILE
    %s
ccs%|]}|rd|ndVqdS)z
     |      rNr)�.0�srrr�	<genexpr>�sra�
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="test.html"><font color="#ffffff">test</font></a>.pydoc_mod</strong></big></big> (version 1.2.3.4)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:%s">%s</a>%s</font></td></tr></table>
    <p><tt>This&nbsp;is&nbsp;a&nbsp;test&nbsp;module&nbsp;for&nbsp;test_pydoc</tt></p>
<p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%"><dl>
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="test.pydoc_mod.html#A">A</a>
</font></dt><dt><font face="helvetica, arial"><a href="test.pydoc_mod.html#B">B</a>
</font></dt><dt><font face="helvetica, arial"><a href="test.pydoc_mod.html#C">C</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="A">class <strong>A</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Hello&nbsp;and&nbsp;goodbye<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%%">Methods defined here:<br>
<dl><dt><a name="A-__init__"><strong>__init__</strong></a>()</dt><dd><tt>Wow,&nbsp;I&nbsp;have&nbsp;no&nbsp;function!</tt></dd></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>%s</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>%s</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="B">class <strong>B</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%">Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>%s</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>%s</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>NO_MEANING</strong> = 'eggs'</dl>

</td></tr></table> <p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="C">class <strong>C</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%">Methods defined here:<br>
<dl><dt><a name="C-get_answer"><strong>get_answer</strong></a>(self)</dt><dd><tt>Return&nbsp;<a href="#C-say_no">say_no</a>()</tt></dd></dl>

<dl><dt><a name="C-is_it_true"><strong>is_it_true</strong></a>(self)</dt><dd><tt>Return&nbsp;self.<a href="#C-get_answer">get_answer</a>()</tt></dd></dl>

<dl><dt><a name="C-say_no"><strong>say_no</strong></a>(self)</dt></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%"><dl><dt><a name="-doc_func"><strong>doc_func</strong></a>()</dt><dd><tt>This&nbsp;function&nbsp;solves&nbsp;all&nbsp;of&nbsp;the&nbsp;world's&nbsp;problems:<br>
hunger<br>
lack&nbsp;of&nbsp;Python<br>
war</tt></dd></dl>
 <dl><dt><a name="-nodoc_func"><strong>nodoc_func</strong></a>()</dt></dl>
</td></tr></table><p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%"><strong>__xyz__</strong> = 'X, Y and Z'</td></tr></table><p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
    
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%">Benjamin&nbsp;Peterson</td></tr></table><p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Credits</strong></big></font></td></tr>
    
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%">Nobody</td></tr></table>
ccs!|]}|jdd�VqdS)� z&nbsp;N)�replace)rrrrrrsz~No Python documentation found for %r.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.�
z/problem in %s - ImportError: No module named %ra/
Help on class DA in module %s:

class DA(builtins.object)
 |  Data descriptors defined here:
 |  
 |  __dict__%s
 |  
 |  __weakref__%s
 |  
 |  ham
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from Meta:
 |  
 |  ham = 'spam'
z�
Help on class Class in module %s:

class Class(builtins.object)
 |  Data and other attributes inherited from Meta:
 |  
 |  LIFE = 42
z�
Help on class Class1 in module %s:

class Class1(builtins.object)
 |  Data and other attributes inherited from Meta1:
 |  
 |  one = 1
a
Help on class Class2 in module %s:

class Class2(Class1)
 |  Method resolution order:
 |      Class2
 |      Class1
 |      builtins.object
 |  
 |  Data and other attributes inherited from Meta1:
 |  
 |  one = 1
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from Meta3:
 |  
 |  three = 3
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from Meta2:
 |  
 |  two = 2
z�
Help on class C in module %s:

class C(builtins.object)
 |  Data and other attributes defined here:
 |  
 |  here = 'present!'
cOs8||f}tdtj||�\}}}|j�S)Nz-B)r�pydoc�__file__�strip)�module_name�args�env�rc�out�errrrr�	run_pydocRs
!r(cCsTtj�}|j|�}|jt�p-d}|rDd|d}|j�|fS)Nrz
<br><a href="z">Module Docs</a>)rZHTMLDoc�	docmodule�	getdoclocrr!)�module�doc�output�locrrr�get_pydoc_html\sr/cCsCtjj}||t��}tj�}|j|d|�}|S)N�basedir)�os�path�dirnamer r�TextDocr*)r+r3r0r,r.rrr�get_pydoc_linkes
r5cCsutj�}|jt�pd}|r5d|d}|j|�}tjd�}|jd|�}|j�|fS)Nrz
MODULE DOCS
    rz.)	rr4r*rr)�re�compile�subr!)r+r,r.r-Zpattrrr�get_pydoc_textmsr9cCsL|jd�\}}}|jd�\}}}|jd�\}}}|S)Nz</head>z<title>z</title>)�	partition)�text�header�_�titlerrr�get_html_title{sr?c@sCeZdZddd�Zejddd��Zdd�ZdS)�
PydocBaseTestNcs=|ptjjt�g�ddd��fdd�}|S)Nrcs�|p�||�S)Nr)r2�prefix�onerror)�default_path�
walk_packagesrr�wrapper�sz8PydocBaseTest._restricted_walk_packages.<locals>.wrapper)r1r2r3r )�selfrDr2rEr)rCrDr�_restricted_walk_packages�sz'PydocBaseTest._restricted_walk_packagesccs8tj}|j||�t_z	dVWd|t_XdS)N)�pkgutilrDrG)rFr2rDrrr�restrict_walk_packages�s			z$PydocBaseTest.restrict_walk_packagescCs5tj|d�}t|�}|j|||�|S)Nz	text/html)r�_url_handlerr?�assertEqual)rF�urlZexpected_titler;�resultrrr�call_url_handler�szPydocBaseTest.call_url_handler)rrrrG�
contextlib�contextmanagerrIrNrrrrr@�s
	r@c@s)eZdZejejjdkd�ejeed�oEej	�d�e
dd����Zejejjdkd�ejeed�o�ej	�d�e
dd����Zd	d
�Z
dd�Zd
d�Zdd�Zdd�Zdd�Zejejjdkd�dd��Zdd�Zdd�Zejejjdkd�ejeed�o}ej	�d�e
dd����Zdd�Zd d!�Zejejjdkd�d"d#��Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0S)1�PydocDocTestrz)Docstrings are omitted with -O2 and above�gettracez1trace function introduces __locals__ unexpectedlycCs^tt�\}}tjt�}tjj|�}t|||ft}|j	||�dS)N)
r/r�inspect�
getabsfile�urllib�parse�quote�expected_html_pattern�expected_html_data_docstringsrK)rFrM�doc_locZmod_fileZmod_urlZ
expected_htmlrrr�
test_html_doc�szPydocDocTest.test_html_doccCsGtt�\}}t|fttjt�f}|j||�dS)N)r9r�expected_text_pattern�expected_text_data_docstringsrSrTrK)rFrMrZ�
expected_textrrr�
test_text_doc�s

zPydocDocTest.test_text_doccCsHddl}Gdd�d|j�}tj|�}|jd|�dS)Nrc@seZdZdZdZdS)zIPydocDocTest.test_text_enum_member_with_value_zero.<locals>.BinaryIntegerr�N)rrrZzero�onerrrr�
BinaryInteger�srbz<BinaryInteger.zero: 0>)�enum�IntEnumr�
render_doc�assertIn)rFrcrbr,rrr�%test_text_enum_member_with_value_zero�sz2PydocDocTest.test_text_enum_member_with_value_zerocCs&ttjj�}|jd|�dS)Nzxml.etree.elementtree)r5�xml�etreeZElementTreerf)rFZdoc_linkrrr�,test_mixed_case_module_names_are_lower_cased�sz9PydocDocTest.test_mixed_case_module_names_are_lower_casedcCs,ttj�\}}|j|dd�dS)Nrz'MODULE DOCS incorrectly includes a link)r9rhrirK)rFrMrZrrr�test_issue8225�szPydocDocTest.test_issue8225cCs1tj}zdt_tj�Wd|t_XdS)N)�sys�stdinr�getpager)rFZprevious_stdinrrr�test_getpager_with_stdin_none�s
		z*PydocDocTest.test_getpager_with_stdin_nonecCsjGdd�d�}Gdd�d�}tj|��}tj|��}|j|jdd�|�dS)Nc@seZdZdZdS)z)PydocDocTest.test_non_str_name.<locals>.A�*N)rrrrrrr�A�srqc@seZdZdS)z)PydocDocTest.test_non_str_name.<locals>.BN)rrrrrrr�B�srr)rrerKr)rFrqrrZadocZbdocrrr�test_non_str_name�s
zPydocDocTest.test_non_str_namecCs<d}tt|�d�}t|}|j||d�dS)Nztest.i_am_not_here�asciiz&documentation for missing module found)�strr(�missing_patternrK)rF�missing_modulerM�expectedrrr�
test_not_here�s

zPydocDocTest.test_not_herez)Docstrings are omitted with -OO and abovecCs;tddd�}tjjdd�}|j||�dS)Nztest.test_pydoc.nonasciiZPYTHONIOENCODINGrt�backslashreplace)r(r�__doc__�encoderf)rFrM�encodedrrr�test_not_ascii�szPydocDocTest.test_not_asciicCs?d}tt|�d�}t|j�}|j||�dS)Nz test.i_am_not_here rt)rur(rvr!rK)rFrwrMrxrrr�test_input_strip�szPydocDocTest.test_input_stripcCsetj}|j|d�d�|j|d�d�|j|d�d�|j|d�d�dS)Nz<function stripid at 0x88dcee4>z<function stripid>z <function stripid at 0x01F65390>Z42z<type 'exceptions.Exception'>)r�stripidrK)rFr�rrr�test_stripid�s	zPydocDocTest.test_stripidcCsBt}tj}dd�}d|_t�}tjd|�}tt�\}}d}dj�}	t	j
|	�}	|	t}
|t_z�td���}td���}|j|�|j
�j�}
|
|fttjt�f}|jd|j
��|jd|j
��|j||
�WdQRXWdQRXWd|t_XdS)	NcSs
dd�S)NcSs|S)Nr)�xrrr�<lambda>szJPydocDocTest.test_help_output_redirect.<locals>.<lambda>.<locals>.<lambda>rrrrrr�sz8PydocDocTest.test_help_output_redirect.<locals>.<lambda>r-ztest.pydoc_modz9
        Help on module test.pydoc_mod in test:

        �stdout�stderrr)r\rrnZmaxDiffr�Helperr9r�lstrip�textwrap�dedentr	�help�getvaluer!r]rSrTrK)rFZold_patternZgetpager_oldZgetpager_new�buf�helperZunusedrZr+Zhelp_headerZexpected_help_patternr-r'rMr^rrr�test_help_output_redirects0			
	

"z&PydocDocTest.test_help_output_redirectc
Cs{tdddgdd�}t��}tj|�WdQRX|j�}|jd|�|jd|�|jd|�dS)	N�NT�abc�def�renameTZ_1�_replace�_asdict)rr
rr�r�rf)rFr��help_io�helptextrrr�!test_namedtuple_public_underscore.sz.PydocDocTest.test_namedtuple_public_underscorecCs�|jtt�x�d
D]�}ttdd|��L}|dkrZtdj|�d|�tdd|�tdd|�WdQRXtjti�}|j|d	�qWdS)N�
ISO-8859-1�UTF-8�w�encodingz#coding: {}�fileu"""line 1: héz
line 2: hi"""uline 1: hé)r�r�)	�
addCleanuprr�open�print�formatr�synopsisrK)rFr�Zscriptr�rrr�
test_synopsis7s
zPydocDocTest.test_synopsiscCs?tjj�d}tj}tj|�}|j||�dS)Nr)r1r{�
splitlines�
__cached__rr�rK)rFrx�filenamer�rrr�test_synopsis_sourcelessBs	z%PydocDocTest.test_synopsis_sourcelesscCs�tjj���}tjj|d�}tjj|�}t	|d��}|j
d�WdQRXtj|�t
j|i�}|j|�t
j|i�}|j|�WdQRXdS)Nzfoomod42.pyr�zfoo = 1)�test�support�temp_cwdr1r2�join�	importlib�util�cache_from_sourcer��write�
py_compiler7rr��assertIsNone)rF�test_dir�	init_pathZcached_path�fobjr�Zsynopsis_cachedrrr�"test_synopsis_sourceless_empty_docKs

z/PydocDocTest.test_synopsis_sourceless_empty_doccCs#d}|jtj|�d�dS)Nz#I Am A Doc


Here is my description�
I Am A Doc�
Here is my description)r�r�)rKrZsplitdoc)rFZexample_stringrrr�test_splitdoc_with_descriptionWsz+PydocDocTest.test_splitdoc_with_descriptioncCsXtj�}|jtj|j��|jtjtj��|jtjd��dS)NzI am not a method)rZDoc�
assertTrueZ_is_some_method�fail�int�__add__�assertFalse)rFr,rrr�test_is_object_or_method\sz%PydocDocTest.test_is_object_or_methodc
Cs3tjj��}|jtj|��WdQRXdS)N)r�r�r�r�r�	ispackage)rFr�rrr� test_is_package_when_not_packageesz-PydocDocTest.test_is_package_when_not_packagec
Cshtjj��R}tjj|d�}t|d�j�|jt	j
|��tj|�WdQRXdS)Nz__init__.pyr�)r�r�r�r1r2r�r��closer�rr��remove)rFr�r�rrr�test_is_package_when_is_packageis
z,PydocDocTest.test_is_package_when_is_packagecCssGdd�dt�}ttt��}|j|d<|d=|d=|j|d<tj|�}|j||�dS)Nc@seZdZdd�ZdS)z/PydocDocTest.test_allmethods.<locals>.TestClasscSsdS)NTr)rFrrr�method_returning_truewszEPydocDocTest.test_allmethods.<locals>.TestClass.method_returning_trueN)rrrr�rrrr�	TestClassvsr�r�r{�	__class__�__subclasshook__)�object�dict�varsr�r�rZ
allmethodsZassertDictEqual)rFr�rx�methodsrrr�test_allmethodsps

zPydocDocTest.test_allmethodsN) rrr�unittest�skipIfrl�flags�optimize�hasattrrRr
r[r_rgrjrkrorsryr~rr�r�r�r�r�r�r�r�r�r�r�rrrrrQ�sF
	

$		rQc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	j
d
�dd��Ze	j
d
�dd��Ze	j
d�dd��Z
dd�ZdS)�PydocImportTestcCs0tjt�|_|jtt�tj�dS)N)r1�mkdirrr�r�rr��invalidate_caches)rFrrr�setUp�szPydocImportTest.setUpc	Cs�d}d
dddj|�dfdj|�dj|�ff}tjjt|�tjd}x~|D]v\}}t|d	��}|jd
j|��WdQRXt|dt�j	d�}t
||f}|j||�qiWdS)NZ
testmod_xyzzy�
i_am_not_here�test.i_am_not_here_either�test.i_am_not_here.neither_am_i�test.i_am_not_herezi_am_not_here.{}ztest.{}�pyr�z
import {}
�
PYTHONPATHrt)r�r�)r�r�)r�r�)r�r1r2r�r�extsepr�r�r(�decode�badimport_patternrK)	rF�modnameZ	testpairsZsourcefnZimportstringZ
expectedinmsg�frMrxrrr�test_badimport�s! zPydocImportTest.test_badimportc-CsMtjjtd�}tj|�tjj|d�tjd}t|d��}|jd�WdQRX|jdtg���t	��'}t
��}tjd�WdQRXWdQRX|j
|j�d�|j
|j�d�t	��'}t
��}tjd�WdQRXWdQRX|j
|j�j�d�|j
|j�d�WdQRXdS)	NZ	syntaxerr�__init__r�r�zinvalid python syntax = $1
r2Zxyzzyr)r1r2r�rr�r�r�r�rIr
rr�aproposrKr�r!)rF�pkgdirZ	badsyntaxr�r&r'rrr�test_apropos_with_bad_package�s 
 z-PydocImportTest.test_apropos_with_bad_packagecCs�tjjtd�|_tj|jd�|jtj|j�|jdtg��8t	��'}t
��}tjd�WdQRXWdQRXWdQRX|j
|j�d�|j
|j�d�dS)NZ
unreadablerr2ZSOMEKEYr)r1r2r�rZunreadable_dirr�r��rmdirrIr
rrr�rKr�)rFr&r'rrr� test_apropos_with_unreadable_dir�s"z0PydocImportTest.test_apropos_with_unreadable_dircCstjjtd�}tj|�|jt|�tjj|d�}t|d��}|jd�WdQRXt	j
tj	|�j�}zotj||t	j
@�|jdtg��%t��}tjd�WdQRXWdQRX|jd|j��Wdtj||�XdS)NZwalkpkgz__init__.pyr�zfoo = 1r2r)r1r2r�rr�r�rr�r��stat�S_IMODE�st_mode�chmod�S_IEXECrIr
rr�rfr�)rFr�r�r�Zcurrent_moder�rrr�test_apropos_empty_doc�s
"z&PydocImportTest.test_apropos_empty_docc Cstjjtd�}tj|�tjj|d�}t|ddd��}|jd�WdQRX|jdtg���tt	j�}t	jj
dt�zR|jtd	��ddl
}WdQRX|jd
d�}d}|j||�Wd|t	jdd�<XWdQRXdS)
N�test_error_packagez__init__.pyZwtr�rtzraise ValueError("ouch")
r2rZouchzsearch?key=test_error_packagezPydoc: Search Resultsz8<a href="test_error_package.html">test_error_package</a>)r1r2r�rr�r�r�rI�tuplerl�insertZassertRaisesRegex�
ValueErrorr�rNrf)rFr�Zinitr�Zsaved_pathsr�r;�foundrrr�test_url_search_package_error�s 
		z-PydocImportTest.test_url_search_package_errorz(causes undesirable side-effects (#20128)c	Cs}d}d}d}|||}t�}tjd|�}|d�|j�j�}t|j��}|j||�dS)Nr��r-�modules)rrr�r�r!�lenr�ZassertGreaterEqual)	rFZnum_header_linesZnum_module_lines_minZnum_footer_linesrxr-r�rMZ	num_linesrrr�test_modules�s	
zPydocImportTest.test_modulesc
Cs^d}t�}tjd|�}t��}|d�WdQRX|j�}|j||�dS)Nzpydoc - r-z
modules pydoc)rrr�r
r�rf)rFrxr-r�r�rMrrr�test_modules_searchs	z#PydocImportTest.test_modules_searchz+some buildbots are not cooperating (#20128)c
Csdd}t�}tjd|�}t��}|d�WdQRX|j�}|j|j|��dS)Nzgc - r-zmodules garbage)rrr�r
r�r��
startswith)rFrxr-r�r�rMrrr�test_modules_search_builtin
s	z+PydocImportTest.test_modules_search_builtincCsetjtj�}|j|t�|j|jd�|j|jtj�|j|jtj�dS)Nr)rZ
importfiler ZassertIsNotrKr�__spec__)rFZloaded_pydocrrr�test_importfiles
zPydocImportTest.test_importfileN)rrrr�r�r�r�r�r�r��skipr�r�r�r�rrrrr��s
r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zed	d
��Zdd�Z	e
d
d��Zdd�Ze
dd��Z
e
dd��ZdS)�TestDescriptionscCs3ddlm}tj|�}|jd|�dS)Nr)�pydocfodderr�)r�r�rrerf)rFr�r,rrr�test_module$szTestDescriptions.test_modulecCsuGdd�d�}|�}|jtj|�d�|jtj|�d�dt}|j|tj|��dS)Nc@seZdZdS)z&TestDescriptions.test_class.<locals>.CN)rrrrrrr�C+srzclass CzC in module %s object)rKrZdescriberrfre)rFr�crxrrr�
test_class*s	
zTestDescriptions.test_classcCs�tjtjttjtjttjfddd��}tjd�}Gdd�dtj|tjtt	f�}|j
tj|�j
�dd�|j
tj|�j
�d	d
�dS)N)�datar��returncSsddS)N.r)rr�rrr�foo4sz/TestDescriptions.test_typing_pydoc.<locals>.foo�Tc@seZdZddS)z-TestDescriptions.test_typing_pydoc.<locals>.C.N)rrrrrrrr8srr`z=ffoooo(data:List[Any], x:int) -> Iterator[Tuple[int, Any]]rzclass CC(typing.Mapping)���)�typingZListZAnyr��IteratorZTupleZTypeVarZGeneric�MappingrurKrrer�)rFrrrrrr�test_typing_pydoc3s
/-z"TestDescriptions.test_typing_pydoccCs�x`dD]X}|jtj|��ytj|�Wqtk
r^|jdj|��YqXqWx:d
D]2}|jtj|��|jttj|�qjWdS)Nru�
str.translate�builtins.str�builtins.str.translatezfinding the doc of {!r} failed�notbuiltins�strrr�strr.translate�str.trrrranslate�builtins.strrr�builtins.str.trrranslate)rur
rr)rrrrrr)	ZassertIsNotNonerZlocatere�ImportErrorr�r�r��assertRaises)rF�namerrr�test_builtin?s


zTestDescriptions.test_builtincCs/tjtj|��}|jd�}|dS)Nrr)rZplainre�split)�or;�linesrrr�_get_summary_linePsz"TestDescriptions._get_summary_linecCs#|j|jtjj�d�dS)Nzwrap(self, text))rKrr��TextWrapper�wrap)rFrrr�test_unbound_python_methodXsz+TestDescriptions.test_unbound_python_methodcCs#|j|jtjj�d�dS)Nzdump(self, obj, /))rKr�_pickle�Pickler�dump)rFrrr�test_unbound_builtin_method\sz,TestDescriptions.test_unbound_builtin_methodcCs,tj�}|j|j|j�d�dS)Nz2wrap(text) method of textwrap.TextWrapper instance)r�rrKrr)rF�trrr�test_bound_python_methodbsz)TestDescriptions.test_bound_python_methodcCs8t�}tj|�}|j|j|j�d�dS)Nz/dump(obj, /) method of _pickle.Pickler instance)rr!r"rKrr#)rFr�prrr�test_bound_builtin_methodgs	z*TestDescriptions.test_bound_builtin_methodcCs |j|jtj�d�dS)Nz0stat(path, *, dir_fd=None, follow_symlinks=True))rKrr1r�)rFrrr�test_module_level_callableosz+TestDescriptions.test_module_level_callableN)rrrrrrr�staticmethodrr r
r$r&r(r)rrrrr�"s	r�z!Threading required for this test.c@seZdZdd�ZdS)�PydocServerTestcCs�dd�}tj|dd�}|jd|jj�tj�}d}xD|jr�tjd�|jrLtj�||krL|j�PqLW|j	|j
d�dS)NcSsd||f}|S)Nzthe URL sent was: (%s, %s)r)rLZcontent_typer;rrr�my_url_handler|sz3PydocServerTest.test_server.<locals>.my_url_handler�portr�	localhostr`g{�G�z�?)rZ
_start_serverrfZ	docserver�address�timeZserving�sleep�stoprK�error)rFr,ZserverthreadZ	starttime�timeoutrrr�test_serverys

zPydocServerTest.test_serverN)rrrr5rrrrr+usr+c@s(eZdZdd�Zdd�ZdS)�PydocUrlHandlerTestcCs9tj}|jt|dd�|jt|dd�dS)Nrqrrr�foobar)rrJr�	TypeError)rFr�rrr�test_content_type_err�s	z)PydocUrlHandlerTest.test_content_type_errc
Cs�ddddddddd d!d"d#g}|j��Yx$|D]\}}|j||�q>Wtj}d|}d|}|j||�WdQRXdS)$Nr�Pydoc: Index of Modules�get?key=�index�topics�
Pydoc: Topics�keywords�Pydoc: Keywordsr�Pydoc: module pydoc�
get?key=pydoc�search?key=pydoc�Pydoc: Search Results�
topic?key=def�Pydoc: KEYWORD def�topic?key=STRINGS�Pydoc: TOPIC STRINGSr7�Pydoc: Error - foobar�getfile?key=foobar�!Pydoc: Error - getfile?key=foobarzPydoc: getfile zgetfile?key=)rr:)r;r:)r<r:)r=r>)r?r@)rrA)rBrA)rCrD)rErF)rGrH)r7rI)rJrK)rIrN�stringr )rFZrequestsrLr>r2rrr�test_url_requests�s&	
	

z%PydocUrlHandlerTest.test_url_requestsN)rrrr9rMrrrrr6�sr6c@seZdZdd�ZdS)�
TestHelpercCs)|jttjj�ttj��dS)N)rK�sortedrr�r?�keyword�kwlist)rFrrr�
test_keywords�szTestHelper.test_keywordsN)rrrrRrrrrrN�srNc@s`eZdZejejjdkd�ejeed�oEej	�d�dd���Z
ejejjdkd�ejeed�o�ej	�d�dd���Zejejjdkd�ejeed�o�ej	�d�d	d
���Zejejjdkd�ejeed�o8ej	�d�dd���Z
d
d�ZdS)�PydocWithMetaClassesrz)Docstrings are omitted with -O2 and aboverRz1trace function introduces __locals__ unexpectedlycCs�Gdd�dt�}Gdd�dd|�}tdd�tD��}t�}tjd|�}||�ttf|dd	�}|j�j	�}|j
||�dS)
Ncs"eZdZ�fdd�Z�S)z=PydocWithMetaClasses.test_DynamicClassAttribute.<locals>.Metacs |dkrdSt�j|�S)N�hamZspam)�super�__getattr__)rFr)r�rrrV�szIPydocWithMetaClasses.test_DynamicClassAttribute.<locals>.Meta.__getattr__)rrrrVrr)r�r�Meta�srWc@s%eZdZejdd��ZdS)z;PydocWithMetaClasses.test_DynamicClassAttribute.<locals>.DAcSsdS)NZeggsr)rFrrrrT�sz?PydocWithMetaClasses.test_DynamicClassAttribute.<locals>.DA.hamN)rrr�types�DynamicClassAttributerTrrrr�DA�srZ�	metaclasscss%|]}|rd|ndVqdS)z	
 |      rNr)rrrrrr�szBPydocWithMetaClasses.test_DynamicClassAttribute.<locals>.<genexpr>r-r)�typer��expected_data_docstringsrrr��!expected_dynamicattribute_patternrr�r!rK)rFrWrZr]r-r�r^rMrrr�test_DynamicClassAttribute�s
	
z/PydocWithMetaClasses.test_DynamicClassAttributecCs�Gdd�dt�}Gdd�dd|�}t�}tjd|�}||�tt}|j�j�}|j||�dS)Ncs.eZdZdd�Z�fdd�Z�S)zHPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.MetacSsddddgS)Nr�rr�LIFEr)�clsrrr�__dir__�szPPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.Meta.__dir__cs |dkrdSt�j|�S)Nr`rp)rUZ_Meta__getattr)rFr)r�rrrV�szTPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.Meta.__getattr__)rrrrbrVrr)r�rrW�srWc@seZdZdS)zIPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.ClassN)rrrrrrr�Class�srcr[r-)	r\rrr��"expected_virtualattribute_pattern1rr�r!rK)rFrWrcr-r�r^rMrrr�%test_virtualClassAttributeWithOneMeta�s	

z:PydocWithMetaClasses.test_virtualClassAttributeWithOneMetacs3Gdd�dt��Gdd�dt��G��fdd�d���}Gdd�dd	��}Gd
d�d|d	|�}d}}t�}tjd
|�}||�tt}|j�j�}	|j||	�t�}tjd
|�}||�t	t}
|j�j�}|j|
|�dS)Ncs.eZdZdd�Z�fdd�Z�S)zIPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1cSsddddgS)Nr�rrrar)rarrrrb�szQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1.__dir__cs |dkrdSt�j|�S)Nrar`)rUrV)rFr)r�rrrV�szUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1.__getattr__)rrrrbrVrr)r�r�Meta1�srfcs.eZdZdd�Z�fdd�Z�S)zIPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2cSsddddgS)Nr�rr�twor)rarrrrb�szQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2.__dir__cs |dkrdSt�j|�S)Nrgr)rUrV)rFr)r�rrrV�szUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2.__getattr__)rrrrbrVrr)r�r�Meta2�srhcs7eZdZ��fdd�Z�fdd�Z�S)zIPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3cs<tttddddg�j|��j|����S)Nr�rr�three)�listrO�setrb)ra)rfrhrrrb�s	zQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3.__dir__cs |dkrdSt�j|�S)Nrir�)rUrV)rFr)r�rrrV�szUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3.__getattr__)rrrrbrVr)rfrh)r�r�Meta3�srlc@seZdZdS)zJPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Class1N)rrrrrrr�Class1srmr[c@seZdZdS)zJPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Class2N)rrrrrrr�Class2srnFr-)
r\rrr��"expected_virtualattribute_pattern2rr�r!rK�"expected_virtualattribute_pattern3)rFrlrmrnZfail1Zfail2r-r�Zexpected_text1Zresult1Zexpected_text2Zresult2r)rfrhr�%test_virtualClassAttributeWithTwoMeta�s$"	
	

	

z:PydocWithMetaClasses.test_virtualClassAttributeWithTwoMetacCs�Gdd�dt�}Gdd�dd|�}t�}tjd|�}||�tt}|j�j�}|j||�dS)Nc@seZdZdd�ZdS)z.PydocWithMetaClasses.test_buggy_dir.<locals>.McSsddddgS)Nr�r�missing�herer)rarrrrbsz6PydocWithMetaClasses.test_buggy_dir.<locals>.M.__dir__N)rrrrbrrrr�Msrtc@seZdZdZdS)z.PydocWithMetaClasses.test_buggy_dir.<locals>.Czpresent!N)rrrrsrrrrrsrr[r-)	r\rrr��!expected_missingattribute_patternrr�r!rK)rFrtrr-r�r^rMrrr�test_buggy_dirs	

z#PydocWithMetaClasses.test_buggy_dirc
Cs@t��}tjd�WdQRX|j�}|jd|�dS)Nz	enum.Enumz
class Enum)r
rr�r�rf)rFr�r�rrr�test_resolve_false&sz'PydocWithMetaClasses.test_resolve_falseN)rrrr�r�rlr�r�r�rRr_rerqrvrwrrrrrS�s"+rScCs5z&tjjttttttt	�Wdt
�XdS)N)r�r�Zrun_unittestrQr�r�r+r6rNrSrrrrr�	test_main/srx�__main__)rr)rrrr)rrrr)Qr1rl�builtinsrO�importlib.utilr�rSrr�rPr!rHr6r�rLZtest.supportr�r0rXr	r�Zurllib.parserUZ	xml.etreerhZxml.etree.ElementTreer��ior�collectionsrZtest.support.script_helperrrrrrr	r
rrr
r�	threadingrrr�ZHAVE_DOCSTRINGSr]r!r\r�r]rXrYr�lineseprvr�r^rdrorprur(r/r5r9r?ZTestCaser@rQr�r�Z
skipUnlessr+r6rNrSrxrrrrr�<module>s�@
	R
y
			
	��S%v