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ZdS )nonasciiu   Це не латиницяN__name__
__module____qualname____doc__ 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 )zW
    Runs pydoc on the specified module. Returns the stripped
    output of pydoc.
    z-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 )z&Returns pydoc generated output as htmlr   z<br><a href="z">Module Docs</a>)r!   HTMLDoc	docmodule	getdoclocr   r#   )moduledocoutputlocr   r   r   get_pydoc_htmlv  s    
r2   c                 C   s:   t jj}t jj}|||t}t }|j| |d}|S )z,Returns a documentation web link of a module)basedir)ospathabspathdirnamer"   r!   TextDocr-   )r.   r6   r7   r3   r/   r1   r   r   r   get_pydoc_link  s    r9   c                 C   sR   t  }|tpd}|r&d| d }|| }td}|d|}| |fS )z&Returns pydoc generated output as textr   z
MODULE DOCS
    r    .)	r!   r8   r-   r   r,   recompilesubr#   )r.   r/   r1   r0   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    rD   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 )zi
        A version of pkgutil.walk_packages() that will restrict itself to
        a given path.
        Nr   c                    s   | p ||S Nr   )r5   prefixonerrorZdefault_pathwalk_packagesr   r   wrapper  s    z8PydocBaseTest._restricted_walk_packages.<locals>.wrapper)Nr   N)r4   r5   r7   r"   )selfrJ   r5   rK   r   rI   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 rF   )pkgutilrJ   rM   )rL   r5   rJ   r   r   r   restrict_walk_packages  s    z$PydocBaseTest.restrict_walk_packagesc                 C   s&   t |d}t|}| ||| |S )Nz	text/html)r!   _url_handlerrD   assertEqual)rL   urlZexpected_titler@   resultr   r   r   call_url_handler  s    zPydocBaseTest.call_url_handler)N)N)r   r   r   rM   
contextlibcontextmanagerrO   rT   r   r   r   r   rE     s   

	rE   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 rF   )
r2   r   inspect
getabsfileurllibparsequoteexpected_html_patternexpected_html_data_docstringsrQ   )rL   rS   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 rF   )r>   r   expected_text_patternexpected_text_data_docstringsr\   r]   rQ   )rL   rS   rc   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   rk   z<BinaryInteger.zero: 0>)enumIntEnumr!   
render_docassertIn)rL   rl   rk   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)r9   xmletreeZElementTreero   )rL   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>   rq   rr   rQ   )rL   rS   rc   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 rF   )sysstdinr!   getpager)rL   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*   Nr   r   r   r   r   r   r   A  s   r{   c                   @   s   e Zd ZdS )z)PydocDocTest.test_non_str_name.<locals>.BNrz   r   r   r   r   B  s   r|   )r!   rn   rQ   r   )rL   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_patternrQ   rL   Zmissing_modulerS   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   r   encodero   )rL   rS   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#   rQ   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!   stripidrQ   )rL   r   r   r   r   test_stripid  s    


zPydocDocTest.test_stripidc                 C   s&   t  }|t}d}| || dS )a  Tests help on builtin object which have more than four child classes.

        When running help() on a builtin class which has child classes, it
        should contain a "Built-in subclasses" section and only 4 classes
        should be displayed with a hint on how many more subclasses are present.
        For example:

        >>> help(object)
        Help on class object in module builtins:

        class object
         |  The most base type
         |
         |  Built-in subclasses:
         |      async_generator
         |      BaseException
         |      builtin_function_or_method
         |      bytearray
         |      ... and 82 other subclasses
        z |  Built-in subclasses:
 |      async_generator
 |      BaseException
 |      builtin_function_or_method
 |      bytearray
 |      ... and \d+ other subclassesN)r!   r8   docclassobjectZassertRegexrL   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 )a1  Tests help on builtin object which have only child classes.

        When running help() on a builtin class which has child classes, it
        should contain a "Built-in subclasses" section. For example:

        >>> help(ArithmeticError)
        Help on class ArithmeticError in module builtins:

        class ArithmeticError(Exception)
         |  Base class for arithmetic errors.
         |
         ...
         |
         |  Built-in subclasses:
         |      FloatingPointError
         |      OverflowError
         |      ZeroDivisionError
        zc |  Built-in subclasses:
 |      FloatingPointError
 |      OverflowError
 |      ZeroDivisionErrorN)r!   r8   r   ArithmeticErrorro   r   r   r   r   test_builtin_with_childB  s    
z$PydocDocTest.test_builtin_with_childc                 C   s2   t  }|t}d}| || | d| dS )a  Tests help on builtin classes which have grandchild classes.

        When running help() on a builtin class which has child classes, it
        should contain a "Built-in subclasses" section. However, if it also has
        grandchildren, these should not show up on the subclasses section.
        For example:

        >>> help(Exception)
        Help on class Exception in module builtins:

        class Exception(BaseException)
         |  Common base class for all non-exit exceptions.
         |
         ...
         |
         |  Built-in subclasses:
         |      ArithmeticError
         |      AssertionError
         |      AttributeError
         ...
        z^ |  Built-in subclasses:
 |      ArithmeticError
 |      AssertionError
 |      AttributeErrorZeroDivisionErrorN)r!   r8   r   	Exceptionro   assertNotInr   r   r   r   test_builtin_with_grandchild]  s
    
z)PydocDocTest.test_builtin_with_grandchildc                 C   s"   t  }|t}| d| dS )a  Tests help on builtin object which have no child classes.

        When running help() on a builtin class which has no child classes, it
        should not contain any "Built-in subclasses" section. For example:

        >>> help(ZeroDivisionError)

        Help on class ZeroDivisionError in module builtins:

        class ZeroDivisionError(ArithmeticError)
         |  Second argument to a division or modulo operation was zero.
         |
         |  Method resolution order:
         |      ZeroDivisionError
         |      ArithmeticError
         |      Exception
         |      BaseException
         |      object
         |
         |  Methods defined here:
         ...
        Built-in subclassesN)r!   r8   r   r   r   rL   r/   r@   r   r   r   test_builtin_no_child}  s    
z"PydocDocTest.test_builtin_no_childc                 C   s"   t  }|t}| d| dS )zTests help on metaclasses.

        When running help() on a metaclasses such as type, it
        should not contain any "Built-in subclasses" section.
        r   N)r!   r8   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 rF   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>r0   ztest.pydoc_modz9
        Help on module test.pydoc_mod in test:

        stdoutstderrr   )re   r!   rw   maxDiffr   Helperr>   r   lstriptextwrapdedentr	   helpgetvaluer#   rf   r\   r]   rQ   )rL   Zold_patternZgetpager_oldZgetpager_newbufhelperZunusedrc   r.   Zhelp_headerZexpected_help_patternr0   r)   rS   rg   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   ro   )rL   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   )rL   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!   synopsisrQ   )rL   r   Zscriptr   r   r   r   test_synopsis  s    *zPydocDocTest.test_synopsisc                 C   s.   t j d }t j}t|}| || d S )Nr   )r4   r   
splitlines
__cached__r!   r   rQ   )rL   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_cwdr4   r5   join	importlibutilcache_from_sourcer   write
py_compiler<   r!   r   assertIsNone)rL   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)rQ   r!   Zsplitdoc)rL   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 rF   )r   r   r   ZassertFalser!   	ispackage)rL   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   r4   r5   r   r   close
assertTruer!   r   remove)rL   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   rL   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)rL   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 )z(Raise this widget in the stacking order.Nr   )rL   Z	aboveThisr   r   r   tkraise*  s    z3PydocDocTest.test_method_aliases.<locals>.A.tkraisec                 S   s   dS )zReturn sizeNr   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   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                 [   s   dS )z'Configure resources of an item TAGORID.Nr   )rL   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   r{   r   r   r|   /  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!   rn   r;   r=   rQ   r   r+   )rL   r|   r/   r   r   r   test_method_aliases(  s    
%'(z PydocDocTest.test_method_aliases)'r   r   r   r   unittestskipIfru   flagsoptimizehasattrrZ   r   rd   rh   rp   rs   rt   rx   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   rW     sn   	

 #
	
rW   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 rF   )r4   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   r4   r5   r   r   extsepr   r   r*   decodebadimport_patternrQ   )	rL   modnameZ	testpairsZsourcefnZimportstringZexpectedinmsgfrS   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
r5   Zxyzzyr   )r4   r5   r   r   r   r   r   r   rO   r
   r   r!   aproposrQ   r   r#   )rL   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   )r4   r5   r   r   Zunreadable_dirr   r   rmdirrO   r
   r   r!   r  rQ   r   )rL   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   )r4   r5   r   r   r   r   r   r   r   statS_IMODEst_modechmodS_IEXECrO   r
   r!   r  ro   r   )rL   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>)r4   r5   r   r   r   r   r   rO   tupleru   insertZassertRaisesRegex
ValueErrorr  rT   ro   )rL   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 )NrX         r   modules)r   r!   r   r   r#   lenr   ZassertGreaterEqual)	rL   Znum_header_linesZnum_module_lines_minZnum_footer_linesr   r0   r   rS   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   ro   rL   r   r0   r   r   rS   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assertIsNotrQ   r   __spec__)rL   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!   rn   ro   )rL   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ZdS )z&TestDescriptions.test_class.<locals>.CzNew-style classNr   r   r   r   r   C-  r   r&  zclass CzC in module %s object)rQ   r!   describer   ro   rn   )rL   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)rQ   r!   r'  typingListintrn   	plaintextro   listr   r#   r   rL   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   )rQ   r!   r'  r,  Unionr.  r   rn   r/  ro   r   r#   r   r1  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))rQ   r!   r'  r,  Anyrn   r/  ro   r   r#   r   r1  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 rF   r   )r9  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>.CNrz   r   r   r   r   r&  Y  r   r&  z?ffoooo(data: List[Any], x: int) -> Iterator[Tuple[int, Any]]rX   z2class CC(collections.abc.Mapping, typing.Generic))r,  r-  r7  r.  IteratorTupleTypeVarGenericMappingr   rQ   r!   rn   r   )rL   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locatern   ImportErrorZfailr   r   assertRaisesrL   namer   r   r   test_builtin`  s    zTestDescriptions.test_builtinc                 C   s"   t t | }|d}|d S Nr    rX   )r!   plainrn   splitor@   linesr   r   r   _get_summary_lineq  s    
z"TestDescriptions._get_summary_linec                 C   s,   t t | }|d}d|dd  S rI  )r!   rJ  rn   rK  r   rL  r   r   r   _get_summary_linesx  s    
z#TestDescriptions._get_summary_linesc                 C   s   |  | tjjd d S )Nzwrap(self, text))rQ   rO  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, /))rQ   rO  _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   rQ  rQ   rO  rR  )rL   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   rZ  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>.NonHashableFieldsNr[  r   r   r   r   NonHashableFields  s   r^  )r   r!   rn   Z
assertLessindex)rL   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   rT  rU  rQ   rO  rV  )rL   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))rQ   rO  r4   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 )zA static methodNr   r   yr   r   r   sm  s    z0TestDescriptions.test_staticmethod.<locals>.X.smN)r   r   r   staticmethodrf  r   r   r   r   X  s   rh  rf  z<staticmethod object>zsm(x, y)
    A static method
zL
 |  Static methods defined here:
 |  
 |  sm(x, y)
 |      A static method
)rQ   rP  __dict__rf  ro   r!   rJ  rn   rL   rh  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 )zA class methodNr   )clsr   r   r   r   cm  s    z/TestDescriptions.test_classmethod.<locals>.X.cmN)r   r   r   classmethodrm  r   r   r   r   rh    s   rh  rm  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
)rQ   rP  ri  rm  ro   r!   rJ  rn   rj  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)
rQ   rO  r.  rp  floatrq  r   r%   
memoryviewrr  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 )Nrq  startfgetvalue)rQ   rO  complexrq  rangerv  slicepropertyrw  StopIterationrx  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>.Pointrd  N)r   r   r   	__slots__r   r   r   r   Point  s   r  r   )rQ   rO  r   )rL   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>.NSNrz   r   r   r   r   NS  s   r  ri  )rQ   rO  ri  )rL   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)rQ   rO  r   ru   	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   rQ   rP  r  )rL   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 )zArea of the rect)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
)rQ   rP  r  ro   r!   rJ  rn   )rL   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 Nry   r   rL   rr  rl  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   rh    s   rh  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
rQ   rP  r  r   r   rj  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 )Nri   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   rh  6  s   rh  r   r  z    Custom descriptor
r;  zfoo
    Custom descriptor
r  rj  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)r:  c                    s   dS Nri   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!   rJ  r/  documentro   r+   )rL   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!   rJ  r/  r  ro   r+   )rL   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 )za link https://localhost/Nr   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  ro   )rL   r  r  r   r   r   test_html_for_https_links^  s    z*TestDescriptions.test_html_for_https_linksN)"r   r   r   r%  r)  r2  r5  r8  rC  rH  rg  rO  rP  rS  r   rW  rY  r`  rb  rc  rk  ro  ru  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Zdd ZdS )PydocServerTestzTests for pydoc._start_serverc                 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   )rR   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_serverro   Z	docserveraddresstime	monotonicr   r   ZSHORT_TIMEOUTZservingsleepstoprQ   error)rL   r  ZserverthreadZ	starttimetimeoutr   r   r   test_serverl  s    
zPydocServerTest.test_serverN)r   r   r   r   r  r   r   r   r   r  i  s   r  c                   @   s    e Zd ZdZdd Zdd ZdS )PydocUrlHandlerTestzTests for pydoc._url_handlerc                 C   s*   t j}| t|dd | t|dd d S )Nr{   r   r|   foobar)r!   rP   rE  	TypeError)rL   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)rO   rT   )rL   ZrequestsrR   rC   r   r   r   test_url_requests  s    
z%PydocUrlHandlerTest.test_url_requestsN)r   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 rF   )rQ   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 )PydocWithMetaClassesrX   rY   rZ   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                    s   |dkrdS t  |S )NhamZspamsuper__getattr__rF  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   rX   )r   r  expected_data_docstringsr   r!   r   !expected_dynamicattribute_patternr   r   r#   rQ   )rL   r  r  rf   r0   r   rg   rS   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   rl  r   r   r   __dir__  s    zPPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.Meta.__dir__c                    s   |dkrdS t  |S )Nr  ry   )r  Z_Meta__getattrrF  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>.ClassNrz   r   r   r   r   Class  s   r  r  r   )	r   r   r!   r   "expected_virtualattribute_pattern1r   r   r#   rQ   )rL   r  r  r0   r   rg   rS   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   rj   r   r  r   r   r   r    s    zQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1.__dir__c                    s   |dkrdS t  |S )Nrj   ri   r  rF  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  rX   r  rF  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)r0  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  rF  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>.Class1Nrz   r   r   r   r   Class1  s   r  r  c                   @   s   e Zd ZdS )zJPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Class2Nrz   r   r   r   r   Class2  s   r  Fr   )
r   r   r!   r   "expected_virtualattribute_pattern2r   r   r#   rQ   "expected_virtualattribute_pattern3)rL   r  r  r  Zfail1Zfail2r0   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#   rQ   )rL   r  r&  r0   r   rg   rS   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   ro   )rL   r   r   r   r   r   test_resolve_false  s    (z'PydocWithMetaClasses.test_resolve_falseN)r   r   r   r   r   ru   r   r   r   rZ   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TemporaryDirectoryrG  argv0dirr4   r5   r   argv0r   cleanupgetcwd
abs_curdircurdircurdir_spellings)rL   Ztmpdirr  r   r   r   r     s    zTestInternalUtilities.setUpNc                 C   s   |d u r| j }t||S rF   )r  r!   _get_revised_path)rL   
given_pathr  r   r   r   r  &  s    z'TestInternalUtilities._get_revised_pathc                 C   s8   t j }| jD ]"}t||D ]}|| q"q|S rF   )ru   r5   copyr  rz  countr   )rL   
clean_pathspelling__r   r   r   _get_starting_path-  s
    

z(TestInternalUtilities._get_starting_pathc                 C   s*   |   }| jg| }| | || d S rF   )r  r  rQ   r  )rL   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 rF   )r  r  r  rQ   r  )rL   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  rQ   )rL   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  )rL   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 rF   )r   r   Zthreading_setupr   ZaddModuleCleanupZthreading_cleanupr   )thread_infor   r   r   setUpModule]  s    
r  __main__)Pr4   ru   rU   importlib.utilr   r\   r!   r   r  rT  rN   r;   r	  stringr  Ztest.supportr   r  r  r,  r   urllib.parser^   Z	xml.etreerq   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#   re   r  rf   ra   rb   r   linesepr   r   r  r  r  r  r  r*   r2   r9   r>   rD   ZTestCaserE   rW   r   r#  r  r  r  r  r  r  r   mainr   r   r   r   <module>   s   ,
] 			
		   R   GvA
