Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/test_pydoc.cpython-34.pyc

�
f f~��
@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZddlmZddlm 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�d8Z/nd9Z/d
j0�Z1e2dd�e/D��Z3dj0�Z4e2dd�e/D��Z5dZ6dZ7dj0�Z8dj0�Z9dj0�Z:dj0�Z;dj0�Z<dd�Z=dd�Z>dd�Z?dd �Z@d!d"�ZAGd#d$�d$ejB�ZCGd%d&�d&ejB�ZDGd'd(�d(eC�ZEGd)d*�d*ejB�ZFejGe*d+�Gd,d-�d-ejB��ZHGd.d/�d/eC�ZIGd0d1�d1ejB�ZJGd2d3�d3ejB�ZKe#d4d5��ZLeMd6kr�eL�ndS):�N)�StringIO)�
namedtuple)�assert_python_ok)	�TESTFN�rmtree�
reap_children�reap_threads�captured_output�captured_stdout�captured_stderr�unlink�requires_docstrings)�	pydoc_modc@seZdZdZdS)�nonasciiuЦе не латиницяN)�__name__�
__module__�__qualname__�__doc__�rr�4/opt/alt/python34/lib64/python3.4/test/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 '%s'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)zW
    Runs pydoc on the specified module. Returns the stripped
    output of pydoc.
    z-B)r�pydoc�__file__�strip)Zmodule_name�args�env�rc�out�errrrr�	run_pydocNs
!r'cCsWtj�}|j|�}|jt�p-d}|rGd|d}n|j�|fS)z&Returns pydoc generated output as htmlrz
<br><a href="z">Module Docs</a>)rZHTMLDoc�	docmodule�	getdoclocrr!)�module�doc�output�locrrr�get_pydoc_htmlXsr.cCsxtj�}|jt�pd}|r8d|d}n|j|�}tjd�}|jd|�}|j�|fS)z&Returns pydoc generated output as textrz
MODULE DOCS
    �
z.)	rZTextDocr)rr(�re�compile�subr!)r*r+r-r,Zpattrrr�get_pydoc_textasr3c	Csc|jdd�}|jdd�}tj||dddddd�}td	d
j|��dS)z"Prints unified diffs for two texts�keependsT�nrZfromfile�expectedZtofileZgotr/rN)�
splitlines�difflibZunified_diff�print�join)Ztext1Ztext2Zlines1Zlines2Zdiffsrrr�print_diffsos
	r;cCsL|jd�\}}}|jd�\}}}|jd�\}}}|S)Nz</head>z<title>z</title>)�	partition)�text�header�_�titlerrr�get_html_titlexsrAc@sCeZdZddd�Zejddd��Zdd�ZdS)�
PydocBaseTestNcs=|ptjjt�g�ddd��fdd�}|S)zi
        A version of pkgutil.walk_packages() that will restrict itself to
        a given path.
        Nrcs�|p�||�S)Nr)�path�prefix�onerror)�default_path�
walk_packagesrr�wrapper�sz8PydocBaseTest._restricted_walk_packages.<locals>.wrapper)�osrC�dirnamer )�selfrGrCrHr)rFrGr�_restricted_walk_packages�sz'PydocBaseTest._restricted_walk_packagesccs8tj}|j||�t_z	dVWd|t_XdS)N)�pkgutilrGrL)rKrCrGrrr�restrict_walk_packages�s			z$PydocBaseTest.restrict_walk_packagescCs5tj|d�}t|�}|j|||�|S)Nz	text/html)r�_url_handlerrA�assertEqual)rK�urlZexpected_titler=�resultrrr�call_url_handler�szPydocBaseTest.call_url_handler)rrrrL�
contextlib�contextmanagerrNrSrrrrrB�s
	rBc@seZdZejejjdkd�ejeed�oEej	�d�e
dd����Zejejjdkd�ejeed�o�ej	�d�e
dd����Zd	d
�Z
dd�Zd
d�Zdd�Zdd�Zejejjdkd�dd��Zdd�Zdd�Zejejjdkd�ejeed�oqej	�d�e
dd����Zdd�Zdd�Zejejjdkd�d d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.S)/�PydocDocTestrz)Docstrings are omitted with -O2 and above�gettracez1trace function introduces __locals__ unexpectedlycCswtt�\}}tjt�}tjj|�}t|||ft}||krst	||�|j
d�ndS)Nz%outputs are not equal, see diff above)r.r�inspect�
getabsfile�urllib�parseZquote�expected_html_pattern�expected_html_data_docstringsr;�fail)rKrR�doc_locZmod_fileZmod_urlZ
expected_htmlrrr�
test_html_doc�s
zPydocDocTest.test_html_doccCs`tt�\}}t|fttjt�f}||kr\t||�|jd�ndS)Nz%outputs are not equal, see diff above)r3r�expected_text_pattern�expected_text_data_docstringsrXrYr;r^)rKrRr_�
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rgz<BinaryInteger.zero: 0>)�enumZIntEnumr�
render_doc�assertIn)rKrhrgr+rrr�%test_text_enum_member_with_value_zero�sz2PydocDocTest.test_text_enum_member_with_value_zerocCs,ttj�\}}|j|dd�dS)Nrz'MODULE DOCS incorrectly includes a link)r3�xmlZetreerP)rKrRr_rrr�test_issue8225�szPydocDocTest.test_issue8225cCs1tj}zdt_tj�Wd|t_XdS)N)�sys�stdinr�getpager)rKZprevious_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rsc@seZdZdS)z)PydocDocTest.test_non_str_name.<locals>.BN)rrrrrrr�B�srt)rrirPr)rKrsrtZadocZbdocrrr�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_patternrP)rK�missing_modulerRr6rrr�
test_not_here�s

zPydocDocTest.test_not_herez)Docstrings are omitted with -OO and abovecCs;tddd�}tjjdd�}|j||�dS)Nztest.test_pydoc.nonasciiZPYTHONIOENCODINGrv�backslashreplace)r'rr�encoderj)rKrRZencodedrrr�test_not_ascii�szPydocDocTest.test_not_asciicCs?d}tt|�d�}t|j�}|j||�dS)Nz test.i_am_not_here rv)rwr'rxr!rP)rKryrRr6rrr�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�stripidrP)rKrrrr�test_stripid�s	zPydocDocTest.test_stripidcCs@t}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||
�WdQXWdQXWd|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)rarrpZmaxDiffr�Helperr3r�lstrip�textwrap�dedentr	�help�getvaluer!rbrXrYrP)rKZold_patternZgetpager_oldZgetpager_newZbuf�helperZunusedr_r*Zhelp_headerZexpected_help_patternr,r&rRrcrrr�test_help_output_redirects0			
	

 z&PydocDocTest.test_help_output_redirectc	Csztdddgdd�}t��}tj|�WdQX|j�}|jd|�|jd|�|jd|�dS)	N�NT�abc�def�renameTZ_1�_replace�_asdict)rr
rr�r�rj)rKr��help_io�helptextrrr�!test_namedtuple_public_underscore*sz.PydocDocTest.test_namedtuple_public_underscorecCs�|jtt�x�d
D]�}ttdd|��O}|dkr]tdj|�d|�ntdd|�tdd|�WdQXtjti�}|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�openr9�formatr�synopsisrP)rKr�Zscriptr�rrr�
test_synopsis3s
zPydocDocTest.test_synopsiscCs?tjj�d}tj}tj|�}|j||�dS)Nr)rIrr7�
__cached__rr�rP)rKr6�filenamer�rrr�test_synopsis_sourceless>s	z%PydocDocTest.test_synopsis_sourcelesscCs�tjj���}tjj|d�}tjj|�}t	|d��}|j
d�WdQXtj|�t
j|i�}|j|�t
j|i�}|j|�WdQXdS)Nzfoomod42.pyr�zfoo = 1)�test�support�temp_cwdrIrCr:�	importlib�util�cache_from_sourcer��write�
py_compiler1rr��assertIsNone)rK�test_dir�	init_pathZcached_path�fobjr�Zsynopsis_cachedrrr�"test_synopsis_sourceless_empty_docGs

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�)rPrZsplitdoc)rKZexample_stringrrr�test_splitdoc_with_descriptionSsz+PydocDocTest.test_splitdoc_with_descriptioncCsXtj�}|jtj|j��|jtjtj��|jtjd��dS)NzI am not a method)rZDoc�
assertTrueZ_is_some_methodr^�int�__add__�assertFalse)rKr+rrr�test_is_object_or_methodXsz%PydocDocTest.test_is_object_or_methodc
Cs2tjj��}|jtj|��WdQXdS)N)r�r�r�r�r�	ispackage)rKr�rrr� test_is_package_when_not_packageasz-PydocDocTest.test_is_package_when_not_packagec
Csgtjj��R}tjj|d�}t|d�j�|jt	j
|��tj|�WdQXdS)Nz__init__.pyr�)r�r�r�rIrCr:r��closer�rr��remove)rKr�r�rrr�test_is_package_when_is_packagees
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)rKrrr�method_returning_truesszEPydocDocTest.test_allmethods.<locals>.TestClass.method_returning_trueN)rrrr�rrrr�	TestClassrsr�r�r�	__class__�__subclasshook__)�object�dict�varsr�r�rZ
allmethodsZassertDictEqual)rKr�r6�methodsrrr�test_allmethodsls

zPydocDocTest.test_allmethodsN)rrr�unittest�skipIfrn�flags�optimize�hasattrrWr
r`rdrkrmrqrurzr}r~r�r�r�r�r�r�r�r�r�r�r�rrrrrV�sD

$		rVc@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)rI�mkdirrr�r�rr��invalidate_caches)rKrrr�setUp�szPydocImportTest.setUpc	Cs�d}d
dddj|�dfdj|�dj|�ff}tjjt|�tjd}x}|D]u\}}t|d	��}|jd
j|��WdQXt|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 {}
�
PYTHONPATHrv)r�r�)r�r�)r�r�)r�rIrCr:r�extsepr�r�r'�decode�badimport_patternrP)	rK�modnameZ	testpairsZsourcefnZimportstringZ
expectedinmsg�frRr6rrr�test_badimport�s! zPydocImportTest.test_badimportc)CsGtjjtd�}tj|�tjj|d�tjd}t|d��}|jd�WdQX|jdtg���t	��&}t
��}tjd�WdQXWdQX|j
|j�d�|j
|j�d�t	��&}t
��}tjd�WdQXWdQX|j
|j�j�d�|j
|j�d�WdQXdS)	NZ	syntaxerr�__init__r�r�zinvalid python syntax = $1
rCZxyzzyr)rIrCr:rr�r�r�r�rNr
rr�aproposrPr�r!)rK�pkgdirZ	badsyntaxr�r%r&rrr�test_apropos_with_bad_package�s 
 z-PydocImportTest.test_apropos_with_bad_packagecCs�tjjtd�|_tj|jd�|jtj|j�|jdtg��6t	��&}t
��}tjd�WdQXWdQXWdQX|j
|j�d�|j
|j�d�dS)NZ
unreadablerrCZSOMEKEYr)rIrCr:rZunreadable_dirr�r��rmdirrNr
rrr�rPr�)rKr%r&rrr� test_apropos_with_unreadable_dir�sz0PydocImportTest.test_apropos_with_unreadable_dircCstjjtd�}tj|�|jt|�tjj|d�}t|d��}|jd�WdQXt	j
tj	|�j�}zmtj||t	j
@�|jdtg��$t��}tjd�WdQXWdQX|jd|j��Wdtj||�XdS)NZwalkpkgz__init__.pyr�zfoo = 1rCr)rIrCr:rr�r�rr�r��stat�S_IMODE�st_mode�chmod�S_IEXECrNr
rr�rjr�)rKr�r�r�Zcurrent_moder�rrr�test_apropos_empty_doc�s
"z&PydocImportTest.test_apropos_empty_doccCstjjtd�}tj|�tjj|d�}t|ddd��}|jd�WdQX|jdtg���tt	j�}t	jj
dt�zQ|jtd	��ddl
}WdQX|jd
d�}d}|j||�Wd|t	jdd�<XWdQXdS)
N�test_error_packagez__init__.pyZwtr�rvzraise ValueError("ouch")
rCrZouchzsearch?key=test_error_packagezPydoc: Search Resultsz8<a href="test_error_package.html">test_error_package</a>)rIrCr:rr�r�r�rN�tuplern�insertZassertRaisesRegex�
ValueErrorr�rSrj)rKr�Zinitr�Zsaved_pathsr�r=�foundrrr�test_url_search_package_error�s 
		z-PydocImportTest.test_url_search_package_errorz)causes undesireable side-effects (#20128)c	Cs}d}d}d}|||}t�}tjd|�}|d�|j�j�}t|j��}|j||�dS)Nr��r,�modules)rrr�r�r!�lenr7ZassertGreaterEqual)	rKZnum_header_linesZnum_module_lines_minZnum_footer_linesr6r,r�rRZ	num_linesrrr�test_modules�s	
zPydocImportTest.test_modulesc	Cs]d}t�}tjd|�}t��}|d�WdQX|j�}|j||�dS)Nzpydoc - r,z
modules pydoc)rrr�r
r�rj)rKr6r,r�r�rRrrr�test_modules_search�s	z#PydocImportTest.test_modules_searchz+some buildbots are not cooperating (#20128)c	Cscd}t�}tjd|�}t��}|d�WdQX|j�}|j|j|��dS)Nzgc - r,zmodules garbage)rrr�r
r�r��
startswith)rKr6r,r�r�rRrrr�test_modules_search_builtin	s	z+PydocImportTest.test_modules_search_builtincCsetjtj�}|j|t�|j|jd�|j|jtj�|j|jtj�dS)Nr)rZ
importfiler ZassertIsNotrPr�__spec__)rKZ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�Zedd��Zd	d
�Ze	dd��Z
d
d�Ze	dd��Ze	dd��Z
dS)�TestDescriptionscCs3ddlm}tj|�}|jd|�dS)Nr)�pydocfodderr�)r�r�rrirj)rKr�r+rrr�test_module szTestDescriptions.test_modulecCsuGdd�d�}|�}|jtj|�d�|jtj|�d�dt}|j|tj|��dS)Nc@seZdZdZdS)z&TestDescriptions.test_class.<locals>.CzNew-style classN)rrrrrrrr�C'sr�zclass CzC in module %s object)rPrZdescriberrjri)rKr��cr6rrr�
test_class&s	
zTestDescriptions.test_classcCs�x`dD]X}|jtj|��ytj|�Wqtk
r^|jdj|��YqXqWx:d
D]2}|jtj|��|jttj|�qjWdS)Nrw�
str.translate�builtins.str�builtins.str.translatezfinding the doc of {!r} failed�notbuiltins�strrr�strr.translate�str.trrrranslate�builtins.strrr�builtins.str.trrranslate)zstrr�r�r)rrrrrr)	ZassertIsNotNonerZlocateri�ImportErrorr^r�r��assertRaises)rK�namerrr�test_builtin/s


zTestDescriptions.test_builtincCsGtjtj|��}|jd�}t|�dks?t�|dS)Nr/r)rZplainri�splitr��AssertionError)�or=�linesrrr�_get_summary_line@sz"TestDescriptions._get_summary_linecCs#|j|jtjj�d�dS)Nzwrap(self, text))rPrr��TextWrapper�wrap)rKrrr�test_unbound_python_methodHsz+TestDescriptions.test_unbound_python_methodcCs#|j|jtjj�d�dS)Nzdump(self, obj, /))rPr�_pickle�Pickler�dump)rKrrr�test_unbound_builtin_methodLsz,TestDescriptions.test_unbound_builtin_methodcCs,tj�}|j|j|j�d�dS)Nz2wrap(text) method of textwrap.TextWrapper instance)r�rrPrr)rK�trrr�test_bound_python_methodRsz)TestDescriptions.test_bound_python_methodcCs8t�}tj|�}|j|j|j�d�dS)Nz/dump(obj, /) method of _pickle.Pickler instance)rrrrPrr)rKr�prrr�test_bound_builtin_methodWs	z*TestDescriptions.test_bound_builtin_methodcCs |j|jtj�d�dS)Nz0stat(path, *, dir_fd=None, follow_symlinks=True))rPrrIr�)rKrrr�test_module_level_callable_sz+TestDescriptions.test_module_level_callableN)rrrr�r�r
�staticmethodrrr
rrrrrrrrr�s	r�z!Threading required for this test.c@s"eZdZdZdd�ZdS)�PydocServerTestzTests for pydoc._start_servercCs�dd�}tj|dd�}|jd|jj�tj�}d}xG|jr�tjd�|jrLtj�||krL|j�PqLqLW|j	|j
d�dS)NcSsd||f}|S)Nzthe URL sent was: (%s, %s)r)rQZcontent_typer=rrr�my_url_handlerlsz3PydocServerTest.test_server.<locals>.my_url_handlerZportrZ	localhostreg{�G�z�?)rZ
_start_serverrjZ	docserverZaddress�timeZservingZsleep�stoprP�error)rKrZserverthreadZ	starttimeZtimeoutrrr�test_serveris

zPydocServerTest.test_serverN)rrrrr"rrrrresrc@s.eZdZdZdd�Zdd�ZdS)�PydocUrlHandlerTestzTests for pydoc._url_handlercCs9tj}|jt|dd�|jt|dd�dS)Nrsrrt�foobar)rrOr�	TypeError)rKr�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||�WdQXdS)$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 STRINGSr$�Pydoc: Error - foobar�getfile?key=foobar�!Pydoc: Error - getfile?key=foobarzPydoc: getfile zgetfile?key=)rr')r(r')zindexr')r*r+)zkeywordsr-)zpydocr.)r/r.)r0r1)r2r3)r4r5)zfoobarr6)r7r8)rNrS�stringr )rKZrequestsrQr@rCrrr�test_url_requests�s&	
	

z%PydocUrlHandlerTest.test_url_requestsN)rrrrr&r:rrrrr#sr#c@seZdZdd�ZdS)�
TestHelpercCs)|jttjj�ttj��dS)N)rP�sortedrr�r,�keyword�kwlist)rKrrr�
test_keywords�szTestHelper.test_keywordsN)rrrr?rrrrr;�sr;c@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 aboverWz1trace function introduces __locals__ unexpectedlycCs�Gdd�dt�}Gdd�dd|�}tdd�tD��}t�}tjd|�}||�ttf|dd	�}|j�j	�}||kr�t
||�|jd
�ndS)Ncs"eZdZ�fdd�Z�S)z=PydocWithMetaClasses.test_DynamicClassAttribute.<locals>.Metacs |dkrdSt�j|�S)N�hamZspam)�super�__getattr__)rKr	)r�rrrC�szIPydocWithMetaClasses.test_DynamicClassAttribute.<locals>.Meta.__getattr__)rrrrCrr)r�r�Meta�srDc@s%eZdZejdd��ZdS)z;PydocWithMetaClasses.test_DynamicClassAttribute.<locals>.DAcSsdS)NZeggsr)rKrrrrA�sz?PydocWithMetaClasses.test_DynamicClassAttribute.<locals>.DA.hamN)rrr�types�DynamicClassAttributerArrrr�DA�srG�	metaclasscss%|]}|rd|ndVqdS)z	
 |      rNr)rrrrrr�szBPydocWithMetaClasses.test_DynamicClassAttribute.<locals>.<genexpr>r,rz%outputs are not equal, see diff above)�typer��expected_data_docstringsrrr��!expected_dynamicattribute_patternrr�r!r;r^)rKrDrGrbr,r�rcrRrrr�test_DynamicClassAttribute�s
	

z/PydocWithMetaClasses.test_DynamicClassAttributecCs�Gdd�dt�}Gdd�dd|�}t�}tjd|�}||�tt}|j�j�}||kr�t||�|j	d�ndS)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)NrMrr)rBZ_Meta__getattr)rKr	)r�rrrC�szTPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.Meta.__getattr__)rrrrOrCrr)r�rrD�srDc@seZdZdS)zIPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.ClassN)rrrrrrr�Class�srPrHr,z%outputs are not equal, see diff above)
rIrrr��"expected_virtualattribute_pattern1rr�r!r;r^)rKrDrPr,r�rcrRrrr�%test_virtualClassAttributeWithOneMeta�s	


z:PydocWithMetaClasses.test_virtualClassAttributeWithOneMetacssGdd�dt��Gdd�dt��G��fdd�d���}Gdd�dd	��}Gd
d�d|d	|�}d}}t�}tjd
|�}||�tt}|j�j�}	|	|kr�t||	�d}nt�}tjd
|�}||�t	t}
|j�j�}||
krSt|
|�d}n|s_|ro|j
d�ndS)Ncs.eZdZdd�Z�fdd�Z�S)zIPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1cSsddddgS)Nr�rrrfr)rNrrrrO�szQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1.__dir__cs |dkrdSt�j|�S)Nrfre)rBrC)rKr	)r�rrrC�szUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1.__getattr__)rrrrOrCrr)r�r�Meta1�srScs.eZdZdd�Z�fdd�Z�S)zIPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2cSsddddgS)Nr�rr�twor)rNrrrrO�szQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2.__dir__cs |dkrdSt�j|�S)NrTr)rBrC)rKr	)r�rrrC�szUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2.__getattr__)rrrrOrCrr)r�r�Meta2�srUcs7eZdZ��fdd�Z�fdd�Z�S)zIPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3cs<tttddddg�j|��j|����S)Nr�rr�three)�listr<�setrO)rN)rSrUrrrO�s	zQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3.__dir__cs |dkrdSt�j|�S)NrVr�)rBrC)rKr	)r�rrrC�szUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3.__getattr__)rrrrOrCr)rSrU)r�r�Meta3�srYc@seZdZdS)zJPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Class1N)rrrrrrr�Class1�srZrHc@seZdZdS)zJPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Class2N)rrrrrrr�Class2�sr[Fr,Tz%outputs are not equal, see diff above)rIrrr��"expected_virtualattribute_pattern2rr�r!r;�"expected_virtualattribute_pattern3r^)rKrYrZr[Zfail1Zfail2r,r�Zexpected_text1Zresult1Zexpected_text2Zresult2r)rSrUr�%test_virtualClassAttributeWithTwoMeta�s0"	
	


		


	z:PydocWithMetaClasses.test_virtualClassAttributeWithTwoMetacCs�Gdd�dt�}Gdd�dd|�}t�}tjd|�}||�tt}|j�j�}||kr�t||�|j	d�ndS)Nc@seZdZdd�ZdS)z.PydocWithMetaClasses.test_buggy_dir.<locals>.McSsddddgS)Nr�rZmissing�herer)rNrrrrOsz6PydocWithMetaClasses.test_buggy_dir.<locals>.M.__dir__N)rrrrOrrrr�Msr`c@seZdZdZdS)z.PydocWithMetaClasses.test_buggy_dir.<locals>.Czpresent!N)rrrr_rrrrr�sr�rHr,z%outputs are not equal, see diff above)
rIrrr��!expected_missingattribute_patternrr�r!r;r^)rKr`r�r,r�rcrRrrr�test_buggy_dirs	


z#PydocWithMetaClasses.test_buggy_dirc	Cs?t��}tjd�WdQX|j�}|jd|�dS)Nz	enum.Enumz
class Enum)r
rr�r�rj)rKr�r�rrr�test_resolve_false"sz'PydocWithMetaClasses.test_resolve_falseN)rrrr�r�rnr�r�r�rWrLrRr^rbrcrrrrr@�s"1r@cCs5z&tjjttttttt	�Wdt
�XdS)N)r�r�Zrun_unittestrVr�r�rr#r;r@rrrrr�	test_main+srd�__main__)rr)rrrr)rrrr)NrIrn�builtinsrTr8�importlib.utilr�rXrr�r=rrMr0r�r9Ztest.supportr�rrEr�Zurllib.parserZZ	xml.etreerlr��ior�collectionsrZtest.script_helperrrrrrr	r
rrr
rZ	threadingrrr�ZHAVE_DOCSTRINGSrJr!rar�rbr\r]rxr�rKrQr\r]rar'r.r3r;rAZTestCaserBrVr�r�Z
skipUnlessrr#r;r@rdrrrrr�<module>s�@
	R
y
			
		��G%�