a
    	3j                     @   s~   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 dd Zdd	 ZG d
d dejZdd ZdS )    N)Message)compat32)load_package_tests)__file__c                  G   s   t tjtg| R  S N)r   ospathdirnamer   )args r   T/www/server/python_manager/versions/3.9.10/lib/python3.9/test/test_email/__init__.py
load_tests   s    r   c                 O   s.   t jt jtd| }t|g|R i |S )Ndata)r   r   joinr	   landmarkopen)filenamer
   kwsr   r   r   r   openfile   s    r   c                       sl   e Zd ZdZeZeZ fddZe	j
jZdd ZdddZddd	Zd
d Zdd Zdd Zdd Z  ZS )TestEmailBaseNc                    s$   t  j|i | | t| j d S r   )super__init__ZaddTypeEqualityFuncbytesassertBytesEqual)selfr
   kw	__class__r   r   r   !   s    zTestEmailBase.__init__c                 C   s<   t | }tj|| jdW  d    S 1 s.0    Y  d S N)policy)r   emailZmessage_from_filer   )r   r   fpr   r   r   _msgobj(   s    
zTestEmailBase._msgobjc                 C   s,   |d u r| j }|d u r| j}tj|||dS r   )r   messager    Zmessage_from_string)r   stringr#   r   r   r   r   _str_msg,   s
    zTestEmailBase._str_msgc                 C   s,   |d u r| j }|d u r| j}tj|||dS r   )r   r#   r    Zmessage_from_bytes)r   Z
bytestringr#   r   r   r   r   
_bytes_msg3   s
    zTestEmailBase._bytes_msgc                 C   s   | j | jdS r   )r#   r   )r   r   r   r   _make_message:   s    zTestEmailBase._make_messagec                 C   s   dd |j ddD S )Nc                 S   s   g | ]}t |qS r   )repr).0xr   r   r   
<listcomp>>       z-TestEmailBase._bytes_repr.<locals>.<listcomp>T)keepends)
splitlines)r   br   r   r   _bytes_repr=   s    zTestEmailBase._bytes_reprc                 C   s   |  | || | dS )z@Our byte strings are really encoded strings; improve diff outputN)assertEqualr0   )r   firstsecondmsgr   r   r   r   @   s    zTestEmailBase.assertBytesEqualc                 C   sH   |  t|t|| tt|D ] }| || || d| q"d S )Nzitem {})r1   lenrangeZassertIsInstanceformat)r   actualZexpectedir   r   r   assertDefectsEqualD   s
    z TestEmailBase.assertDefectsEqual)NN)NN)__name__
__module____qualname__ZmaxDiffr   r   r   r#   r   unittestTestCaser1   ZndiffAssertEqualr"   r%   r&   r'   r0   r   r:   __classcell__r   r   r   r   r      s   

r   c                 C   s  i }t t}| j D ]\}}|drt|dszi }|D ]8}t|dsP|f}ddd |D dd}|||< q<|}|||dd	 d
 < d
|v r||	d
d d
  
| qi }|D ]}||vrtd|q|D ]}||vrtd|q| j D ]\}}| D ]\}	}
||	rd|t|	d  }|
 D ]N\}}t|drf||fdd}n||fdd}|d | }||_|||< qBqq| D ]\}}t| || q| S )a2  A test method parameterization class decorator.

    Parameters are specified as the value of a class attribute that ends with
    the string '_params'.  Call the portion before '_params' the prefix.  Then
    a method to be parameterized must have the same prefix, the string
    '_as_', and an arbitrary suffix.

    The value of the _params attribute may be either a dictionary or a list.
    The values in the dictionary and the elements of the list may either be
    single values, or a list.  If single values, they are turned into single
    element tuples.  However derived, the resulting sequence is passed via
    *args to the parameterized test function.

    In a _params dictionary, the keys become part of the name of the generated
    tests.  In a _params list, the values in the list are converted into a
    string by joining the string values of the elements of the tuple by '_' and
    converting any blanks into '_'s, and this become part of the name.
    The  full name of a generated test is a 'test_' prefix, the portion of the
    test function name after the  '_as_' separator, plus an '_', plus the name
    derived as explained above.

    For example, if we have:

        count_params = range(2)

        def count_as_foo_arg(self, foo):
            self.assertEqual(foo+1, myfunc(foo))

    we will get parameterized test methods named:
        test_foo_arg_0
        test_foo_arg_1
        test_foo_arg_2

    Or we could have:

        example_params = {'foo': ('bar', 1), 'bing': ('bang', 2)}

        def example_as_myfunc_input(self, name, count):
            self.assertEqual(name+str(count), myfunc(name, count))

    and get:
        test_myfunc_input_foo
        test_myfunc_input_bing

    Note: if and only if the generated test name is a valid identifier can it
    be used to select the test individually from the unittest command line.

    The values in the params dict can be a single value, a tuple, or a
    dict.  If a single value of a tuple, it is passed to the test function
    as positional arguments.  If a dict, it is a passed via **kw.

    Z_paramskeys__iter___c                 s   s   | ]}t |V  qd S r   )str)r)   vr   r   r   	<genexpr>   r,   zparameterize.<locals>.<genexpr> NiZ_as_r   zNo tester found for {}zNo params found for {}Ztest_c                 S   s   t | |f i |S r   getattrr   nameparamsr   r   r   <lambda>   s    zparameterize.<locals>.<lambda>c                 S   s   t | || S r   rH   rJ   r   r   r   rM      s    )collectionsdefaultdictlist__dict__itemsendswithhasattrr   replacesplitappend
ValueErrorr7   
startswithr5   r;   setattr)clsZ
paramdictsZtestersrK   attrdr*   nZ	testfuncsZ
paramsnameZ
paramsdictZtestnamerootZ	paramnamerL   testZtestnamekeyvaluer   r   r   parameterizeK   sH    5




rb   )r   r>   rN   r    Zemail.messager   Zemail._policybaser   Ztest.supportr   Ztest.test_emailr   r   r   r   r?   r   rb   r   r   r   r   <module>   s   4