B
    u9ae»  ã               @   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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.r:d	Z/nd
Z/d 0¡ Z1e2dd„ e/D ƒƒZ3d 0¡ Z4e2dd„ e/D ƒƒZ5d 6de j7¡Z8dZ9d 0¡ Z:d 0¡ Z;d 0¡ Z<d 0¡ Z=d 0¡ Z>dd„ Z?dd„ Z@dd„ ZAdd„ ZBd d!„ ZCG d"d#„ d#ejDƒZEG d$d%„ d%ejDƒZFG d&d'„ d'eEƒZGG d(d)„ d)ejDƒZHG d*d+„ d+ejDƒZIG d,d-„ d-eEƒZJG d.d/„ d/ejDƒZKG d0d1„ d1ejDƒZLG d2d3„ d3ejDƒZMe%d4d5„ ƒZNeOd6krŽeNƒ  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.7/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   aq  
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)
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)

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

DATA
    __xyz__ = 'X, Y and Z'

VERSION
    1.2.3.4

AUTHOR
    Benjamin Peterson

CREDITS
    Nobody

FILE
    %s
c             c   s   | ]}|rd | ndV  qdS )z
     |      r   Nr   )Ú.0Úsr   r   r   ú	<genexpr>„   s   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="#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>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%"><dl><dt><a name="-doc_func"><strong>doc_func</strong></a>()</dt><dd><tt>This&nbsp;function&nbsp;solves&nbsp;all&nbsp;of&nbsp;the&nbsp;world's&nbsp;problems:<br>
hunger<br>
lack&nbsp;of&nbsp;Python<br>
war</tt></dd></dl>
 <dl><dt><a name="-nodoc_func"><strong>nodoc_func</strong></a>()</dt></dl>
</td></tr></table><p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%"><strong>__xyz__</strong> = 'X, Y and Z'</td></tr></table><p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
    
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%">Benjamin&nbsp;Peterson</td></tr></table><p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Credits</strong></big></font></td></tr>
    
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%">Nobody</td></tr></table>
c             c   s   | ]}|  d d¡V  qdS )ú z&nbsp;N)Úreplace)r   r   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   s,   || f }t dtjf|ž|Ž\}}}| ¡ S )zW
    Runs pydoc on the specified module. Returns the stripped
    output of pydoc.
    z-B)r   ÚpydocÚ__file__Ústrip)Zmodule_nameÚargsÚenvZrcÚoutÚerrr   r   r   Ú	run_pydocS  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_html]  s    
r.   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*   r2   r3   r/   r+   r-   r   r   r   Úget_pydoc_linkf  s    r5   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   z.)	r   r4   r)   r   r(   ÚreÚcompileÚsubr!   )r*   r+   r-   r,   Zpattr   r   r   Úget_pydoc_texto  s    

r9   c             C   s4   |   d¡\}}}|  d¡\}}}|  d¡\}}}|S )Nz</head>z<title>z</title>)Ú	partition)ÚtextÚheaderÚ_Útitler   r   r   Úget_html_title}  s    r?   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   )r1   ÚprefixÚonerror)Údefault_pathÚwalk_packagesr   r   Úwrapper  s    z8PydocBaseTest._restricted_walk_packages.<locals>.wrapper)Nr   N)r0   r1   r3   r    )ÚselfrD   r1   rE   r   )rC   rD   r   Ú_restricted_walk_packages‡  s    z'PydocBaseTest._restricted_walk_packagesc             c   s,   t j}|  ||¡t _z
d V  W d |t _X d S )N)ÚpkgutilrD   rG   )rF   r1   rD   r   r   r   Úrestrict_walk_packages‘  s    
z$PydocBaseTest.restrict_walk_packagesc             C   s&   t  |d¡}t|ƒ}|  |||¡ |S )Nz	text/html)r   Ú_url_handlerr?   ÚassertEqual)rF   ÚurlZexpected_titler;   Úresultr   r   r   Úcall_url_handler›  s    zPydocBaseTest.call_url_handler)N)N)r   r   r   rG   Ú
contextlibÚcontextmanagerrI   rN   r   r   r   r   r@   …  s   

	r@   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e ejjdkd¡e e	edƒoe 
¡ d¡e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/d0„ Z d1d2„ Z!dS )3ÚPydocDocTestNé   z)Docstrings are omitted with -O2 and aboveÚgettracez1trace function introduces __locals__ unexpectedlyc             C   sD   t tƒ\}}t t¡}tj |¡}t|||ft  }|  	||¡ d S )N)
r.   r   ÚinspectÚ
getabsfileÚurllibÚparseZquoteÚexpected_html_patternÚexpected_html_data_docstringsrK   )rF   rM   Ú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 )N)r9   r   Úexpected_text_patternÚexpected_text_data_docstringsrT   rU   rK   )rF   rM   rZ   Ú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   rb   z<BinaryInteger.zero: 0>)ÚenumÚIntEnumr   Ú
render_docÚassertIn)rF   rc   rb   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)r5   ÚxmlÚetreeZElementTreerf   )rF   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)r9   rh   ri   rK   )rF   rM   rZ   r   r   r   Útest_issue8225Ð  s    zPydocDocTest.test_issue8225c             C   s&   t j}zd t _t ¡  W d |t _X d S )N)ÚsysÚstdinr   Úgetpager)rF   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   rq   c               @   s   e Zd ZdS )z)PydocDocTest.test_non_str_name.<locals>.BN)r   r   r   r   r   r   r   ÚBâ  s   rr   )r   re   rK   r   )rF   rq   rr   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 )Nztest.i_am_not_hereÚasciiz&documentation for missing module found)Ústrr&   Úmissing_patternrK   )rF   Úmissing_modulerM   Ú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.nonasciirt   )ZPYTHONIOENCODINGÚbackslashreplace)r&   r   r   Úencoderf   )rF   rM   Z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 rt   )ru   r&   rv   r!   rK   )rF   rw   rM   rx   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   ÚstripidrK   )rF   r~   r   r   r   Útest_stripidü  s    


zPydocDocTest.test_stripidc          
   C   sð   t }tj}dd„ }d | _tƒ }tj|d}ttƒ\}}d}d ¡ }	t	 
|	¡}	|	t  }
|t_zˆtdƒv}tdƒb}| |¡ | ¡  ¡ }|
|ft t t¡f  }|  d| ¡ ¡ |  d| ¡ ¡ |  ||¡ W d Q R X W d Q R X W d |t_X d S )	Nc               S   s   dd„ S )Nc             S   s   | S )Nr   )Úxr   r   r   Ú<lambda>  ó    zJPydocDocTest.test_help_output_redirect.<locals>.<lambda>.<locals>.<lambda>r   r   r   r   r   r     r‚   z8PydocDocTest.test_help_output_redirect.<locals>.<lambda>)r,   ztest.pydoc_modz9
        Help on module test.pydoc_mod in test:

        ÚstdoutÚstderrr   )r\   r   rn   ÚmaxDiffr   ÚHelperr9   r   ÚlstripÚtextwrapÚdedentr	   ÚhelpÚgetvaluer!   r]   rT   rU   rK   )rF   Zold_patternZgetpager_oldZgetpager_newÚbufÚhelperZunusedrZ   r*   Zhelp_headerZexpected_help_patternr,   r%   rM   r^   r   r   r   Útest_help_output_redirect	  s0    



$z&PydocDocTest.test_help_output_redirectc          	   C   s^   t dddgdd}tƒ }t |¡ W d Q R X | ¡ }|  d|¡ |  d|¡ |  d|¡ d S )	NÚNTÚabcÚdefT)ÚrenameZ_1Ú_replaceÚ_asdict)r   r
   r   rŠ   r‹   rf   )rF   r   Úhelp_ioÚhelptextr   r   r   Ú!test_namedtuple_public_underscore1  s    z.PydocDocTest.test_namedtuple_public_underscorec          
   C   s‚   |   tt¡ xpdD ]h}ttd|d8}|dkr@td |¡|d td|d td|d W d Q R X t ti ¡}|  |d	¡ qW d S )
N)z
ISO-8859-1zUTF-8Úw)ÚencodingzUTF-8z#coding: {})Úfileu   """line 1: hÃ©zline 2: hi"""u   line 1: hÃ©)	Ú
addCleanupr   r   ÚopenÚprintÚformatr   ÚsynopsisrK   )rF   r™   ZscriptrŸ   r   r   r   Útest_synopsis:  s    
zPydocDocTest.test_synopsisc             C   s.   t j ¡ d }t j}t |¡}|  ||¡ d S )Nr   )r0   r   Ú
splitlinesÚ
__cached__r   rŸ   rK   )rF   rx   ÚfilenamerŸ   r   r   r   Útest_synopsis_sourcelessE  s    
z%PydocDocTest.test_synopsis_sourcelessc          
   C   sŠ   t j ¡ v}tj |d¡}tj |¡}t	|dƒ}| 
d¡ W d Q R X t |¡ t |i ¡}|  |¡ t |i ¡}|  |¡ W d Q R X d S )Nzfoomod42.pyr˜   zfoo = 1)ÚtestÚsupportÚtemp_cwdr0   r1   ÚjoinÚ	importlibÚutilÚcache_from_sourcerœ   ÚwriteÚ
py_compiler7   r   rŸ   ÚassertIsNone)rF   Útest_dirÚ	init_pathZcached_pathÚfobjrŸ   Zsynopsis_cachedr   r   r   Ú"test_synopsis_sourceless_empty_docN  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)rK   r   Zsplitdoc)rF   Zexample_stringr   r   r   Útest_splitdoc_with_descriptionZ  s    z+PydocDocTest.test_splitdoc_with_descriptionc             C   s@   t  ¡ }|  t  |j¡¡ |  t  tj¡¡ |  t  d¡¡ d S )NzI am not a method)r   ZDocÚ
assertTrueZ_is_some_methodÚfailÚintÚ__add__ÚassertFalse)rF   r+   r   r   r   Útest_is_object_or_method_  s    z%PydocDocTest.test_is_object_or_methodc          	   C   s*   t j ¡ }|  t |¡¡ W d Q R X d S )N)r¥   r¦   r§   r¸   r   Ú	ispackage)rF   r¯   r   r   r   Ú test_is_package_when_not_packageh  s    z-PydocDocTest.test_is_package_when_not_packagec          	   C   sP   t j ¡ <}tj |d¡}t|dƒ ¡  |  t	 
|¡¡ t |¡ W d Q R X d S )Nz__init__.pyr˜   )r¥   r¦   r§   r0   r1   r¨   rœ   Úcloser´   r   rº   Úremove)rF   r¯   r°   r   r   r   Útest_is_package_when_is_packagel  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   )rF   r   r   r   Úmethod_returning_truez  s    zEPydocDocTest.test_allmethods.<locals>.TestClass.method_returning_trueN)r   r   r   r¿   r   r   r   r   Ú	TestClassy  s   rÀ   r¿   r   Ú	__class__Ú__subclasshook__Ú__init_subclass__)	ÚobjectÚdictÚvarsr¿   rÂ   rÃ   r   Z
allmethodsZassertDictEqual)rF   rÀ   rx   Úmethodsr   r   r   Útest_allmethodss  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   )rF   Z	aboveThisr   r   r   ÚtkraiseŽ  s    z3PydocDocTest.test_method_aliases.<locals>.A.tkraisec             S   s   dS )zReturn sizeNr   )rF   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   rq     s   
rq   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   )rF   ZtagOrIdZcnfÚkwr   r   r   Úitemconfigure”  s    z9PydocDocTest.test_method_aliases.<locals>.B.itemconfigure)N)r   r   r   rÌ   Z
itemconfigrÊ   Zb_sizer   )rq   r   r   rr   “  s   
rr   z.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   re   r6   r8   rK   r   r'   )rF   rr   r+   r   )rq   r   Útest_method_aliasesŒ  s    
%
(z PydocDocTest.test_method_aliases)"r   r   r   r…   ÚunittestÚskipIfrl   ÚflagsÚoptimizeÚhasattrrS   r   r[   r_   rg   rj   rk   ro   rs   ry   r|   r}   r   rŽ   r—   r    r¤   r²   r³   r¹   r»   r¾   rÈ   rÍ   r   r   r   r   rQ   £  sJ   
	
$		rQ   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 )N)r0   Úmkdirr   r¯   r›   r   r©   Úinvalidate_caches)rF   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 }x`|D ]X\}}t|d	ƒ}| d
  |¡¡ W d Q R X t|td 	d¡}t
||f }|  ||¡ qJW d S )NZtestmod_xyzzy)Úi_am_not_herer×   )ztest.i_am_not_here_eitherztest.i_am_not_here_either)ztest.i_am_not_here.neither_am_iztest.i_am_not_herezi_am_not_here.{}r×   ztest.{}Úpyr˜   z
import {}
)Z
PYTHONPATHrt   )rž   r0   r1   r¨   r   Úextseprœ   r¬   r&   ÚdecodeÚbadimport_patternrK   )	rF   ÚmodnameZ	testpairsZsourcefnZimportstringZexpectedinmsgÚfrM   rx   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 Q R X | jtgd¦ t	ƒ "}t
ƒ }t d¡ W d Q R X W d Q R X |  | ¡ d¡ |  | ¡ d¡ t	ƒ "}t
ƒ }t d¡ W d Q R X W d Q R X |  | ¡  ¡ d¡ |  | ¡ d¡ W d Q R X d S )	NZ	syntaxerrÚ__init__rØ   r˜   zinvalid python syntax = $1
)r1   Zxyzzyr   )r0   r1   r¨   r   rÔ   rÙ   rœ   r¬   rI   r
   r   r   ÚaproposrK   r‹   r!   )rF   ÚpkgdirZ	badsyntaxrÝ   r$   r%   r   r   r   Útest_apropos_with_bad_package  s     
z-PydocImportTest.test_apropos_with_bad_packagec             C   sš   t j td¡| _t  | jd¡ |  t j| j¡ | jtgd4 t	ƒ "}t
ƒ }t d¡ W d Q R X W d Q R X W d Q R X |  | ¡ d¡ |  | ¡ d¡ d S )NZ
unreadabler   )r1   ZSOMEKEYr   )r0   r1   r¨   r   Zunreadable_dirrÔ   r›   ÚrmdirrI   r
   r   r   rà   rK   r‹   )rF   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 Q R X t	 
t  	|¡j¡}z^t  ||t	j @ ¡ | jtgd" tƒ }t d¡ W d Q R X W d Q R X |  d| ¡ ¡ W d t  ||¡ X d S )NZwalkpkgz__init__.pyr˜   zfoo = 1)r1   r   )r0   r1   r¨   r   rÔ   r›   r   rœ   r¬   ÚstatÚS_IMODEÚst_modeÚchmodÚS_IEXECrI   r
   r   rà   rf   r‹   )rF   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 Q R X | jtgdp tt	jƒ}t	j 
dt¡ z@|  td	¡ dd l}W d Q R X |  d
d¡}d}|  ||¡ W d |t	jd d …< X W d Q R X d S )NÚtest_error_packagez__init__.pyZwtrt   )r™   zraise ValueError("ouch")
)r1   r   Zouchzsearch?key=test_error_packagezPydoc: Search Resultsz8<a href="test_error_package.html">test_error_package</a>)r0   r1   r¨   r   rÔ   rœ   r¬   rI   Útuplerl   ÚinsertZassertRaisesRegexÚ
ValueErrorrë   rN   rf   )rF   rá   Z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 )NrR   é   é   )r,   Úmodules)r   r   r†   r‹   r!   Úlenr¡   ZassertGreaterEqual)	rF   Znum_header_linesZnum_module_lines_minZnum_footer_linesrx   r,   r   rM   Z	num_linesr   r   r   Útest_modulesV  s    zPydocImportTest.test_modulesc          	   C   sH   d}t ƒ }tj|d}tƒ }|dƒ W d Q R X | ¡ }|  ||¡ d S )Nzpydoc - )r,   zmodules pydoc)r   r   r†   r
   r‹   rf   )rF   rx   r,   r   r•   rM   r   r   r   Útest_modules_searchf  s    z#PydocImportTest.test_modules_searchz+some buildbots are not cooperating (#20128)c          	   C   sL   d}t ƒ }tj|d}tƒ }|dƒ W d Q R X | ¡ }|  | |¡¡ d S )Nzgc - )r,   zmodules garbage)r   r   r†   r
   r‹   r´   Ú
startswith)rF   rx   r,   r   r•   rM   r   r   r   Útest_modules_search_builtins  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assertIsNotrK   r   Ú__spec__)rF   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               @   st   e Zd Zdd„ Zdd„ Zdd„ Z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dS )ÚTestDescriptionsc             C   s&   ddl m} t |¡}|  d|¡ d S )Nr   )Úpydocfodderrý   )r¥   rý   r   re   rf   )rF   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 classN)r   r   r   r   r   r   r   r   ÚC‘  s    rÿ   zclass CzC in module %s object)rK   r   Zdescriber   rf   re   )rF   rÿ   Úcrx   r   r   r   Ú
test_class  s    zTestDescriptions.test_classc             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 )Nr   )r  r€   r   r   r   Úfooš  s    z/TestDescriptions.test_typing_pydoc.<locals>.fooÚTc               @   s   e Zd ZdS )z-TestDescriptions.test_typing_pydoc.<locals>.CN)r   r   r   r   r   r   r   rÿ   ž  s    rÿ   éÿÿÿÿz?ffoooo(data: List[Any], x: int) -> Iterator[Tuple[int, Any]]rR   z2class CC(collections.abc.Mapping, typing.Generic))ÚtypingZListZAnyr¶   ÚIteratorZTupleZTypeVarZGenericÚMappingru   rK   r   re   r¡   )rF   r  r  rÿ   r   r   r   Útest_typing_pydoc™  s    
"
"z"TestDescriptions.test_typing_pydocc          	   C   s„   xPdD ]H}|   t |¡¡ yt |¡ W q tk
rL   |  d |¡¡ Y qX qW x,dD ]$}|  t |¡¡ |  ttj|¡ qXW d S )N)ru   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locatere   ÚImportErrorrµ   rž   r®   ÚassertRaises)rF   Únamer   r   r   Útest_builtin¥  s    

zTestDescriptions.test_builtinc             C   s"   t  t  | ¡¡}| d¡}|d S )Nr   rR   )r   Zplainre   Úsplit)Úor;   Úlinesr   r   r   Ú_get_summary_line¶  s    
z"TestDescriptions._get_summary_linec             C   s   |   |  tjj¡d¡ d S )Nzwrap(self, text))rK   r  rˆ   ÚTextWrapperÚwrap)rF   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, /))rK   r  Ú_pickleÚPicklerÚdump)rF   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ˆ   r  rK   r  r  )rF   Útr   r   r   Útest_bound_python_methodÈ  s    z)TestDescriptions.test_bound_python_methodc             C   s~   t ddddgƒ}t |¡}|  | d¡| d¡¡ |  | d¡| d¡¡ G dd„ dƒ}G dd„ dƒ}t |¡ t |¡ d S )	NÚPersonZnicknameZ	firstnameZagegroupc               @   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>.NonHashableFieldsN)r   r   r   r  r   r   r   r   ÚNonHashableFieldsÖ  s   r  )r   r   re   Z
assertLessÚindex)rF   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   r  r  rK   r  r  )rF   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))rK   r  r0   rå   )rF   r   r   r   Útest_module_level_callableå  s    z+TestDescriptions.test_module_level_callableN)r   r   r   rþ   r  r
  r  Ústaticmethodr  r  r   r  r  r!  r#  r$  r   r   r   r   rü   ˆ  s   	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 ¡ }d}x4|jrht d¡ |jr6t ¡ | |kr6| 	¡  P q6W |  
|jd ¡ d S )Nc             S   s   d| |f }|S )Nzthe URL sent was: (%s, %s)r   )rL   Zcontent_typer;   r   r   r   Úmy_url_handlerñ  s    z3PydocServerTest.test_server.<locals>.my_url_handlerz0.0.0.0r   )ZhostnameZportr`   g{®Gáz„?)r   Z_start_serverrf   Z	docserverZaddressÚtimeZ	monotonicZservingZsleepÚstoprK   Úerror)rF   r'  ZserverthreadZ	starttimeZtimeoutr   r   r   Útest_serverî  s    
zPydocServerTest.test_serverN)r   r   r   r   r+  r   r   r   r   r&  ë  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 )Nrq   r   rr   Úfoobar)r   rJ   r  Ú	TypeError)rF   rÝ   r   r   r   Útest_content_type_err  s    z)PydocUrlHandlerTest.test_content_type_errc             C   st   ddddddddd	d
ddg}|   ¡ F x|D ]\}}|  ||¡ q,W tj}d| }d| }|  ||¡ W d Q R X d S )N)r   zPydoc: Index of Modules)zget?key=zPydoc: Index of Modules)r   zPydoc: Index of Modules)ZtopicszPydoc: Topics)ÚkeywordszPydoc: Keywords)r   zPydoc: module pydoc)zget?key=pydoczPydoc: module pydoc)zsearch?key=pydoczPydoc: Search Results)ztopic?key=defzPydoc: KEYWORD def)ztopic?key=STRINGSzPydoc: TOPIC STRINGS)r-  zPydoc: Error - foobar)zgetfile?key=foobarz!Pydoc: Error - getfile?key=foobarzPydoc: getfile zgetfile?key=)rI   rN   Ústringr    )rF   ZrequestsrL   r>   r1   r   r   r   Útest_url_requests  s&    
z%PydocUrlHandlerTest.test_url_requestsN)r   r   r   r   r/  r2  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 )N)rK   Úsortedr   r†   r0  ÚkeywordÚkwlist)rF   r   r   r   Útest_keywords*  s    zTestHelper.test_keywordsN)r   r   r   r7  r   r   r   r   r3  )  s   r3  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ƒoše 	¡ d¡d	d
„ ƒƒZe ejjdkd¡e eedƒoÐe 	¡ d¡dd„ ƒƒZdd„ ZdS )ÚPydocWithMetaClassesrR   z)Docstrings are omitted with -O2 and aboverS   z1trace function introduces __locals__ unexpectedlyc             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   r;  5  s    zIPydocWithMetaClasses.test_DynamicClassAttribute.<locals>.Meta.__getattr__)r   r   r   r;  Ú__classcell__r   r   )rÁ   r   ÚMeta4  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   )rF   r   r   r   r9  :  s    z?PydocWithMetaClasses.test_DynamicClassAttribute.<locals>.DA.hamN)r   r   r   ÚtypesÚDynamicClassAttributer9  r   r   r   r   ÚDA9  s   r@  )Ú	metaclassc             s   s   | ]}|rd | ndV  qdS )z	
 |      r   Nr   )r   r   r   r   r   r   =  s   zBPydocWithMetaClasses.test_DynamicClassAttribute.<locals>.<genexpr>)r,   rR   )Útyperì   Úexpected_data_docstringsr   r   r†   Ú!expected_dynamicattribute_patternr   r‹   r!   rK   )rF   r=  r@  r]   r,   r   r^   rM   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   ddddgS )NrÁ   r   r   ÚLIFEr   )Úclsr   r   r   Ú__dir__M  s    zPPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.Meta.__dir__c                s   |dkrdS t ƒ  |¡S )NrF  rp   )r:  Z_Meta__getattr)rF   r  )rÁ   r   r   r;  O  s    zTPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.Meta.__getattr__)r   r   r   rH  r;  r<  r   r   )rÁ   r   r=  L  s   r=  c               @   s   e Zd ZdS )zIPydocWithMetaClasses.test_virtualClassAttributeWithOneMeta.<locals>.ClassN)r   r   r   r   r   r   r   ÚClassS  s   rI  )rA  )r,   )	rB  r   r   r†   Ú"expected_virtualattribute_pattern1r   r‹   r!   rK   )rF   r=  rI  r,   r   r^   rM   r   r   r   Ú%test_virtualClassAttributeWithOneMetaG  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   ddddgS )NrÁ   r   r   ra   r   )rG  r   r   r   rH  b  s    zQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1.__dir__c                s   |dkrdS t ƒ  |¡S )Nra   r`   )r:  r;  )rF   r  )rÁ   r   r   r;  d  s    zUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta1.__getattr__)r   r   r   rH  r;  r<  r   r   )rÁ   r   ÚMeta1a  s   rL  c                   s$   e Zd Zdd„ Z‡ fdd„Z‡  ZS )zIPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2c             S   s   ddddgS )NrÁ   r   r   Útwor   )rG  r   r   r   rH  i  s    zQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2.__dir__c                s   |dkrdS t ƒ  |¡S )NrM  rR   )r:  r;  )rF   r  )rÁ   r   r   r;  k  s    zUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta2.__getattr__)r   r   r   rH  r;  r<  r   r   )rÁ   r   ÚMeta2h  s   rN  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ddddgˆ  | ¡ ˆ | ¡ ƒƒƒS )NrÁ   r   r   Úthree)Úlistr4  ÚsetrH  )rG  )rL  rN  r   r   rH  p  s    zQPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3.__dir__c                s   |dkrdS t ƒ  |¡S )NrO  rò   )r:  r;  )rF   r  )rÁ   r   r   r;  t  s    zUPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Meta3.__getattr__)r   r   r   rH  r;  r<  r   )rL  rN  )rÁ   r   ÚMeta3o  s   rR  c               @   s   e Zd ZdS )zJPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Class1N)r   r   r   r   r   r   r   ÚClass1x  s   rS  )rA  c               @   s   e Zd ZdS )zJPydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta.<locals>.Class2N)r   r   r   r   r   r   r   ÚClass2z  s   rT  F)r,   )
rB  r   r   r†   Ú"expected_virtualattribute_pattern2r   r‹   r!   rK   Ú"expected_virtualattribute_pattern3)rF   rR  rS  rT  Zfail1Zfail2r,   r   Zexpected_text1Zresult1Zexpected_text2Zresult2r   )rL  rN  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   ddddgS )NrÁ   r   ÚmissingÚherer   )rG  r   r   r   rH    s    z6PydocWithMetaClasses.test_buggy_dir.<locals>.M.__dir__N)r   r   r   rH  r   r   r   r   ÚM  s   rZ  c               @   s   e Zd ZdZdS )z.PydocWithMetaClasses.test_buggy_dir.<locals>.Czpresent!N)r   r   r   rY  r   r   r   r   rÿ   ’  s   rÿ   )rA  )r,   )	rB  r   r   r†   Ú!expected_missingattribute_patternr   r‹   r!   rK   )rF   rZ  rÿ   r,   r   r^   rM   r   r   r   Útest_buggy_dirŠ  s    z#PydocWithMetaClasses.test_buggy_dirc          	   C   s4   t ƒ }t d¡ W d Q R X | ¡ }|  d|¡ d S )Nz	enum.Enumz
class Enum)r
   r   rŠ   r‹   rf   )rF   r•   r–   r   r   r   Útest_resolve_false›  s    z'PydocWithMetaClasses.test_resolve_falseN)r   r   r   rÎ   rÏ   rl   rÐ   rÑ   rÒ   rS   rE  rK  rW  r\  r]  r   r   r   r   r8  .  s"   +r8  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   )ÚtempfileZTemporaryDirectoryr  Úargv0dirr0   r1   r¨   Úargv0r›   ZcleanupÚgetcwdÚ
abs_curdirÚcurdirÚcurdir_spellings)rF   Ztmpdirrc  r   r   r   rÖ   ¦  s    zTestInternalUtilities.setUpNc             C   s   |d kr| j }t ||¡S )N)ra  r   Ú_get_revised_path)rF   Ú
given_pathra  r   r   r   rf  ®  s    z'TestInternalUtilities._get_revised_pathc             C   s@   t j ¡ }x0| jD ]&}x t| |¡ƒD ]}| |¡ q&W qW |S )N)rl   r1   Úcopyre  ÚrangeÚcountr½   )rF   Ú
clean_pathÚspellingÚ__r   r   r   Ú_get_starting_pathµ  s
    
z(TestInternalUtilities._get_starting_pathc             C   s*   |   ¡ }| jg| }|  |  |¡|¡ d S )N)rn  rc  rK   rf  )rF   rk  Ú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 )N)rn  rc  r`  rK   rf  )rF   rk  ro  Ú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)ra  )rf  r   r    )rg  )rF   r   r   rf  Ì  s    z\TestInternalUtilities.test_sys_path_adjustment_protects_pydoc_dir.<locals>._get_revised_path)rn  r`  rc  rK   )rF   rf  rk  rq  ro  rr  r   )rF   r   Ú+test_sys_path_adjustment_protects_pydoc_dirË  s    zATestInternalUtilities.test_sys_path_adjustment_protects_pydoc_dirc          
   C   s    |   ¡ }x’| jD ]ˆ}| j|dr |g| }|  |  |¡¡ ||g }|  |  |¡¡ | jg| }|  |  |¡¡ || jg }|  |  |¡¡ W d Q R X qW d S )N)Zcurdir_spelling)rn  re  ZsubTestr®   rf  r`  )rF   rk  rl  Zleading_curdirZtrailing_curdirrq  rr  r   r   r   Ú5test_sys_path_adjustment_when_curdir_already_includedÖ  s    

zKTestInternalUtilities.test_sys_path_adjustment_when_curdir_already_included)N)
r   r   r   rÖ   rf  rn  rp  rs  rt  ru  r   r   r   r   r^  ¤  s   
	r^  c            
   C   s,   zt j ttttttt	t
¡ W d tƒ  X d S )N)r¥   r¦   Zrun_unittestrQ   rÓ   rü   r&  r,  r3  r8  r^  r   r   r   r   r   Ú	test_mainå  s    
rv  Ú__main__)Pr0   rl   rO   Úimportlib.utilr©   rT   r   r­   r5  r  rH   r6   rå   r1  r_  Ztest.supportr¥   r(  r>  r  rÎ   Zurllib.parserV   Z	xml.etreerh   Zxml.etree.ElementTreerˆ   Z	threadingÚior   Úcollectionsr   Ztest.support.script_helperr   r   r   r   r   r	   r
   r   r   r   r   r   r¦   ZHAVE_DOCSTRINGSrC  r!   r\   rì   r]   rX   rY   r   Úlineseprv   rÛ   rD  rJ  rU  rV  r[  r&   r.   r5   r9   r?   ZTestCaser@   rQ   rÓ   rü   r&  r,  r3  r8  r^  rv  r   r   r   r   r   Ú<module>   s‚   ,
T
{
			
		  N c%vA
