a
    QIh                      @  s8  d dl mZ d dlZd dlZd dlmZ d dlZddlmZm	Z	m
Z
mZ ddlmZ ejddd	d
dZddddZdddddZdddddZdddddZddddZddddZdddddZe	dded d!dd"d#Zdddd$d%ZG d&d' d'Zdddd(d)Ze	d*d+ddd,d!dd-d.Zdddd/d0Zd1dd2d3Ze
d4ed5dd6Zdddd7d8ZG d9d: d:Z dddd;d<Z!e	d=dd>d ddd?d@Z"e	d=dd>d dddAdBZ#e	d=ddd dddCdDZ$e	d=ddd dddEdFZ%dddGdHZ&ddddIdJZ'dddKdLZ(dS )M    )annotationsN)
ModuleType   )TrioDeprecationWarning
deprecateddeprecated_aliaswarn_deprecated   )module_with_deprecationszpytest.WarningsRecorder)recwarnreturnc                 C  s   t d t dt | S )Nalwaysignore)warningssimplefilterResourceWarning)r    r   T/var/www/html/venv_bot_3.9/lib/python3.9/site-packages/trio/_tests/test_deprecate.pyrecwarn_always   s    
r   ztuple[str, int]r   c                  C  s:   t  } | d usJ | jd us"J t | j}|j|jfS N)inspectcurrentframef_backgetframeinfofilenamelineno)frameinfor   r   r   _here   s
    r   None)r   r   c                 C  s   dddd}|  t  \}}t| dks.J | t}t|jtsHJ d|jjd v s\J d|jjd v spJ d	|jjd v sJ d
|jjd v sJ |j|ksJ |j	|d ksJ d S )Nr    r   c                   S  s   t ddddd d S )Nice1.2r	   waterissueinsteadr   r   r   r   r   deprecated_thing$   s    z.test_warn_deprecated.<locals>.deprecated_thingr	   zice is deprecatedr   zTrio 1.2zwater instead	/issues/1)
r   lenpopDeprecationWarning
isinstancemessageWarningargsr   r   )r   r(   r   r   gotr   r   r   test_warn_deprecated#   s    

r2   c                 C  sz   t ddd d d t| dks J | t}t|jts:J d|jjd v sNJ d|jjd v sbJ d|jjd v svJ d S )	Nr#   1.3r$   r	   zwater is deprecatedr   zno replacementzTrio 1.3)r   r*   r+   r,   r-   r.   r/   r0   r   r1   r   r   r   (test_warn_deprecated_no_instead_or_issue4   s    
r5   c                   s^   dd fdd}dddd t  \}}|  | t}|j|ksHJ |j|d ksZJ d S )Nr    r   c                     s
      d S r   r   r   nested2r   r   nested1B   s    z0test_warn_deprecated_stacklevel.<locals>.nested1c                   S  s   t dddddd d S )Nxr3      y   )r%   r&   
stacklevelr'   r   r   r   r   r7   E   s    z0test_warn_deprecated_stacklevel.<locals>.nested2r	   )r   r+   r,   r   r   )r   r8   r   r   r1   r   r6   r   test_warn_deprecated_stacklevelA   s    

r>   c                   C  s   d S r   r   r   r   r   r   oldO   s    r?   c                   C  s   d S r   r   r   r   r   r   newS   s    r@   c                 C  sV   t tddtd | t}t|jts*J d|jjd v s>J d|jjd v sRJ d S )N1.0r	   r$   z test_deprecate.old is deprecatedr   ztest_deprecate.new instead)	r   r?   r@   r+   r,   r-   r.   r/   r0   r4   r   r   r   test_warn_deprecated_formattingW   s
    
rB   1.5{   r$   intc                   C  s   dS )Nr<   r   r   r   r   r   deprecated_old_   s    rF   c                 C  s|   t  dksJ | t}t|jts(J d|jjd v s<J d|jjd v sPJ d|jjd v sdJ d|jjd v sxJ d S )Nr<   z+test_deprecate.deprecated_old is deprecatedr   rC   ztest_deprecate.newz
issues/123)rF   r+   r,   r-   r.   r/   r0   r4   r   r   r   test_deprecated_decoratord   s    
rG   c                   @  s(   e Zd ZeddddddddZd	S )
FoorA   rD   Zcryingr$   rE   r   c                 C  s   dS )Nr:   r   selfr   r   r   methodo   s    z
Foo.methodN)__name__
__module____qualname__r   rK   r   r   r   r   rH   n   s   rH   c                 C  sH   t  }| dksJ | t}t|jts0J d|jjd v sDJ d S )Nr:   z'test_deprecate.Foo.method is deprecatedr   )rH   rK   r+   r,   r-   r.   r/   r0   )r   fr1   r   r   r    test_deprecated_decorator_methodt   s
    
rP   r"   z	the thing)thingr%   r&   c                   C  s   dS )NH   r   r   r   r   r   deprecated_with_thing|   s    rS   c                 C  s@   t  dksJ | t}t|jts(J d|jjd v s<J d S )NrR   zthe thing is deprecatedr   )rS   r+   r,   r-   r.   r/   r0   r4   r   r   r   -test_deprecated_decorator_with_explicit_thing   s    
rT   strc                   C  s   dS )Nnew hotnessr   r   r   r   r   new_hotness   s    rW   old_hotness1.23r%   c                 C  s   t  dksJ | t}t|jts(J d|jjd v s<J d|jjd v sPJ d|jjd v sdJ d|jjd v sxJ tt jtsJ dt jv sJ dt jv sJ dt jv sJ d S )	NrV   z(test_deprecate.old_hotness is deprecatedr   rY   z"test_deprecate.new_hotness insteadzissues/1z.. deprecated:: 1.23zissues/1>`__)	rX   r+   r,   r-   r.   r/   r0   __doc__rU   r4   r   r   r   test_deprecated_alias   s    
r\   c                   @  s*   e Zd ZddddZededddZd	S )
AliasrU   r   c                 C  s   dS )Nnew hotness methodr   rI   r   r   r   new_hotness_method   s    zAlias.new_hotness_methodzAlias.old_hotness_methodz3.21r	   rZ   N)rL   rM   rN   r_   r   old_hotness_methodr   r   r   r   r]      s   r]   c                 C  sX   t  }| dksJ | t}t|jts0J |jjd }d|v sHJ d|v sTJ d S )Nr^   r   z5test_deprecate.Alias.old_hotness_method is deprecatedz/test_deprecate.Alias.new_hotness_method instead)r]   r`   r+   r,   r-   r.   r/   r0   )r   objr1   msgr   r   r   test_deprecated_alias_method   s    
rc   z2.1hic                   C  s   dS zHello!Nr   r   r   r   r   docstring_test1   s    rf   c                   C  s   dS re   r   r   r   r   r   docstring_test2   s    rg   c                   C  s   dS re   r   r   r   r   r   docstring_test3   s    rh   c                   C  s   dS re   r   r   r   r   r   docstring_test4   s    ri   c                   C  s<   t jdksJ tjdksJ tjdks*J tjdks8J d S )NzHello!

.. deprecated:: 2.1
   Use hi instead.
   For details, see `issue #1 <https://github.com/python-trio/trio/issues/1>`__.

z0Hello!

.. deprecated:: 2.1
   Use hi instead.

znHello!

.. deprecated:: 2.1
   For details, see `issue #1 <https://github.com/python-trio/trio/issues/1>`__.

zHello!

.. deprecated:: 2.1

)rf   r[   rg   rh   ri   r   r   r   r   !test_deprecated_docstring_munging   s     rj   c                 C  sD  t jdksJ t| dksJ tt tu s.J t \}}t jdksFJ | t}t	|j
ts`J |j|ksnJ |j|d ksJ d|j
jd v sJ d|j
jd v sJ d|j
jd v sJ d|j
jd v sJ t jd	ksJ | t}t	|j
tsJ d
|j
jd v sJ tt t j W d    n1 s60    Y  d S )Nrd   r   Zvalue1r	   zmodule_with_deprecations.dep1zTrio 1.1r)   zvalue1 insteadZvalue2zinstead-string instead)r
   Zregularr*   typer   r   Zdep1r+   r,   r-   r.   r/   r   r   r0   Zdep2pytestZraisesAttributeErrorZasdf)r   r   r   r1   r   r   r   test_module_with_deprecations   s&    


rn   c                   C  s   t    tddd d d W d    n1 s.0    Y  t jtdd  tddd d d W d    n1 sl0    Y  t t" tddd d dd W d    n1 s0    Y  d S )NZfoobarr$   z6^foo is deprecated since Trio bar with no replacement$)matchT)r%   r&   Zuse_triodeprecationwarning)rl   Zdeprecated_callr   Zwarnsr,   r   r   r   r   r   test_warning_class  s    
..rq   ))
__future__r   r   r   typesr   rl   Z
_deprecater   r   r   r    r
   Zfixturer   r   r2   r5   r>   r?   r@   rB   rF   rG   rH   rP   rS   rT   rW   rX   r\   r]   rc   rf   rg   rh   ri   rj   rn   rq   r   r   r   r   <module>   sN   
	
*