a
    ze                     @   s  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlm Z  d dlm!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) d dlm*Z* G dd dZ+ej,j-r2d	Z.nd
Z.d/ Z0e1dd e.D Z2d/ Z3e1dd e.D Z4d5de j6Z7dZ8d/ Z9d/ Z:d/ Z;d/ Z<d/ Z=dd Z>dd Z?dd Z@dd ZAd d! ZBG d"d# d#ejCZDG d$d% d%ejCZEG d&d' d'eDZFG d(d) d)ejCZGG d*d+ d+ejCZHG d,d- d-eDZIG d.d/ d/ejCZJG d0d1 d1ejCZKG d2d3 d3ejCZLd4d5 ZMeNd6kreO  dS )7    N)StringIO)
namedtuple)assert_python_ok)	TESTFNrmtreereap_childrenreap_threadscaptured_outputcaptured_stdoutcaptured_stderrunlinkrequires_docstrings)	pydoc_modc                   @   s   e Zd ZdS )nonasciiN__name__
__module____qualname__ r   r   %/usr/lib/python3.9/test/test_pydoc.pyr   #   s   r   ).dictionary for instance variables (if defined)2list of weak references to the object (if defined)r   r   ) r   r   r   a  
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'
     |  
     |  __annotations__ = {'NO_MEANING': <class 'str'>}
    
    class C(builtins.object)
     |  Methods defined here:
     |  
     |  get_answer(self)
     |      Return say_no()
     |  
     |  is_it_true(self)
     |      Return self.get_answer()
     |  
     |  say_no(self)
     |  
     |  ----------------------------------------------------------------------
     |  Class methods defined here:
     |  
     |  __class_getitem__(item) from builtins.type
     |  
     |  ----------------------------------------------------------------------
     |  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'
    c_alias = test.pydoc_mod.C[int]
    list_alias1 = typing.List[int]
    list_alias2 = list[int]
    type_union1 = typing.Union[int, str]

VERSION
    1.2.3.4

AUTHOR
    Benjamin Peterson

CREDITS
    Nobody

FILE
    %s
c                 c   s   | ]}|rd | ndV  qdS )z
     |      r   Nr   .0sr   r   r   	<genexpr>   s   r   ak  
<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="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%"><table width="100%%" summary="list"><tr><td width="25%%" valign=top><a href="types.html">types</a><br>
</td><td width="25%%" valign=top><a href="typing.html">typing</a><br>
</td><td width="25%%" valign=top></td><td width="25%%" valign=top></td></tr></table></td></tr></table><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>

<dl><dt><strong>__annotations__</strong> = {'NO_MEANING': &lt;class 'str'&gt;}</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>
Class methods defined here:<br>
<dl><dt><a name="C-__class_getitem__"><strong>__class_getitem__</strong></a>(item)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></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'<br>
<strong>c_alias</strong> = test.pydoc_mod.C[int]<br>
<strong>list_alias1</strong> = typing.List[int]<br>
<strong>list_alias2</strong> = list[int]<br>
<strong>type_union1</strong> = typing.Union[int, str]</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>
c                 c   s   | ]}| d dV  qdS ) z&nbsp;N)replacer   r   r   r   r     s   z~No Python documentation found for %r.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.
z7problem in %s - ModuleNotFoundError: 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!'
c                 O   s2   || f }t dtjg|R i |\}}}| S )Nz-B)r   pydoc__file__strip)module_nameargsenvrcouterrr   r   r   	run_pydocl  s    
 r)   c                 C   s<   t  }|| }|tpd}|r0d| d }| |fS )Nr   z<br><a href="z">Module Docs</a>)r    HTMLDoc	docmodule	getdoclocr   r"   )moduledocoutputlocr   r   r   get_pydoc_htmlv  s    
r1   c                 C   s:   t jj}t jj}|||t}t }|j| |d}|S )N)basedir)ospathabspathdirnamer!   r    TextDocr,   )r-   r5   r6   r2   r.   r0   r   r   r   get_pydoc_link  s    r8   c                 C   sR   t  }|tpd}|r&d| d }|| }td}|d|}| |fS )Nr   z
MODULE DOCS
    r   .)	r    r7   r,   r   r+   recompilesubr"   )r-   r.   r0   r/   Zpattr   r   r   get_pydoc_text  s    

r=   c                 C   s4   |  d\}}}| d\}}}| d\}}}|S )Nz</head>z<title>z</title>)	partition)textheader_titler   r   r   get_html_title  s    rC   c                   @   s.   e Zd ZdddZejd	ddZdd ZdS )
PydocBaseTestNc                    s&   |pt jtg d fdd	}|S )Nr   c                    s   | p ||S Nr   )r4   prefixonerrorZdefault_pathwalk_packagesr   r   wrapper  s    z8PydocBaseTest._restricted_walk_packages.<locals>.wrapper)Nr   N)r3   r4   r6   r!   )selfrI   r4   rJ   r   rH   r   _restricted_walk_packages  s    z'PydocBaseTest._restricted_walk_packagesc                 c   s2   t j}| ||t _zd V  W |t _n|t _0 d S rE   )pkgutilrI   rL   )rK   r4   rI   r   r   r   restrict_walk_packages  s    z$PydocBaseTest.restrict_walk_packagesc                 C   s&   t |d}t|}| ||| |S )Nz	text/html)r    _url_handlerrC   assertEqual)rK   urlZexpected_titler?   resultr   r   r   call_url_handler  s    zPydocBaseTest.call_url_handler)N)N)r   r   r   rL   
contextlibcontextmanagerrN   rS   r   r   r   r   rD     s   

	rD   c                   @   s  e Zd ZdZeejjdkdee	edo2e
 dedd Zeejjdkdee	edole
 dedd	 Zd
d Zdd Zdd Zdd Zdd Zdd Zeejjdkddd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zeejjdkdee	edo,e
 ded'd( Zd)d* Zd+d, Zd-d. Zeejjdkdd/d0 Z d1d2 Z!d3d4 Z"d5d6 Z#d7d8 Z$d9d: Z%d;d< Z&dS )=PydocDocTestN   )Docstrings are omitted with -O2 and abovegettrace1trace function introduces __locals__ unexpectedlyc                 C   sD   t t\}}tt}tj|}t|||ft  }| 	|| d S rE   )
r1   r   inspect
getabsfileurllibparsequoteexpected_html_patternexpected_html_data_docstringsrP   )rK   rR   doc_locZmod_fileZmod_urlZexpected_htmlr   r   r   test_html_doc  s    
zPydocDocTest.test_html_docc                 C   s6   t t\}}t|ft ttf  }| || d S rE   )r=   r   expected_text_patternexpected_text_data_docstringsr[   r\   rP   )rK   rR   rb   expected_textr   r   r   test_text_doc  s    
zPydocDocTest.test_text_docc                 C   s4   dd l }G dd d|j}t|}| d| d S )Nr   c                   @   s   e Zd ZdZdZdS )zIPydocDocTest.test_text_enum_member_with_value_zero.<locals>.BinaryIntegerr      N)r   r   r   Zzerooner   r   r   r   BinaryInteger  s   rj   z<BinaryInteger.zero: 0>)enumIntEnumr    
render_docassertIn)rK   rk   rj   r.   r   r   r   %test_text_enum_member_with_value_zero  s    
z2PydocDocTest.test_text_enum_member_with_value_zeroc                 C   s   t tjj}| d| d S )Nzxml.etree.elementtree)r8   xmletreeZElementTreern   )rK   Zdoc_linkr   r   r   ,test_mixed_case_module_names_are_lower_cased  s    z9PydocDocTest.test_mixed_case_module_names_are_lower_casedc                 C   s    t tj\}}| |dd d S )Nr   z'MODULE DOCS incorrectly includes a link)r=   rp   rq   rP   )rK   rR   rb   r   r   r   test_issue8225  s    zPydocDocTest.test_issue8225c                 C   s,   t j}zd t _t  W |t _n|t _0 d S rE   )sysstdinr    getpager)rK   Zprevious_stdinr   r   r   test_getpager_with_stdin_none  s
    
z*PydocDocTest.test_getpager_with_stdin_nonec                 C   sL   G dd d}G dd d}t | }t | }| |dd| d S )Nc                   @   s   e Zd ZdZ dS )z)PydocDocTest.test_non_str_name.<locals>.A*   Nr   r   r   r   r   A  s   ry   c                   @   s   e Zd ZdS )z)PydocDocTest.test_non_str_name.<locals>.BNr   r   r   r   r   B  s   rz   )r    rm   rP   r   )rK   ry   rz   ZadocZbdocr   r   r   test_non_str_name  s
    zPydocDocTest.test_non_str_namec                 C   s,   d}t t|d}t| }| ||d d S )Ntest.i_am_not_hereasciiz&documentation for missing module found)strr)   missing_patternrP   rK   Zmissing_modulerR   expectedr   r   r   test_not_here  s    zPydocDocTest.test_not_herez)Docstrings are omitted with -OO and abovec                 C   s*   t ddd}tjdd}| || d S )Nztest.test_pydoc.nonasciir}   )ZPYTHONIOENCODINGbackslashreplace)r)   r   __doc__encodern   )rK   rR   encodedr   r   r   test_not_ascii	  s    zPydocDocTest.test_not_asciic                 C   s.   d}t t|d}t|  }| || d S )Nz test.i_am_not_here r}   )r~   r)   r   r"   rP   r   r   r   r   test_input_strip  s    zPydocDocTest.test_input_stripc                 C   sJ   t j}| |dd | |dd | |dd | |dd d S )Nz<function stripid at 0x88dcee4>z<function stripid>z <function stripid at 0x01F65390>Z42z<type 'exceptions.Exception'>)r    stripidrP   )rK   r   r   r   r   test_stripid  s    


zPydocDocTest.test_stripidc                 C   s&   t  }|t}d}| || d S )Nz |  Built-in subclasses:
 |      async_generator
 |      BaseException
 |      builtin_function_or_method
 |      bytearray
 |      ... and \d+ other subclasses)r    r7   docclassobjectZassertRegexrK   r.   r?   Zsnipr   r   r   )test_builtin_with_more_than_four_children#  s    
z6PydocDocTest.test_builtin_with_more_than_four_childrenc                 C   s&   t  }|t}d}| || d S )Nzc |  Built-in subclasses:
 |      FloatingPointError
 |      OverflowError
 |      ZeroDivisionError)r    r7   r   ArithmeticErrorrn   r   r   r   r   test_builtin_with_childB  s    
z$PydocDocTest.test_builtin_with_childc                 C   s2   t  }|t}d}| || | d| d S )Nz^ |  Built-in subclasses:
 |      ArithmeticError
 |      AssertionError
 |      AttributeErrorZeroDivisionError)r    r7   r   	Exceptionrn   assertNotInr   r   r   r   test_builtin_with_grandchild]  s
    
z)PydocDocTest.test_builtin_with_grandchildc                 C   s"   t  }|t}| d| d S NzBuilt-in subclasses)r    r7   r   r   r   rK   r.   r?   r   r   r   test_builtin_no_child}  s    
z"PydocDocTest.test_builtin_no_childc                 C   s"   t  }|t}| d| d S r   )r    r7   r   typer   r   r   r   r   test_builtin_on_metaclasses  s    
z(PydocDocTest.test_builtin_on_metaclassesc              	   C   s  t }tj}dd }d | _t }tj|d}tt\}}d}d }	t	
|	}	|	t  }
|t_ztd}tdl}|| |  }|
|ft ttf  }| d|  | d|  | || W d    n1 s0    Y  W d    n1 s0    Y  W |t_n|t_0 d S )	Nc                   S   s   dd S )Nc                 S   s   | S rE   r   )xr   r   r   <lambda>      zJPydocDocTest.test_help_output_redirect.<locals>.<lambda>.<locals>.<lambda>r   r   r   r   r   r     r   z8PydocDocTest.test_help_output_redirect.<locals>.<lambda>r/   ztest.pydoc_modz9
        Help on module test.pydoc_mod in test:

        stdoutstderrr   )rd   r    rv   maxDiffr   Helperr=   r   lstriptextwrapdedentr	   helpgetvaluer"   re   r[   r\   rP   )rK   Zold_patternZgetpager_oldZgetpager_newbufhelperZunusedrb   r-   Zhelp_headerZexpected_help_patternr/   r(   rR   rf   r   r   r   test_help_output_redirect  s<    



Jz&PydocDocTest.test_help_output_redirectc                 C   sz   t dddg}t }t| W d    n1 s40    Y  | }| d| | d| | d| | d| d S )NPersonnickname	firstnamezAlias for field number 0zAlias for field number 1r   r
   r    r   r   rn   )rK   r   help_iohelptextr   r   r   test_namedtuple_fields  s    (z#PydocDocTest.test_namedtuple_fieldsc                 C   sr   t dddgdd}t }t| W d    n1 s80    Y  | }| d| | d| | d| d S )	NNTabcdefT)renameZ_1_replace_asdictr   )rK   r   r   r   r   r   r   !test_namedtuple_public_underscore  s    (z.PydocDocTest.test_namedtuple_public_underscorec              	   C   s   |  tt dD ]|}ttd|dB}|dkr>td||d td|d td|d W d    n1 sj0    Y  tti }| |d	 qd S )
N)z
ISO-8859-1UTF-8wencodingr   z#coding: {})fileu   """line 1: hézline 2: hi"""u   line 1: hé)	
addCleanupr   r   openprintformatr    synopsisrP   )rK   r   Zscriptr   r   r   r   test_synopsis  s    *zPydocDocTest.test_synopsisc                 C   s.   t j d }t j}t|}| || d S )Nr   )r3   r   
splitlines
__cached__r    r   rP   )rK   r   filenamer   r   r   r   test_synopsis_sourceless  s    
z%PydocDocTest.test_synopsis_sourcelessc              	   C   s   t j }tj|d}tj|}t	|d}|
d W d    n1 sP0    Y  t| t|i }| | t|i }| | W d    n1 s0    Y  d S )Nzfoomod42.pyr   foo = 1)testsupporttemp_cwdr3   r4   join	importlibutilcache_from_sourcer   write
py_compiler;   r    r   assertIsNone)rK   test_dir	init_pathZcached_pathfobjr   Zsynopsis_cachedr   r   r   "test_synopsis_sourceless_empty_doc  s    (

z/PydocDocTest.test_synopsis_sourceless_empty_docc                 C   s   d}|  t|d d S )Nz#I Am A Doc


Here is my description)z
I Am A Docz
Here is my description)rP   r    Zsplitdoc)rK   Zexample_stringr   r   r   test_splitdoc_with_description  s    z+PydocDocTest.test_splitdoc_with_descriptionc                 C   s>   t j  }| t| W d    n1 s00    Y  d S rE   )r   r   r   ZassertFalser    	ispackage)rK   r   r   r   r    test_is_package_when_not_package  s    z-PydocDocTest.test_is_package_when_not_packagec                 C   sd   t j F}tj|d}t|d  | t	
| t| W d    n1 sV0    Y  d S )N__init__.pyr   )r   r   r   r3   r4   r   r   close
assertTruer    r   remove)rK   r   r   r   r   r   test_is_package_when_is_package  s
    z,PydocDocTest.test_is_package_when_is_packagec                 C   s`   G dd dt }ttt }|j|d< |d= |d= |j|d< |j|d< t|}| || d S )Nc                   @   s   e Zd Zdd ZdS )z/PydocDocTest.test_allmethods.<locals>.TestClassc                 S   s   dS )NTr   rK   r   r   r   method_returning_true  s    zEPydocDocTest.test_allmethods.<locals>.TestClass.method_returning_trueN)r   r   r   r   r   r   r   r   	TestClass  s   r   r   r   	__class____subclasshook____init_subclass__)	r   dictvarsr   r   r   r    Z
allmethodsZassertDictEqual)rK   r   r   methodsr   r   r   test_allmethods  s    



zPydocDocTest.test_allmethodsc                    sp   G dd d G  fddd }t |}tdd|}| |dt  t j|t  d}| |d	t  d S )
Nc                   @   s"   e Zd ZdddZeZdd ZdS )z+PydocDocTest.test_method_aliases.<locals>.ANc                 S   s   d S rE   r   )rK   Z	aboveThisr   r   r   tkraise*  s    z3PydocDocTest.test_method_aliases.<locals>.A.tkraisec                 S   s   d S rE   r   r   r   r   r   a_size-  s    z2PydocDocTest.test_method_aliases.<locals>.A.a_size)N)r   r   r   r   Zliftr   r   r   r   r   ry   )  s   
ry   c                       s    e Zd ZdddZeZ jZdS )z+PydocDocTest.test_method_aliases.<locals>.BNc                 [   s   d S rE   r   )rK   ZtagOrIdZcnfkwr   r   r   itemconfigure0  s    z9PydocDocTest.test_method_aliases.<locals>.B.itemconfigure)N)r   r   r   r   Z
itemconfigr   Zb_sizer   ry   r   r   rz   /  s   
rz   r9   r   a  Python Library Documentation: class B in module %s

class B(A)
 |  Method resolution order:
 |      B
 |      A
 |      builtins.object
 |  
 |  Methods defined here:
 |  
 |  b_size = a_size(self)
 |  
 |  itemconfig = itemconfigure(self, tagOrId, cnf=None, **kw)
 |  
 |  itemconfigure(self, tagOrId, cnf=None, **kw)
 |      Configure resources of an item TAGORID.
 |  
 |  ----------------------------------------------------------------------
 |  Methods inherited from A:
 |  
 |  a_size(self)
 |      Return size
 |  
 |  lift = tkraise(self, aboveThis=None)
 |  
 |  tkraise(self, aboveThis=None)
 |      Raise this widget in the stacking order.
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from A:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
Zrenderera  Python Library Documentation: class B in module %s

<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)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%"><dl><dt>Method resolution order:</dt>
<dd>B</dd>
<dd>A</dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="B-b_size"><strong>b_size</strong></a> = <a href="#B-a_size">a_size</a>(self)</dt></dl>

<dl><dt><a name="B-itemconfig"><strong>itemconfig</strong></a> = <a href="#B-itemconfigure">itemconfigure</a>(self, tagOrId, cnf=None, **kw)</dt></dl>

<dl><dt><a name="B-itemconfigure"><strong>itemconfigure</strong></a>(self, tagOrId, cnf=None, **kw)</dt><dd><tt>Configure&nbsp;resources&nbsp;of&nbsp;an&nbsp;item&nbsp;TAGORID.</tt></dd></dl>

<hr>
Methods inherited from A:<br>
<dl><dt><a name="B-a_size"><strong>a_size</strong></a>(self)</dt><dd><tt>Return&nbsp;size</tt></dd></dl>

<dl><dt><a name="B-lift"><strong>lift</strong></a> = <a href="#B-tkraise">tkraise</a>(self, aboveThis=None)</dt></dl>

<dl><dt><a name="B-tkraise"><strong>tkraise</strong></a>(self, aboveThis=None)</dt><dd><tt>Raise&nbsp;this&nbsp;widget&nbsp;in&nbsp;the&nbsp;stacking&nbsp;order.</tt></dd></dl>

<hr>
Data descriptors inherited from A:<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>)r    rm   r:   r<   rP   r   r*   )rK   rz   r.   r   r   r   test_method_aliases(  s    
%'(z PydocDocTest.test_method_aliases)'r   r   r   r   unittestskipIfrt   flagsoptimizehasattrrY   r   rc   rg   ro   rr   rs   rw   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rV     sn   	

 #
	
rV   c                   @   sz   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Ze	
ddd Ze	
ddd Ze	
ddd Zdd ZdS )PydocImportTestc                 C   s$   t t| _| tt t  d S rE   )r3   mkdirr   r   r   r   r   invalidate_cachesr   r   r   r   setUp  s    zPydocImportTest.setUpc           	   	   C   s   d}dddd |dfd |d |ff}tjt|tj d }|D ]l\}}t|d	 }|d
 | W d    n1 s0    Y  t|td	d}t
||f }| || qHd S )NZtestmod_xyzzy)i_am_not_herer   )test.i_am_not_here_eitherr   )ztest.i_am_not_here.neither_am_ir|   zi_am_not_here.{}r   ztest.{}pyr   z
import {}
)Z
PYTHONPATHr}   )r   r3   r4   r   r   extsepr   r   r)   decodebadimport_patternrP   )	rK   modnameZ	testpairsZsourcefnZimportstringZexpectedinmsgfrR   r   r   r   r   test_badimport  s    .zPydocImportTest.test_badimportc              
   C   s  t jtd}t | t j|dt j d }t|d}|d W d    n1 sZ0    Y  | jtgd t	 @}t
 }td W d    n1 s0    Y  W d    n1 s0    Y  | | d | | d t	 B}t
 }td W d    n1 s0    Y  W d    n1 s<0    Y  | |  d | | d W d    n1 s0    Y  d S )	NZ	syntaxerr__init__r   r   zinvalid python syntax = $1
r4   Zxyzzyr   )r3   r4   r   r   r   r   r   r   rN   r
   r   r    aproposrP   r   r"   )rK   pkgdirZ	badsyntaxr   r'   r(   r   r   r   test_apropos_with_bad_package  s     
(FJz-PydocImportTest.test_apropos_with_bad_packagec              
   C   s   t jtd| _t | jd | t j| j | jtgdf t	 @}t
 }td W d    n1 sl0    Y  W d    n1 s0    Y  W d    n1 s0    Y  | | d | | d d S )NZ
unreadabler   r  ZSOMEKEYr   )r3   r4   r   r   Zunreadable_dirr   r   rmdirrN   r
   r   r    r  rP   r   )rK   r'   r(   r   r   r    test_apropos_with_unreadable_dir  s    dz0PydocImportTest.test_apropos_with_unreadable_dirc              
   C   s  t jtd}t | | t| t j|d}t|d}|d W d    n1 s\0    Y  t	
t 	|j}zt ||t	j @  | jtgd@ t }td W d    n1 s0    Y  W d    n1 s0    Y  | d|  W t || nt || 0 d S )NZwalkpkgr   r   r   r  r   )r3   r4   r   r   r   r   r   r   r   statS_IMODEst_modechmodS_IEXECrN   r
   r    r  rn   r   )rK   r  r   r   Zcurrent_moder   r   r   r   test_apropos_empty_doc  s    
(Fz&PydocImportTest.test_apropos_empty_docc                 C   s  t jtd}t | t j|d}t|ddd}|d W d    n1 sT0    Y  | jtgd tt	j}t	j
dt zb| td	 dd l}W d    n1 s0    Y  | d
d}d}| || W |t	jd d < n|t	jd d < 0 W d    n1 s0    Y  d S )Ntest_error_packager   Zwtr}   r   zraise ValueError("ouch")
r  r   Zouchzsearch?key=test_error_packagePydoc: Search Resultsz8<a href="test_error_package.html">test_error_package</a>)r3   r4   r   r   r   r   r   rN   tuplert   insertZassertRaisesRegex
ValueErrorr  rS   rn   )rK   r  initr   Zsaved_pathsr  r?   foundr   r   r   test_url_search_package_error  s"    
(
&z-PydocImportTest.test_url_search_package_errorz(causes undesirable side-effects (#20128)c           	      C   sZ   d}d}d}|| | }t  }tj|d}|d |  }t| }| || d S )NrW         r   modules)r   r    r   r   r"   lenr   ZassertGreaterEqual)	rK   Znum_header_linesZnum_module_lines_minZnum_footer_linesr   r/   r   rR   Z	num_linesr   r   r   test_modules  s    zPydocImportTest.test_modulesc                 C   s\   d}t  }tj|d}t }|d W d    n1 s:0    Y  | }| || d S )Nzpydoc - r   zmodules pydoc)r   r    r   r
   r   rn   rK   r   r/   r   r   rR   r   r   r   test_modules_search  s    &z#PydocImportTest.test_modules_searchz+some buildbots are not cooperating (#20128)c                 C   s`   d}t  }tj|d}t }|d W d    n1 s:0    Y  | }| || d S )Nzgc - r   zmodules garbage)r   r    r   r
   r   r   
startswithr  r   r   r   test_modules_search_builtin  s    &z+PydocImportTest.test_modules_search_builtinc                 C   sJ   t t j}| |t  | |jd | |jt j | |jt j d S )Nr    )r    Z
importfiler!   ZassertIsNotrP   r   __spec__)rK   Zloaded_pydocr   r   r   test_importfile  s
    zPydocImportTest.test_importfileN)r   r   r   r   r   r  r  r  r  r   skipr  r  r  r   r   r   r   r   r     s   


r   c                   @   s4  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	e
dd Ze
dd Zdd Zedd Zdd Zdd Zedd Zedd Zedd  Zed!d" Zed#d$ Zed%d& Zed'd( Zed)d* Zed+d, Zed-d. Zed/d0 Zed1d2 Zed3d4 Zd5d6 Zd7d8 Z d9d: Z!d;S )<TestDescriptionsc                 C   s&   ddl m} t|}| d| d S )Nr   )pydocfodderr#  )r   r#  r    rm   rn   )rK   r#  r.   r   r   r   test_module&  s    
zTestDescriptions.test_modulec                 C   sV   G dd d}| }|  t|d |  t|d dt }| |t| d S )Nc                   @   s   e Zd ZdS )z&TestDescriptions.test_class.<locals>.CNr   r   r   r   r   C-  r   r%  zclass CzC in module %s object)rP   r    describer   rn   rm   )rK   r%  cr   r   r   r   
test_class,  s    zTestDescriptions.test_classc                 C   s   |  ttjt d tjtjt tjd}| d| | d| | t	j
  d | |  tt	t d tjt	t tjd}| d| | d| | t	j
  d | d S )N_GenericAliasr   z_GenericAlias in module typingz
class list(object)r   GenericAliaszGenericAlias in module builtins)rP   r    r&  typingListintrm   	plaintextrn   listr   r"   r   rK   r.   r   r   r   test_generic_alias5  s    z#TestDescriptions.test_generic_aliasc                 C   sv   |  ttjttf d tjtjttf tjd}| 	d| | 	d| tjj
rr| 	tjj
  d | d S )N_UnionGenericAliasr   z#_UnionGenericAlias in module typingz
typing.Unionr   )rP   r    r&  r+  Unionr-  r~   rm   r.  rn   r   r"   r   r0  r   r   r   test_union_typeB  s    z TestDescriptions.test_union_typec                 C   st   |  ttjd tjtjtjd}| d| tjjrd| d| | tjj	 
 d | n| d| d S )N_SpecialFormr   z_SpecialForm in module typingz
typing.Anyr   z
class _SpecialForm(_Final))rP   r    r&  r+  Anyrm   r.  rn   r   r"   r   r0  r   r   r   test_special_formJ  s    z"TestDescriptions.test_special_formc                 C   s   t jt j tt jt jtt jf  ddd}t d}G dd dt j| t jtt	f }| 
t| d d | 
t| d	 d
 d S )N)datar   returnc                 S   s   d S rE   r   )r8  r   r   r   r   fooU  s    z/TestDescriptions.test_typing_pydoc.<locals>.fooTc                   @   s   e Zd ZdS )z-TestDescriptions.test_typing_pydoc.<locals>.CNr   r   r   r   r   r%  Y  r   r%  z?ffoooo(data: List[Any], x: int) -> Iterator[Tuple[int, Any]]rW   z2class CC(collections.abc.Mapping, typing.Generic))r+  r,  r6  r-  IteratorTupleTypeVarGenericMappingr~   rP   r    rm   r   )rK   r:  r;  r%  r   r   r   test_typing_pydocT  s    

"z"TestDescriptions.test_typing_pydocc              	   C   sz   dD ]F}|  t| zt| W q tyH   | d| Y q0 qdD ]$}| t| | ttj| qPd S )N)r~   zstr.translatezbuiltins.strzbuiltins.str.translatezfinding the doc of {!r} failed)ZnotbuiltinsZstrrrzstrr.translatezstr.trrrranslatezbuiltins.strrrzbuiltins.str.trrranslate)	ZassertIsNotNoner    Zlocaterm   ImportErrorZfailr   r   assertRaisesrK   namer   r   r   test_builtin`  s    zTestDescriptions.test_builtinc                 C   s"   t t | }|d}|d S Nr   rW   )r    plainrm   splitor?   linesr   r   r   _get_summary_lineq  s    
z"TestDescriptions._get_summary_linec                 C   s,   t t | }|d}d|dd  S rH  )r    rI  rm   rJ  r   rK  r   r   r   _get_summary_linesx  s    
z#TestDescriptions._get_summary_linesc                 C   s   |  | tjjd d S )Nzwrap(self, text))rP   rN  r   TextWrapperwrapr   r   r   r   test_unbound_python_method  s    z+TestDescriptions.test_unbound_python_methodc                 C   s   |  | tjjd d S )Nzdump(self, obj, /))rP   rN  _picklePicklerdumpr   r   r   r   test_unbound_builtin_method  s    z,TestDescriptions.test_unbound_builtin_methodc                 C   s    t  }| | |jd d S )Nz2wrap(text) method of textwrap.TextWrapper instance)r   rP  rP   rN  rQ  )rK   tr   r   r   test_bound_python_method  s    z)TestDescriptions.test_bound_python_methodc                 C   s|   t dg d}t|}| |d|d | |d|d G dd d}G dd	 d	}t| t| d S )
Nr   )r   r   agegroupr   r   rY  c                   @   s   e Zd ZdZdS )zMTestDescriptions.test_field_order_for_named_tuples.<locals>.NonIterableFieldsNr   r   r   _fieldsr   r   r   r   NonIterableFields  s   r\  c                   @   s   e Zd Zg gZdS )zMTestDescriptions.test_field_order_for_named_tuples.<locals>.NonHashableFieldsNrZ  r   r   r   r   NonHashableFields  s   r]  )r   r    rm   Z
assertLessindex)rK   r   r   r\  r]  r   r   r   !test_field_order_for_named_tuples  s    

z2TestDescriptions.test_field_order_for_named_tuplesc                 C   s(   t  }t|}| | |jd d S )Nz/dump(obj, /) method of _pickle.Pickler instance)r   rS  rT  rP   rN  rU  )rK   r   pr   r   r   test_bound_builtin_method  s
    
z*TestDescriptions.test_bound_builtin_methodc                 C   s   |  | tjd d S )Nz0stat(path, *, dir_fd=None, follow_symlinks=True))rP   rN  r3   r  r   r   r   r   test_module_level_callable  s    z+TestDescriptions.test_module_level_callablec                 C   sV   G dd d}|  | |jd d |  | |jd | dtt| d S )Nc                   @   s   e Zd Zedd ZdS )z-TestDescriptions.test_staticmethod.<locals>.Xc                 S   s   d S rE   r   r   yr   r   r   sm  s    z0TestDescriptions.test_staticmethod.<locals>.X.smN)r   r   r   staticmethodre  r   r   r   r   X  s   rg  re  z<staticmethod object>zsm(x, y)
    A static method
zL
 |  Static methods defined here:
 |  
 |  sm(x, y)
 |      A static method
)rP   rO  __dict__re  rn   r    rI  rm   rK   rg  r   r   r   test_staticmethod  s    z"TestDescriptions.test_staticmethodc                 C   sV   G dd d}|  | |jd d |  | |jd | dtt| d S )Nc                   @   s   e Zd Zedd ZdS )z,TestDescriptions.test_classmethod.<locals>.Xc                 S   s   d S rE   r   )clsr   r   r   r   cm  s    z/TestDescriptions.test_classmethod.<locals>.X.cmN)r   r   r   classmethodrl  r   r   r   r   rg    s   rg  rl  z<classmethod object>z:cm(x) method of builtins.type instance
    A class method
zZ
 |  Class methods defined here:
 |  
 |  cm(x) from builtins.type
 |      A class method
)rP   rO  rh  rl  rn   r    rI  rm   ri  r   r   r   test_classmethod  s    z!TestDescriptions.test_classmethodc                 C   sT   |  | tjd |  | tjd |  | tjd |  | tj	d d S )N	numeratorrealr$   obj)
rP   rN  r-  ro  floatrp  r   r$   
memoryviewrq  r   r   r   r   test_getset_descriptor  s    z'TestDescriptions.test_getset_descriptorc                 C   sh   |  | tjd |  | tjd |  | tjd |  | tjd |  | t	j
d d S )Nrp  startfgetvalue)rP   rN  complexrp  rangeru  slicepropertyrv  StopIterationrw  r   r   r   r   test_member_descriptor  s
    z'TestDescriptions.test_member_descriptorc                 C   s&   G dd d}|  | |jd d S )Nc                   @   s   e Zd ZdZdS )z4TestDescriptions.test_slot_descriptor.<locals>.Pointrc  N)r   r   r   	__slots__r   r   r   r   Point  s   r  r   )rP   rN  r   )rK   r  r   r   r   test_slot_descriptor  s    z%TestDescriptions.test_slot_descriptorc                 C   s*   G dd d}|  | |jd d d S )Nc                   @   s   e Zd ZdS )z6TestDescriptions.test_dict_attr_descriptor.<locals>.NSNr   r   r   r   r   NS  s   r  rh  )rP   rN  rh  )rK   r  r   r   r   test_dict_attr_descriptor  s    z*TestDescriptions.test_dict_attr_descriptorc                 C   sl   |  | ttjjd |  | ttjjd |  | ttjj	d |  | ttj
jd d S )Nwidthdebugmajormax)rP   rN  r   rt   	hash_infor  r   r  version_infor  
float_infor  r   r   r   r    test_structseq_member_descriptor  s    z1TestDescriptions.test_structseq_member_descriptorc                 C   s"   t dd}| | |jd d S )NBox)r  Zheightz    Alias for field number 0
)r   rP   rO  r  )rK   r  r   r   r    test_namedtuple_field_descriptor  s    
z1TestDescriptions.test_namedtuple_field_descriptorc                 C   s>   G dd d}|  | |jd | dtt| d S )Nc                   @   s   e Zd Zedd ZdS )z,TestDescriptions.test_property.<locals>.Rectc                 S   s   | j | j S rE   )r   hr   r   r   r   area  s    z1TestDescriptions.test_property.<locals>.Rect.areaN)r   r   r   r{  r  r   r   r   r   Rect  s   r  z    Area of the rect
z#
 |  area
 |      Area of the rect
)rP   rO  r  rn   r    rI  rm   )rK   r  r   r   r   test_property  s
    zTestDescriptions.test_propertyc                    sp   G dd d G  fddd}|  | |jd d|j_|  | |jd d|j_|  | |jd	 d S )
Nc                   @   s   e Zd Zdd ZdS )z?TestDescriptions.test_custom_non_data_descriptor.<locals>.Descrc                 S   s   |d u r| S dS Nrx   r   rK   rq  rk  r   r   r   __get__  s    zGTestDescriptions.test_custom_non_data_descriptor.<locals>.Descr.__get__N)r   r   r   r  r   r   r   r   Descr  s   r  c                       s   e Zd Z  ZdS )z;TestDescriptions.test_custom_non_data_descriptor.<locals>.XNr   r   r   attrr   r  r   r   rg    s   rg  zX<test.test_pydoc.TestDescriptions.test_custom_non_data_descriptor.<locals>.Descr object>Custom descriptorzo<test.test_pydoc.TestDescriptions.test_custom_non_data_descriptor.<locals>.Descr object>
    Custom descriptor
r:  zfoo(...)
    Custom descriptor
rP   rO  r  r   r   ri  r   r  r   test_custom_non_data_descriptor  s    z0TestDescriptions.test_custom_non_data_descriptorc                    sp   G dd d G  fddd}|  | |jd d|j_|  | |jd d|j_|  | |jd	 d S )
Nc                   @   s   e Zd Zdd Zdd ZdS )z;TestDescriptions.test_custom_data_descriptor.<locals>.Descrc                 S   s   |d u r| S dS r  r   r  r   r   r   r  0  s    zCTestDescriptions.test_custom_data_descriptor.<locals>.Descr.__get__c                 S   s   dd  d S )Nrh   r   r   r  r   r   r   __set__4  s    zCTestDescriptions.test_custom_data_descriptor.<locals>.Descr.__set__N)r   r   r   r  r  r   r   r   r   r  /  s   r  c                       s   e Zd Z  ZdS )z7TestDescriptions.test_custom_data_descriptor.<locals>.XNr  r   r  r   r   rg  6  s   rg  r   r  z    Custom descriptor
r:  zfoo
    Custom descriptor
r  ri  r   r  r   test_custom_data_descriptor-  s    z,TestDescriptions.test_custom_data_descriptorc                 C   sJ   t ddd}ttj|}| d| t |}| d| d S )N)r9  c                    s   dS Nrh   r   )Zignr   r   r   coro_functionG  s    z=TestDescriptions.test_async_annotation.<locals>.coro_functionzasync coro_functionz4async <a name="-coro_function"><strong>coro_function)r-  r    rI  r.  documentrn   r*   )rK   r  r?   htmlr   r   r   test_async_annotationF  s    z&TestDescriptions.test_async_annotationc                 C   sD   dd }t t j|}| d| t  |}| d| d S )Nc                   S  s
   dV  d S r  r   r   r   r   r   an_async_generatorS  s    zLTestDescriptions.test_async_generator_annotation.<locals>.an_async_generatorzasync an_async_generatorz>async <a name="-an_async_generator"><strong>an_async_generator)r    rI  r.  r  rn   r*   )rK   r  r?   r  r   r   r   test_async_generator_annotationR  s    z0TestDescriptions.test_async_generator_annotationc                 C   s&   dd }t  |}| d| d S )Nc                   S   s   d S rE   r   r   r   r   r   a_fn_with_https_link_  s    zHTestDescriptions.test_html_for_https_links.<locals>.a_fn_with_https_linkz3<a href="https://localhost/">https://localhost/</a>)r    r*   r  rn   )rK   r  r  r   r   r   test_html_for_https_links^  s    z*TestDescriptions.test_html_for_https_linksN)"r   r   r   r$  r(  r1  r4  r7  rB  rG  rf  rN  rO  rR  r   rV  rX  r_  ra  rb  rj  rn  rt  r}  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r"  $  sZ   	









	







r"  c                   @   s   e Zd Zdd ZdS )PydocServerTestc                 C   s|   dd }t j|ddd}| d|jj t }tjj	}|j
rjtd |j
r8t | |kr8|  qjq8| |jd  d S )Nc                 S   s   d| |f }|S )Nzthe URL sent was: (%s, %s)r   )rQ   Zcontent_typer?   r   r   r   my_url_handlero  s    z3PydocServerTest.test_server.<locals>.my_url_handlerz0.0.0.0r   )hostnameportg{Gz?)r    Z_start_serverrn   Z	docserveraddresstime	monotonicr   r   ZSHORT_TIMEOUTZservingsleepstoprP   error)rK   r  ZserverthreadZ	starttimetimeoutr   r   r   test_serverl  s    
zPydocServerTest.test_serverN)r   r   r   r  r   r   r   r   r  i  s   r  c                   @   s   e Zd Zdd Zdd ZdS )PydocUrlHandlerTestc                 C   s*   t j}| t|dd | t|dd d S )Nry   r   rz   foobar)r    rO   rD  	TypeError)rK   r   r   r   r   test_content_type_err  s    z)PydocUrlHandlerTest.test_content_type_errc                 C   sN   g d}|   * |D ]\}}| || qW d    n1 s@0    Y  d S )N))r   Pydoc: Index of Modules)zget?key=r  )r^  r  )ZtopicszPydoc: Topics)keywordszPydoc: Keywords)r    Pydoc: module pydoc)zget?key=pydocr  )zsearch?key=pydocr  )ztopic?key=defzPydoc: KEYWORD def)ztopic?key=STRINGSzPydoc: TOPIC STRINGS)r  zPydoc: Error - foobar)rN   rS   )rK   ZrequestsrQ   rB   r   r   r   test_url_requests  s    
z%PydocUrlHandlerTest.test_url_requestsN)r   r   r   r  r  r   r   r   r   r    s   r  c                   @   s   e Zd Zdd ZdS )
TestHelperc                 C   s   |  ttjjttj d S rE   )rP   sortedr    r   r  keywordkwlistr   r   r   r   test_keywords  s    zTestHelper.test_keywordsN)r   r   r   r  r   r   r   r   r    s   r  c                   @   s   e Zd Zeejjdkdeeedo.e	 ddd Z
eejjdkdeeedode	 ddd Zeejjdkdeeedoe	 dd	d
 Zeejjdkdeeedoe	 ddd Zdd ZdS )PydocWithMetaClassesrW   rX   rY   rZ   c                 C   s   G dd dt }G dd d|d}tdd tD }t }tj|d}|| ttf|d d	   }| 	 }| 
|| d S )
Nc                       s   e Zd Z fddZ  ZS )z=PydocWithMetaClasses.test_DynamicClassAttribute.<locals>.Metac                    s   |dkrdS t  |S )NhamZspamsuper__getattr__rE  r   r   r   r    s    zIPydocWithMetaClasses.test_DynamicClassAttribute.<locals>.Meta.__getattr__)r   r   r   r  __classcell__r   r   r  r   Meta  s   r  c                   @   s   e Zd Zejdd ZdS )z;PydocWithMetaClasses.test_DynamicClassAttribute.<locals>.DAc                 S   s   dS )NZeggsr   r   r   r   r   r    s    z?PydocWithMetaClasses.test_DynamicClassAttribute.<locals>.DA.hamN)r   r   r   typesDynamicClassAttributer  r   r   r   r   DA  s   r  	metaclassc                 s   s   | ]}|rd | ndV  qdS )z	
 |      r   Nr   r   r   r   r   r     s   zBPydocWithMetaClasses.test_DynamicClassAttribute.<locals>.<genexpr>r   rW   )r   r  expected_data_docstringsr   r    r   !expected_dynamicattribute_patternr   r   r"   rP   )rK   r  r  re   r/   r   rf   rR   r   r   r   test_DynamicClassAttribute  s    z/PydocWithMetaClasses.test_DynamicClassAttributec                 C   s`   G dd dt }G dd d|d}t }tj|d}|| tt }|  }| || d S )Nc                       s$   e Zd Zdd Z fddZ  ZS )zHPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.Metac                 S   s   g dS )N)r   r   r   LIFEr   rk  r   r   r   __dir__  s    zPPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.Meta.__dir__c                    s   |dkrdS t  |S )Nr  rx   )r  Z_Meta__getattrrE  r  r   r   r    s    zTPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.Meta.__getattr__r   r   r   r  r  r  r   r   r  r   r    s   r  c                   @   s   e Zd ZdS )zIPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.ClassNr   r   r   r   r   Class  s   r  r  r   )	r   r   r    r   "expected_virtualattribute_pattern1r   r   r"   rP   )rK   r  r  r/   r   rf   rR   r   r   r   %test_virtualClassAttributeWithOneMeta  s    z:PydocWithMetaClasses.test_virtualClassAttributeWithOneMetac                    s   G dd dt  G dd dt G  fddd }G dd d d	}G d
d d||d	}d }}t }tj|d}|| tt }|  }	| ||	 t }tj|d}|| t	t }
|  }| |
| d S )Nc                       s$   e Zd Zdd Z fddZ  ZS )zIPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1c                 S   s   g dS )N)r   r   r   ri   r   r  r   r   r   r    s    zQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1.__dir__c                    s   |dkrdS t  |S )Nri   rh   r  rE  r  r   r   r    s    zUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1.__getattr__r  r   r   r  r   Meta1  s   r  c                       s$   e Zd Zdd Z fddZ  ZS )zIPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2c                 S   s   g dS )N)r   r   r   twor   r  r   r   r   r    s    zQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2.__dir__c                    s   |dkrdS t  |S )Nr  rW   r  rE  r  r   r   r    s    zUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2.__getattr__r  r   r   r  r   Meta2  s   r  c                       s*   e Zd ZfddZ fddZ  ZS )zIPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3c                    s(   t ttg d |  |  S )N)r   r   r   three)r/  r  setr  r  r  r  r   r   r    s    zQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3.__dir__c                    s   |dkrdS t  |S )Nr  r  r  rE  r  r   r   r    s    zUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3.__getattr__r  r   r  r  r   Meta3  s   r  c                   @   s   e Zd ZdS )zJPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Class1Nr   r   r   r   r   Class1  s   r  r  c                   @   s   e Zd ZdS )zJPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Class2Nr   r   r   r   r   Class2  s   r  Fr   )
r   r   r    r   "expected_virtualattribute_pattern2r   r   r"   rP   "expected_virtualattribute_pattern3)rK   r  r  r  Zfail1Zfail2r/   r   Zexpected_text1Zresult1Zexpected_text2Zresult2r   r  r   %test_virtualClassAttributeWithTwoMeta  s$    	z:PydocWithMetaClasses.test_virtualClassAttributeWithTwoMetac                 C   s`   G dd dt }G dd d|d}t }tj|d}|| tt }|  }| || d S )Nc                   @   s   e Zd Zdd ZdS )z.PydocWithMetaClasses.test_buggy_dir.<locals>.Mc                 S   s   g dS )N)r   r   missingherer   r  r   r   r   r    s    z6PydocWithMetaClasses.test_buggy_dir.<locals>.M.__dir__N)r   r   r   r  r   r   r   r   M  s   r  c                   @   s   e Zd ZdZdS )z.PydocWithMetaClasses.test_buggy_dir.<locals>.Czpresent!N)r   r   r   r  r   r   r   r   r%  
  s   r%  r  r   )	r   r   r    r   !expected_missingattribute_patternr   r   r"   rP   )rK   r  r%  r/   r   rf   rR   r   r   r   test_buggy_dir  s    z#PydocWithMetaClasses.test_buggy_dirc                 C   sH   t  }td W d    n1 s&0    Y  | }| d| d S )Nz	enum.Enumz
class Enum)r
   r    r   r   rn   )rK   r   r   r   r   r   test_resolve_false  s    (z'PydocWithMetaClasses.test_resolve_falseN)r   r   r   r   r   rt   r   r   r   rY   r  r  r  r  r  r   r   r   r   r    s:   *r  c                   @   sF   e Zd Zdd ZdddZdd Zdd	 Zd
d Zdd Zdd Z	dS )TestInternalUtilitiesc                 C   sN   t  }|j| _tj|jd| _| |j	 t
  | _}dtj|g| _d S )NZnonexistentr   )tempfileTemporaryDirectoryrF  argv0dirr3   r4   r   argv0r   cleanupgetcwd
abs_curdircurdircurdir_spellings)rK   Ztmpdirr  r   r   r   r     s    zTestInternalUtilities.setUpNc                 C   s   |d u r| j }t||S rE   )r  r    _get_revised_path)rK   
given_pathr  r   r   r   r  &  s    z'TestInternalUtilities._get_revised_pathc                 C   s8   t j }| jD ]"}t||D ]}|| q"q|S rE   )rt   r4   copyr  ry  countr   )rK   
clean_pathspelling__r   r   r   _get_starting_path-  s
    

z(TestInternalUtilities._get_starting_pathc                 C   s*   |   }| jg| }| | || d S rE   )r  r  rP   r  )rK   r  expected_pathr   r   r   ,test_sys_path_adjustment_adds_missing_curdir5  s    zBTestInternalUtilities.test_sys_path_adjustment_adds_missing_curdirc                 C   sT   |   }| jg| }| jg| }| | || || jg }| | || d S rE   )r  r  r  rP   r  )rK   r  r  leading_argv0dirtrailing_argv0dirr   r   r   *test_sys_path_adjustment_removes_argv0_dir:  s    z@TestInternalUtilities.test_sys_path_adjustment_removes_argv0_dirc                    sh    fdd}   } jg| } jg| } ||| | jg } jg| } ||| d S )Nc                    s    j | tjdS )N)r  )r  r    r!   )r  r   r   r   r  D  s    z\TestInternalUtilities.test_sys_path_adjustment_protects_pydoc_dir.<locals>._get_revised_path)r  r  r  rP   )rK   r  r  r  r  r  r   r   r   +test_sys_path_adjustment_protects_pydoc_dirC  s    zATestInternalUtilities.test_sys_path_adjustment_protects_pydoc_dirc              	   C   s   |   }| jD ]}| j|d| |g| }| | | ||g }| | | | jg| }| | | || jg }| | | W d    q1 s0    Y  qd S )N)Zcurdir_spelling)r  r  ZsubTestr   r  r  )rK   r  r  Zleading_curdirZtrailing_curdirr  r  r   r   r   5test_sys_path_adjustment_when_curdir_already_includedN  s    


zKTestInternalUtilities.test_sys_path_adjustment_when_curdir_already_included)N)
r   r   r   r   r  r  r  r  r  r   r   r   r   r   r    s   
	r  c                  C   s.   t j } tjt jjg| R   tt d S rE   )r   r   Zthreading_setupr   ZaddModuleCleanupZthreading_cleanupr   )thread_infor   r   r   setUpModule]  s    
r  __main__)Pr3   rt   rT   importlib.utilr   r[   r    r   r  rS  rM   r:   r  stringr  Ztest.supportr   r  r  r+  r   urllib.parser]   Z	xml.etreerp   Zxml.etree.ElementTreer   ior   collectionsr   Ztest.support.script_helperr   r   r   r   r   r	   r
   r   r   r   r   r   r   ZHAVE_DOCSTRINGSr  r"   rd   r  re   r`   ra   r   linesepr   r   r  r  r  r  r  r)   r1   r8   r=   rC   ZTestCaserD   rV   r   r"  r  r  r  r  r  r  r   mainr   r   r   r   <module>   s   ,
] 			
		   R   GvA
