o
    HXh#                     @   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! d dlm"Z" d dlm#Z#m$Z$m%Z%m&Z&m'Z' d dl(m)Z)m*Z*m+Z+ d d	lm,Z, G d
d dZ-ej.j/rdZ0ndZ0d1 Z2e3dd e0D Z4d1 Z5e3dd e0D Z6d7de j8Z9dZ:d1 Z;d1 Z<d1 Z=d1 Z>d1 Z?dd Z@dd ZAdd  ZBd!d" ZCd#d$ ZDG d%d& d&ejEZFG d'd( d(ejEZGG d)d* d*eFZHG d+d, d,ejEZIG d-d. d.ejEZJG d/d0 d0eFZKG d1d2 d2ejEZLG d3d4 d4ejEZMG d5d6 d6ejEZNd7d8 ZOePd9krQeQ  dS dS ):    N)StringIO)
namedtuple)	os_helper)assert_python_ok)threading_helper)reap_childrencaptured_outputcaptured_stdoutcaptured_stderrrequires_docstrings)TESTFNrmtreeunlink)	pydoc_modc                   @   s   e Zd Z	 dS )nonasciiN__name__
__module____qualname__ r   r   9/opt/python-3.10.19/usr/lib/python3.10/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]
    type_union2 = int | str

VERSION
    1.2.3.4

AUTHOR
    Benjamin Peterson

CREDITS
    Nobody

FILE
    %s
c                 c        | ]}|r
d | ndV  qdS )z
     |      r   Nr   .0sr   r   r   	<genexpr>       r   a  
<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]<br>
<strong>type_union2</strong> = 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   s4   	 || 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_pydocn  s   
 r,   c                 C   s>   	 t  }|| }|tpd}|rd| 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_htmlx  s   
r4   c                 C   s<   	 t jj}t jj}|||t}t }|j| |d}|S )N)basedir)ospathabspathdirnamer$   r#   TextDocr/   )r0   r8   r9   r5   r1   r3   r   r   r   get_pydoc_link  s   r;   c                 C   sT   	 t  }|tpd}|rd| d }|| }td}|d|}| |fS )Nr   z
MODULE DOCS
    r"   .)	r#   r:   r/   r   r.   recompilesubr%   )r0   r1   r3   r2   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   rF   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   )r7   prefixonerrorZdefault_pathwalk_packagesr   r   wrapper     z8PydocBaseTest._restricted_walk_packages.<locals>.wrapper)Nr   N)r6   r7   r9   r$   )selfrL   r7   rM   r   rK   r   _restricted_walk_packages  s   z'PydocBaseTest._restricted_walk_packagesc                 c   s2    t j}| ||t _z	d V  W |t _d S |t _w rH   )pkgutilrL   rP   )rO   r7   rL   r   r   r   restrict_walk_packages  s   z$PydocBaseTest.restrict_walk_packagesc                 C   s&   t |d}t|}| ||| |S )Nz	text/html)r#   _url_handlerrF   assertEqual)rO   urlZexpected_titlerB   resultr   r   r   call_url_handler  s   zPydocBaseTest.call_url_handlerrH   )r   r   r   rP   
contextlibcontextmanagerrR   rW   r   r   r   r   rG     s
    

	rG   c                   @   s  e Zd ZdZeejjdkdee	edoe
 dedd Zeejjdkdee	edo6e
 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oe
 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 rH   )
r4   r   inspect
getabsfileurllibparsequoteexpected_html_patternexpected_html_data_docstringsrT   )rO   rV   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 rH   )r@   r   expected_text_patternexpected_text_data_docstringsr_   r`   rT   )rO   rV   rf   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    rn   z<BinaryInteger.zero: 0>)enumIntEnumr#   
render_docassertIn)rO   ro   rn   r1   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)r;   xmletreeZElementTreerr   )rO   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@   rt   ru   rT   )rO   rV   rf   r   r   r   test_issue8225  s   zPydocDocTest.test_issue8225c                 C   s*   t j}zd t _t  W |t _d S |t _w rH   )sysstdinr#   getpager)rO   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      r}   c                   @      e Zd ZdS )z)PydocDocTest.test_non_str_name.<locals>.BNr   r   r   r   r   B      r   )r#   rq   rT   r!   )rO   r}   r   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_patternrT   rO   Zmissing_modulerV   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__encoderr   )rO   rV   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%   rT   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#   stripidrT   )rO   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#   r:   docclassobjectZassertRegexrO   r1   rB   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#   r:   r   ArithmeticErrorrr   r   r   r   r   test_builtin_with_childD  s
   
z$PydocDocTest.test_builtin_with_childc                 C   s4   	 t  }|t}d}| || | d| d S )Nz^ |  Built-in subclasses:
 |      ArithmeticError
 |      AssertionError
 |      AttributeErrorZeroDivisionError)r#   r:   r   	Exceptionrr   assertNotInr   r   r   r   test_builtin_with_grandchild_  s   
z)PydocDocTest.test_builtin_with_grandchildc                 C   $   	 t  }|t}| d| d S NzBuilt-in subclasses)r#   r:   r   r   r   rO   r1   rB   r   r   r   test_builtin_no_child  s   
z"PydocDocTest.test_builtin_no_childc                 C   r   r   )r#   r:   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_zbtdJ}td6}|| |  }|
|ft ttf  }| d|  | d|  | || W d    n1 spw   Y  W d    n1 sw   Y  W |t_d S W |t_d S |t_w )	Nc                   S   s   dd S )Nc                 S   s   | S rH   r   )xr   r   r   <lambda>  s    zJPydocDocTest.test_help_output_redirect.<locals>.<lambda>.<locals>.<lambda>r   r   r   r   r   r     s    z8PydocDocTest.test_help_output_redirect.<locals>.<lambda>r2   ztest.pydoc_modz9
        Help on module test.pydoc_mod in test:

        stdoutstderrr   )rh   r#   rz   maxDiffr   Helperr@   r   lstriptextwrapdedentr   helpgetvaluer%   ri   r_   r`   rT   )rO   Zold_patternZgetpager_oldZgetpager_newbufhelperZunusedrf   r0   Zhelp_headerZexpected_help_patternr2   r+   rV   rj   r   r   r   test_help_output_redirect  sJ   



 
z&PydocDocTest.test_help_output_redirectc                 C   sz   t dddg}t }t| W d    n1 sw   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   rr   )rO   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 sw   Y  | }| d| | d| | d| d S )	NNTabcdefT)renameZ_1_replace_asdictr   )rO   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!}|dkrtd||d td|d td|d W d    n1 s5w   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#   synopsisrT   )rO   r   Zscriptr   r   r   r   test_synopsis  s   zPydocDocTest.test_synopsisc                 C   s.   t j d }t j}t|}| || d S )Nr   )r6   r   
splitlines
__cached__r#   r   rT   )rO   r   filenamer   r   r   r   test_synopsis_sourceless  s   
z%PydocDocTest.test_synopsis_sourcelessc              	   C   s   t  K}tj|d}tj|}t|d}|	d W d    n1 s'w   Y  t
| t|i }| | t|i }| | W d    d S 1 sRw   Y  d S )Nzfoomod42.pyr   foo = 1)r   temp_cwdr6   r7   join	importlibutilcache_from_sourcer   write
py_compiler>   r#   r   assertIsNone)rO   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)rT   r#   Zsplitdoc)rO   Zexample_stringr   r   r   test_splitdoc_with_description  s   z+PydocDocTest.test_splitdoc_with_descriptionc                 C   s>   t  }| t| W d    d S 1 sw   Y  d S rH   )r   r   ZassertFalser#   	ispackage)rO   r   r   r   r    test_is_package_when_not_package  s   
"z-PydocDocTest.test_is_package_when_not_packagec                 C   sd   t  $}tj|d}t|d  | t	| t
| W d    d S 1 s+w   Y  d S )N__init__.pyr   )r   r   r6   r7   r   r   close
assertTruer#   r   remove)rO   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                   @      e Zd Zdd ZdS )z/PydocDocTest.test_allmethods.<locals>.TestClassc                 S      dS )NTr   rO   r   r   r   method_returning_true     zEPydocDocTest.test_allmethods.<locals>.TestClass.method_returning_trueN)r   r   r   r   r   r   r   r   	TestClass      r   r   r   	__class____subclasshook____init_subclass__)	r   dictvarsr   r   r   r#   Z
allmethodsZassertDictEqual)rO   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      d S rH   r   )rO   Z	aboveThisr   r   r   tkraise,  r   z3PydocDocTest.test_method_aliases.<locals>.A.tkraisec                 S   r   rH   r   r   r   r   r   a_size/  r   z2PydocDocTest.test_method_aliases.<locals>.A.a_sizerH   )r   r   r   r   Zliftr   r   r   r   r   r}   +  s    
r}   c                       s    e Zd ZdddZeZ jZdS )z+PydocDocTest.test_method_aliases.<locals>.BNc                 [   r   rH   r   )rO   ZtagOrIdZcnfkwr   r   r   itemconfigure2  r   z9PydocDocTest.test_method_aliases.<locals>.B.itemconfigurerH   )r   r   r   r   Z
itemconfigr   Zb_sizer   r}   r   r   r   1  s    

r   r<   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#   rq   r=   r?   rT   r   r-   )rO   r   r1   r   r   r   test_method_aliases*  s   
%'(
z PydocDocTest.test_method_aliases)'r   r   r   r   unittestskipIfrx   flagsoptimizehasattrr]   r   rg   rk   rs   rv   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   r   rZ     sp    	

 #
	
rZ   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 rH   )r6   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 ]6\}}t|d	}|d
 | W d    n1 s@w   Y  t|td	d}t
||f }| || q$d 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   r6   r7   r   r   extsepr   r   r,   decodebadimport_patternrT   )	rO   modnameZ	testpairsZsourcefnZimportstringZexpectedinmsgfrV   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 s-w   Y  | jtgd t	  }t
 }td W d    n1 sQw   Y  W d    n1 s`w   Y  | | d | | d t	  }t
 }td W d    n1 sw   Y  W d    n1 sw   Y  | |  d | | d W d    d S 1 sw   Y  d S )	NZ	syntaxerr__init__r  r   zinvalid python syntax = $1
r7   Zxyzzyr   )r6   r7   r   r   r   r  r   r   rR   r	   r
   r#   aproposrT   r   r%   )rO   pkgdirZ	badsyntaxr	  r*   r+   r   r   r   test_apropos_with_bad_package  s0   
"z-PydocImportTest.test_apropos_with_bad_packagec              
   C   s   t jtd| _t | jd | t j| j | jtgd3 t	  }t
 }td W d    n1 s6w   Y  W d    n1 sEw   Y  W d    n1 sTw   Y  | | d | | d d S )NZ
unreadabler   r  ZSOMEKEYr   )r6   r7   r   r   Zunreadable_dirr   r   rmdirrR   r	   r
   r#   r  rT   r   )rO   r*   r+   r   r   r    test_apropos_with_unreadable_dir  s   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.w   Y  t	
t 	|j}zJt ||t	j @  | jtgd  t }td W d    n1 sbw   Y  W d    n1 sqw   Y  | d|  W t || d S t || w )NZwalkpkgr   r   r   r  r   )r6   r7   r   r   r   r   r   r   r   statS_IMODEst_modechmodS_IEXECrR   r	   r#   r  rr   r   )rO   r  r   r   Zcurrent_moder   r   r   r   test_apropos_empty_doc  s"   
 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 s*w   Y  | jtgdO tt	j}t	j
dt z1| td	 dd l}W d    n1 sYw   Y  | d
d}d}| || W |t	jd d < n|t	jd d < w W d    d S 1 sw   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>)r6   r7   r   r   r   r   r   rR   tuplerx   insertZassertRaisesRegex
ValueErrorr  rW   rr   )rO   r  Zinitr	  Zsaved_pathsr  rB   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 )Nr[         r   modules)r   r#   r   r   r%   lenr   ZassertGreaterEqual)	rO   Znum_header_linesZnum_module_lines_minZnum_footer_linesr   r2   r   rV   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w   Y  | }| || d S )Nzpydoc - r   zmodules pydoc)r   r#   r   r	   r   rr   rO   r   r2   r   r   rV   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w   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assertIsNotrT   r   __spec__)rO   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,  )testr,  r#   rq   rr   )rO   r,  r1   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                   @   r   )z&TestDescriptions.test_class.<locals>.CNr   r   r   r   r   C/      r/  zclass CzC in module %s object)rT   r#   describer   rr   rq   )rO   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 )	NZ_GenericAliasr   z_GenericAlias in module typingzList = class list(object)r   GenericAliaszGenericAlias in module builtinsz
class list(object))rT   r#   r1  typingListintrq   	plaintextrr   listr   r%   r   rO   r1   r   r   r   test_generic_alias7  s   z#TestDescriptions.test_generic_aliasc                 C   s   |  ttjttf d tjtjttf tjd}| 	d| | 	d| tjj
r9| 	tjj
  d | |  tttB d tjttB tjd}| 	d| | 	d| | 	tjj
  d | d S )	NZ_UnionGenericAliasr   z#_UnionGenericAlias in module typingzUnion = typing.Unionr   	UnionTypez UnionType in module types objectz!
class UnionType(builtins.object))rT   r#   r1  r5  ZUnionr7  r   rq   r8  rr   r   r%   r   typesr<  r:  r   r   r   test_union_typeD  s    z TestDescriptions.test_union_typec                 C   sv   |  ttjd tjtjtjd}| d| tjjr3| d| | tjj	 
 d | d S | d| d S )NZ_SpecialFormr   z_SpecialForm in module typingzAny = typing.Anyr   z Any = class _SpecialForm(_Final))rT   r#   r1  r5  Anyrq   r8  rr   r   r%   r   r:  r   r   r   test_special_formR  s    z"TestDescriptions.test_special_formc              	   C   s   dt jt j dtdt jt jtt jf  f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   r   rH   r   )rA  r   r   r   r   foo]     z/TestDescriptions.test_typing_pydoc.<locals>.fooTc                   @   r   )z-TestDescriptions.test_typing_pydoc.<locals>.CNr   r   r   r   r   r/  a  r0  r/  z?ffoooo(data: List[Any], x: int) -> Iterator[Tuple[int, Any]]r[   z2class CC(collections.abc.Mapping, typing.Generic))r5  r6  r?  r7  IteratorZTupleTypeVarZGenericMappingr   rT   r#   rq   r   )rO   rC  rE  r/  r   r   r   test_typing_pydoc\  s   

"z"TestDescriptions.test_typing_pydocc              	   C   sx   dD ]"}|  t| zt| W q ty$   | d| Y qw dD ]}| t| | ttj| q'd 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locaterq   ImportErrorZfailr   r   assertRaisesrO   namer   r   r   test_builtinh  s   zTestDescriptions.test_builtinc                 C   s"   t t | }|d}|d S Nr"   r[   )r#   plainrq   splitorB   linesr   r   r   _get_summary_liney  s   
z"TestDescriptions._get_summary_linec                 C   s,   t t | }|d}d|dd  S rP  )r#   rQ  rq   rR  r   rS  r   r   r   _get_summary_lines  s   
z#TestDescriptions._get_summary_linesc                 C      |  | tjjd d S )Nzwrap(self, text))rT   rV  r   TextWrapperwrapr   r   r   r   test_unbound_python_method  s   z+TestDescriptions.test_unbound_python_methodc                 C   rX  )Nzdump(self, obj, /))rT   rV  _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   rY  rT   rV  rZ  )rO   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   rb  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  r~   re  c                   @   s   e Zd Zg gZdS )zMTestDescriptions.test_field_order_for_named_tuples.<locals>.NonHashableFieldsNrc  r   r   r   r   NonHashableFields      
rf  )r   r#   rq   Z
assertLessindex)rO   r   r   re  rf  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   r\  r]  rT   rV  r^  )rO   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))rT   rV  r6   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                   @      e Zd Zedd ZdS )z-TestDescriptions.test_staticmethod.<locals>.Xc                 S      	 d S rH   r   r   yr   r   r   sm     z0TestDescriptions.test_staticmethod.<locals>.X.smN)r   r   r   staticmethodrq  r   r   r   r   X      rt  rq  zsm(x, y)
    A static method
zL
 |  Static methods defined here:
 |  
 |  sm(x, y)
 |      A static method
)rT   rW  __dict__rq  rr   r#   rQ  rq   rO   rt  r   r   r   test_staticmethod     z"TestDescriptions.test_staticmethodc                 C   sV   G dd d}|  | |jd d |  | |jd | dtt| d S )Nc                   @   rm  )z,TestDescriptions.test_classmethod.<locals>.Xc                 S   rn  rH   r   )clsr   r   r   r   cm  rr  z/TestDescriptions.test_classmethod.<locals>.X.cmN)r   r   r   classmethodr{  r   r   r   r   rt    ru  rt  r{  zcm(...)
    A class method
z:cm(x) method of builtins.type instance
    A class method
zZ
 |  Class methods defined here:
 |  
 |  cm(x) from builtins.type
 |      A class method
)rT   rW  rv  r{  rr   r#   rQ  rq   rw  r   r   r   test_classmethod  ry  z!TestDescriptions.test_classmethodc                 C   sT   |  | tjd |  | tjd |  | tjd |  | tj	d d S )N	numeratorrealr'   obj)
rT   rV  r7  r~  floatr  r   r'   
memoryviewr  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 )Nr  startfgetvalue)rT   rV  complexr  ranger  slicepropertyr  StopIterationr  r   r   r   r   test_member_descriptor  s
   z'TestDescriptions.test_member_descriptorc                 C   s&   G dd d}|  | |jd d S )Nc                   @      e Zd ZdZdS )z4TestDescriptions.test_slot_descriptor.<locals>.Pointro  N)r   r   r   	__slots__r   r   r   r   Point  r~   r  r   )rT   rV  r   )rO   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                   @   r   )z6TestDescriptions.test_dict_attr_descriptor.<locals>.NSNr   r   r   r   r   NS  r   r  rv  )rT   rV  rv  )rO   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)rT   rV  r   rx   	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   rT   rW  r  )rO   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                   @   rm  )z,TestDescriptions.test_property.<locals>.Rectc                 S   s   	 | j | j S rH   )r   hr   r   r   r   area  s   z1TestDescriptions.test_property.<locals>.Rect.areaN)r   r   r   r  r  r   r   r   r   Rect  ru  r  z    Area of the rect
z#
 |  area
 |      Area of the rect
)rT   rW  r  rr   r#   rQ  rq   )rO   r  r   r   r   test_property  s
   zTestDescriptions.test_propertyc                    p   G dd d G  fddd}|  | |jd d|j_|  | |jd d|j_|  | |jd	 d S )
Nc                   @   r   )z?TestDescriptions.test_custom_non_data_descriptor.<locals>.Descrc                 S      |d u r| S dS Nr|   r   rO   r  rz  r   r   r   __get__!     zGTestDescriptions.test_custom_non_data_descriptor.<locals>.Descr.__get__N)r   r   r   r  r   r   r   r   Descr   r   r  c                          e Zd Z  ZdS )z;TestDescriptions.test_custom_non_data_descriptor.<locals>.XNr   r   r   attrr   r  r   r   rt  %  rg  rt  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
rC  zfoo(...)
    Custom descriptor
rT   rW  r  r   r   rw  r   r  r   test_custom_non_data_descriptor  s   z0TestDescriptions.test_custom_non_data_descriptorc                    r  )
Nc                   @   s   e Zd Zdd Zdd ZdS )z;TestDescriptions.test_custom_data_descriptor.<locals>.Descrc                 S   r  r  r   r  r   r   r   r  :  r  zCTestDescriptions.test_custom_data_descriptor.<locals>.Descr.__get__c                 S   s   dd  d S )Nrl   r   r   r  r   r   r   __set__>  s   zCTestDescriptions.test_custom_data_descriptor.<locals>.Descr.__set__N)r   r   r   r  r  r   r   r   r   r  9  s    r  c                       r  )z7TestDescriptions.test_custom_data_descriptor.<locals>.XNr  r   r  r   r   rt  @  rg  rt  r   r  z    Custom descriptor
rC  zfoo
    Custom descriptor
r  rw  r   r  r   test_custom_data_descriptor7  s   z,TestDescriptions.test_custom_data_descriptorc                 C   sJ   dt fdd}ttj|}| d| t |}| d| d S )NrB  c                    s   dS Nrl   r   )Zignr   r   r   coro_functionQ  s   z=TestDescriptions.test_async_annotation.<locals>.coro_functionzasync coro_functionz4async <a name="-coro_function"><strong>coro_function)r7  r#   rQ  r8  documentrr   r-   )rO   r  rB   htmlr   r   r   test_async_annotationP  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_generator]  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#   rQ  r8  r  rr   r-   )rO   r  rB   r  r   r   r   test_async_generator_annotation\  s   z0TestDescriptions.test_async_generator_annotationc                 C   s&   dd }t  |}| d| d S )Nc                   S   rn  rH   r   r   r   r   r   a_fn_with_https_linki  s   zHTestDescriptions.test_html_for_https_links.<locals>.a_fn_with_https_linkz3<a href="https://localhost/">https://localhost/</a>)r#   r-   r  rr   )rO   r  r  r   r   r   test_html_for_https_linksh  s   z*TestDescriptions.test_html_for_https_linksN)"r   r   r   r.  r3  r;  r>  r@  rJ  rO  rs  rV  rW  r[  r   r_  ra  ri  rk  rl  rx  r}  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r+  &  s\    	









	







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
r7td |j
r4t | |kr4|  n|j
s| |jd  d S )Nc                 S   s   d| |f }|S )Nzthe URL sent was: (%s, %s)r   )rU   Zcontent_typerB   r   r   r   my_url_handlery  s   z3PydocServerTest.test_server.<locals>.my_url_handlerz0.0.0.0r   )hostnameportg{Gz?)r#   Z_start_serverrr   Z	docserveraddresstime	monotonicr-  supportZSHORT_TIMEOUTZservingsleepstoprT   error)rO   r  ZserverthreadZ	starttimetimeoutr   r   r   test_serverv  s   
zPydocServerTest.test_serverN)r   r   r   r  r   r   r   r   r  s  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 )Nr}   r   r   foobar)r#   rS   rL  	TypeError)rO   r	  r   r   r   test_content_type_err  s   z)PydocUrlHandlerTest.test_content_type_errc                 C   sP   g d}|    |D ]
\}}| || qW d    d S 1 s!w   Y  d S )N))r   Pydoc: Index of Modules)zget?key=r  )rh  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)rR   rW   )rO   ZrequestsrU   rE   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                   @   r   )
TestHelperc                 C   s   |  ttjjttj d S rH   )rT   sortedr#   r   r  keywordkwlistr   r   r   r   test_keywords  s   zTestHelper.test_keywordsN)r   r   r   r  r   r   r   r   r    r   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o2e	 ddd ZeejjdkdeeedoMe	 dd	d
 Zeejjdkdeeedohe	 ddd Zdd ZdS )PydocWithMetaClassesr[   r\   r]   r^   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                       |dkrdS t  |S )NhamZspamsuper__getattr__rM  r   r   r   r       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   r   )NZeggsr   r   r   r   r   r    rD  z?PydocWithMetaClasses.test_DynamicClassAttribute.<locals>.DA.hamN)r   r   r   r=  DynamicClassAttributer  r   r   r   r   DA  s    r  	metaclassc                 s   r   )z	
 |      r   Nr   r   r   r   r   r     r   zBPydocWithMetaClasses.test_DynamicClassAttribute.<locals>.<genexpr>r   r[   )r   r  expected_data_docstringsr   r#   r   !expected_dynamicattribute_patternr   r   r%   rT   )rO   r  r  ri   r2   r   rj   rV   r   r   r   test_DynamicClassAttribute  s   z/PydocWithMetaClasses.test_DynamicClassAttributec                 C   `   G dd dt }G dd d|d}t }tj|d}|| tt }|  }| || d S )Nc                       $   e Zd Zdd Z fddZ  ZS )zHPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.Metac                 S      g dS )N)r   r   r   LIFEr   rz  r   r   r   __dir__     zPPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.Meta.__dir__c                    r  )Nr  r|   )r  Z_Meta__getattrrM  r  r   r   r    r  zTPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.Meta.__getattr__r   r   r   r  r  r  r   r   r  r   r        r  c                   @   r   )zIPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.ClassNr   r   r   r   r   Class  r   r  r  r   )	r   r   r#   r   "expected_virtualattribute_pattern1r   r   r%   rT   )rO   r  r  r2   r   rj   rV   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                       r  )zIPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1c                 S   r  )N)r   r   r   rm   r   r  r   r   r   r    r  zQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1.__dir__c                    r  )Nrm   rl   r  rM  r  r   r   r    r  zUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1.__getattr__r  r   r   r  r   Meta1  r  r  c                       r  )zIPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2c                 S   r  )N)r   r   r   twor   r  r   r   r   r    r  zQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2.__dir__c                    r  )Nr  r[   r  rM  r  r   r   r    r  zUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2.__getattr__r  r   r   r  r   Meta2  r  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)r9  r  setr  r  r  r  r   r   r    s   zQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3.__dir__c                    r  )Nr  r   r  rM  r  r   r   r    r  zUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3.__getattr__r  r   r  r  r   Meta3  s    r  c                   @   r   )zJPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Class1Nr   r   r   r   r   Class1  r   r  r  c                   @   r   )zJPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Class2Nr   r   r   r   r   Class2  r   r  Fr   )
r   r   r#   r   "expected_virtualattribute_pattern2r   r   r%   rT   "expected_virtualattribute_pattern3)rO   r  r  r  Zfail1Zfail2r2   r   Zexpected_text1Zresult1Zexpected_text2Zresult2r   r  r   %test_virtualClassAttributeWithTwoMeta  s$   	z:PydocWithMetaClasses.test_virtualClassAttributeWithTwoMetac                 C   r  )Nc                   @   r   )z.PydocWithMetaClasses.test_buggy_dir.<locals>.Mc                 S   r  )N)r   r   missingherer   r  r   r   r   r    r  z6PydocWithMetaClasses.test_buggy_dir.<locals>.M.__dir__N)r   r   r   r  r   r   r   r   M  r   r  c                   @   r  )z.PydocWithMetaClasses.test_buggy_dir.<locals>.Czpresent!N)r   r   r   r  r   r   r   r   r/    r~   r/  r  r   )	r   r   r#   r   !expected_missingattribute_patternr   r   r%   rT   )rO   r  r/  r2   r   rj   rV   r   r   r   test_buggy_dir  s   z#PydocWithMetaClasses.test_buggy_dirc                 C   sH   t  }td W d    n1 sw   Y  | }| d| d S )Nz	enum.Enumz
class Enum)r	   r#   r   r   rr   )rO   r   r   r   r   r   test_resolve_false  s
   z'PydocWithMetaClasses.test_resolve_falseN)r   r   r   r   r   rx   r   r   r   r]   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TemporaryDirectoryrN  argv0dirr6   r7   r   argv0r   cleanupgetcwd
abs_curdircurdircurdir_spellings)rO   Ztmpdirr
  r   r   r   r  (  s   zTestInternalUtilities.setUpNc                 C   s   |d u r| j }t||S rH   )r  r#   _get_revised_path)rO   
given_pathr  r   r   r   r  0  s   z'TestInternalUtilities._get_revised_pathc                 C   s8   t j }| jD ]}t||D ]}|| qq|S rH   )rx   r7   copyr  r  countr   )rO   
clean_pathspelling__r   r   r   _get_starting_path7  s   

z(TestInternalUtilities._get_starting_pathc                 C   s*   |   }| jg| }| | || d S rH   )r  r
  rT   r  )rO   r  expected_pathr   r   r   ,test_sys_path_adjustment_adds_missing_curdir?  s   zBTestInternalUtilities.test_sys_path_adjustment_adds_missing_curdirc                 C   sT   |   }| jg| }| jg| }| | || || jg }| | || d S rH   )r  r
  r  rT   r  )rO   r  r  leading_argv0dirtrailing_argv0dirr   r   r   *test_sys_path_adjustment_removes_argv0_dirD  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  N  rN   z\TestInternalUtilities.test_sys_path_adjustment_protects_pydoc_dir.<locals>._get_revised_path)r  r  r
  rT   )rO   r  r  r  r  r  r   r   r   +test_sys_path_adjustment_protects_pydoc_dirM  s   zATestInternalUtilities.test_sys_path_adjustment_protects_pydoc_dirc              	   C   s   |   }| jD ]N}| j|d> |g| }| | | ||g }| | | | jg| }| | | || jg }| | | W d    n1 sPw   Y  qd S )N)Zcurdir_spelling)r  r  ZsubTestr   r  r  )rO   r  r  Zleading_curdirZtrailing_curdirr  r  r   r   r   5test_sys_path_adjustment_when_curdir_already_includedX  s   


zKTestInternalUtilities.test_sys_path_adjustment_when_curdir_already_includedrH   )
r   r   r   r  r  r  r  r  r  r  r   r   r   r   r  &  s    
	r  c                  C   s*   t  } tjt jg| R   tt d S rH   )r   Zthreading_setupr   ZaddModuleCleanupZthreading_cleanupr   )thread_infor   r   r   setUpModuleg  s   r  __main__)Rr6   rx   rX   importlib.utilr   r_   r#   r   r  r\  rQ   r=   r  stringr  Ztest.supportr-  r  r=  r5  r   urllib.parsera   Z	xml.etreert   Zxml.etree.ElementTreer   ior   collectionsr   r   Ztest.support.script_helperr   r   r   r   r	   r
   r   Ztest.support.os_helperr   r   r   r   r   r  ZHAVE_DOCSTRINGSr  r%   rh   r  ri   rd   re   r!   linesepr   r  r  r  r  r  r   r,   r4   r;   r@   rF   ZTestCaserG   rZ   r   r+  r  r  r  r  r  r  r   mainr   r   r   r   <module>   s    \^   
			
		   R   OvA
