U
    {h}                     @   sl   d dl Z d dlZd dlZddlmZmZmZmZmZ ddl	m
Z
mZ G dd dejZG dd dejZdS )	    N   )inferred_method_return_types"find_return_type_of_builtin_methodunsafe_compile_time_methodsis_safe_compile_time_methodbuiltin_scope)KNOWN_PYTHON_BUILTINS_VERSIONKNOWN_PYTHON_BUILTINSc                   @   s   e Zd Zdd ZdS )TestBuiltinReturnTypesc           	      C   s   t jdk}t D ]\}}tt|dkr*|nd}| D ]\}}t|j}t	||}|j
rd|krr|dd }|dkr~|}| |j| |r| t||| d|  q8| |jdd	| q8qd S )
N)   
   unicodestr[r   T.T)Zpyrex)sysversion_infor   itemsgetattrbuiltinsr   lookuptyper   Zis_builtin_type	partitionassertEqualname
assertTruehasattrZempty_declaration_code)	selfZlook_up_methods	type_namemethodsZpy_typemethod_nameZreturn_type_namebuiltin_typereturn_type r$   E/tmp/pip-unpacked-wheel-fhl22ezh/Cython/Compiler/Tests/TestBuiltin.py'test_find_return_type_of_builtin_method   s    

z>TestBuiltinReturnTypes.test_find_return_type_of_builtin_methodN)__name__
__module____qualname__r&   r$   r$   r$   r%   r
      s   r
   c                   @   s   e Zd Zdd Zdd ZdS )TestBuiltinCompatibilityc                 C   s|   t t}tjdkr|d tdd ttD }tjt	k rl|| }|rb| 
ddt|  | 
d | || d S )Nwin32ZWindowsErrorc                 s   s   | ]}|d kr|V  qdS ))__doc__
__loader__r'   __package____spec__Nr$   ).0r   r$   r$   r%   	<genexpr>,   s   zMTestBuiltinCompatibility.test_python_builtin_compatibility.<locals>.<genexpr>z=skipping test, older Python release found. Missing builtins: z, z*skipping test, older Python release found.)setr	   r   platformdiscard	frozensetdirr   r   r   ZskipTestjoinsortedZassertSetEqual)r   Zexpected_builtinsZruntime_builtinsZmissing_builtinsr$   r$   r%   !test_python_builtin_compatibility(   s    



z:TestBuiltinCompatibility.test_python_builtin_compatibilityc                 C   st   t  D ]f\}}| |t tt|}tt| }| |	| |D ]&}t||d}|dkrF| 
|| qFqFqdS )zValidate the table of builtin methods that are not safe for compile time evaluation
        against the table of known builtin methods (and their types).
        N)r   r   ZassertIsInstancer2   r   r   r8   r   ZassertFalse
differenceZassertIn)r   Zbuiltin_type_nameZunsafe_methodsr"   Zknown_methodsr!   Zbuiltin_methodr$   r$   r%    test_unsafe_compile_time_methods6   s    
z9TestBuiltinCompatibility.test_unsafe_compile_time_methodsN)r'   r(   r)   r9   r;   r$   r$   r$   r%   r*   '   s   r*   )r   r   ZunittestZBuiltinr   r   r   r   r   ZCoder   r	   ZTestCaser
   r*   r$   r$   r$   r%   <module>   s   