a
    xda                     @   sx  d dl Z d dl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 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eddd Zdd ZG dd dZdd  Zed!d"ddd#d$d% Zd&d' Zd(d) Zed*ed+dd,Zd-d. ZG d/d0 d0Zd1d2 Zed3dd4dd5d6 Zed3dd4dd7d8 Zed3dddd9d: Z ed3dddd;d< Z!d=d> Z"d?d@ Z#dS )A    N   )TrioDeprecationWarningwarn_deprecated
deprecateddeprecated_alias   )module_with_deprecationsc                 C   s   t d t dt | S )Nalwaysignore)warningssimplefilterResourceWarning)Zrecwarn r   Q/var/www/html/Ranjet/env/lib/python3.9/site-packages/trio/tests/test_deprecate.pyrecwarn_always   s    
r   c                  C   s   t t  j} | j| jfS N)inspectgetframeinfocurrentframef_backfilenamelineno)infor   r   r   _here   s    r   c                 C   s   dd }|  t  \}}t| dks(J | t}d|jjd v sFJ d|jjd v sZJ d|jjd v snJ d|jjd v sJ |j|ksJ |j|d ksJ d S )	Nc                   S   s   t ddddd d S )NZ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popr   messageargsr   r   )r   r    r   r   gotr   r   r   test_warn_deprecated   s    

r'   c                 C   sj   t ddd d d t| dks J | t}d|jjd v s>J d|jjd v sRJ d|jjd v sfJ d S )	Nr   1.3r   r   zwater is deprecatedr   zno replacementzTrio 1.3)r   r"   r#   r   r$   r%   r   r&   r   r   r   (test_warn_deprecated_no_instead_or_issue.   s    
r*   c                    sR    fdd}dd  t  \}}|  | t}|j|ks<J |j|d ksNJ d S )Nc                      s
      d S r   r   r   nested2r   r   nested19   s    z0test_warn_deprecated_stacklevel.<locals>.nested1c                   S   s   t dddddd d S )Nxr(      y   )r   r   
stacklevelr   r   r   r   r   r,   <   s    z0test_warn_deprecated_stacklevel.<locals>.nested2r   )r   r#   r   r   r   )r   r-   r   r   r&   r   r+   r   test_warn_deprecated_stacklevel8   s    

r3   c                   C   s   d S r   r   r   r   r   r   oldF   s    r4   c                   C   s   d S r   r   r   r   r   r   newJ   s    r5   c                 C   sF   t tddtd | t}d|jjd v s.J d|jjd v sBJ d S )N1.0r   r   z test_deprecate.old is deprecatedr   ztest_deprecate.new instead)r   r4   r5   r#   r   r$   r%   r)   r   r   r   test_warn_deprecated_formattingN   s    
r7   1.5{   r   c                   C   s   dS )Nr1   r   r   r   r   r   deprecated_oldU   s    r:   c                 C   sl   t  dksJ | t}d|jjd v s,J d|jjd v s@J d|jjd v sTJ d|jjd v shJ d S )Nr1   z+test_deprecate.deprecated_old is deprecatedr   r8   ztest_deprecate.newz
issues/123)r:   r#   r   r$   r%   r)   r   r   r   test_deprecated_decoratorZ   s    
r;   c                   @   s"   e Zd Zedddddd ZdS )Foor6   r9   Zcryingr   c                 C   s   dS )Nr/   r   selfr   r   r   methodd   s    z
Foo.methodN)__name__
__module____qualname__r   r?   r   r   r   r   r<   c   s   r<   c                 C   s8   t  }| dksJ | t}d|jjd v s4J d S )Nr/   z'test_deprecate.Foo.method is deprecatedr   )r<   r?   r#   r   r$   r%   )r   fr&   r   r   r    test_deprecated_decorator_methodi   s    
rD   r   z	the thing)thingr   r   c                   C   s   dS )NH   r   r   r   r   r   deprecated_with_thingp   s    rG   c                 C   s0   t  dksJ | t}d|jjd v s,J d S )NrF   zthe thing is deprecatedr   )rG   r#   r   r$   r%   r)   r   r   r   -test_deprecated_decorator_with_explicit_thingu   s    
rH   c                   C   s   dS )Nnew hotnessr   r   r   r   r   new_hotness{   s    rJ   old_hotness1.23r   c                 C   s   t  dksJ | t}d|jjd v s,J d|jjd v s@J d|jjd v sTJ d|jjd v shJ dt jv svJ dt jv sJ dt jv sJ d S )	NrI   z(test_deprecate.old_hotness is deprecatedr   rL   z"test_deprecate.new_hotness insteadzissues/1z.. deprecated:: 1.23zissues/1>`__)rK   r#   r   r$   r%   __doc__r)   r   r   r   test_deprecated_alias   s    
rO   c                   @   s$   e Zd Zdd ZededddZdS )Aliasc                 C   s   dS )Nnew hotness methodr   r=   r   r   r   new_hotness_method   s    zAlias.new_hotness_methodzAlias.old_hotness_methodz3.21r   rM   N)r@   rA   rB   rR   r   old_hotness_methodr   r   r   r   rP      s   rP   c                 C   sH   t  }| dksJ | t}|jjd }d|v s8J d|v sDJ d S )NrQ   r   z5test_deprecate.Alias.old_hotness_method is deprecatedz/test_deprecate.Alias.new_hotness_method instead)rP   rS   r#   r   r$   r%   )r   objr&   msgr   r   r   test_deprecated_alias_method   s    
rV   z2.1hic                   C   s   dS zHello!Nr   r   r   r   r   docstring_test1   s    rY   c                   C   s   dS rX   r   r   r   r   r   docstring_test2   s    rZ   c                   C   s   dS rX   r   r   r   r   r   docstring_test3   s    r[   c                   C   s   dS rX   r   r   r   r   r   docstring_test4   s    r\   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

)rY   rN   rZ   r[   r\   r   r   r   r   !test_deprecated_docstring_munging   s     r]   c                 C   s  t jdksJ t| dksJ t \}}t jdks6J | t}|j|ksNJ |j|d ks`J d|j	j
d v stJ d|j	j
d v sJ d|j	j
d v sJ d|j	j
d v sJ t jd	ksJ | t}d
|j	j
d v sJ tt t j W d    n1 s0    Y  d S )NrW   r   Zvalue1r   zmodule_with_deprecations.dep1zTrio 1.1r!   zvalue1 insteadZvalue2zinstead-string instead)r   Zregularr"   r   Zdep1r#   r   r   r   r$   r%   Zdep2pytestZraisesAttributeErrorZasdf)r   r   r   r&   r   r   r   test_module_with_deprecations   s     


r`   )$r^   r   r   Z
_deprecater   r   r   r    r   Zfixturer   r   r'   r*   r3   r4   r5   r7   r:   r;   r<   rD   rG   rH   rJ   rK   rO   rP   rV   rY   rZ   r[   r\   r]   r`   r   r   r   r   <module>   sH   


	
		



*