U
    H4f                     @   s`  d Z ddlZddlmZ ddlmZmZmZ ddlmZm	Z	 ddlm
Z
mZ ddlmZmZ ddlmZmZ dd	lmZmZ dd
lmZmZ dedddefdeddde	fdedddefdeddde
fdedddefdedddefdedddefdedddefdedddefdedddefdedddefdedddefdedddefd eddd!efd"defgd#edddefd$eddde	fd%edddefd&edddefd'edddefd(edddefd)edddefd*edddefd+edddefd,edddefd-edddefgd.Zd/d0 Zd1d2 Zd3d4 Zed5kr\ejd2d6 dS )7z$
Test cases for the isodate module.
    N)date)
parse_dateISO8601Errordate_isoformat)DATE_CENTURY	DATE_YEAR)DATE_BAS_MONTHDATE_EXT_MONTH)DATE_EXT_COMPLETEDATE_BAS_COMPLETE)DATE_BAS_ORD_COMPLETEDATE_EXT_ORD_COMPLETE)DATE_BAS_WEEKDATE_BAS_WEEK_COMPLETE)DATE_EXT_WEEKDATE_EXT_WEEK_COMPLETEZ19im     Z1985i  z1985-04   Z198504z
1985-04-12   Z19850412Z1985102z1985-102Z1985W155z
1985-W15-5Z1985W15   z1985-W15z1989-W15i  
   z
1989-W15-5   z1-W1-1z+0019z+001985z
+001985-04z+001985-04-12z+0019850412z
+001985102z+001985-102z+001985W155z+001985-W15-5z
+001985W15z+001985-W15)r      c                    s*   G  fdddt j}t  |S )z
    Create a TestCase class for a specific test.

    This allows having a separate TestCase for each test tuple from the
    TEST_CASES list, so that a failed test won't stop other tests.
    c                       s2   e Zd ZdZ fddZ fddZdS )z!create_testcase.<locals>.TestDatez^
        A test case template to parse an ISO date string into a date
        object.
        c                    s4   dkr|  tt  nt }| | dS )zX
            Parse an ISO date string and compare it to the expected value.
            N)assertRaisesr   r   assertEqual)selfresult)
datestringexpectation
yeardigits ;/tmp/pip-unpacked-wheel-giipsm8b/isodate/tests/test_date.py
test_parseV   s    

z,create_testcase.<locals>.TestDate.test_parsec                    s4   dkr|  tt n| t  dS )z}
            Take date object and create ISO string from it.
            This is the reverse test to test_parse.
            N)r   AttributeErrorr   r   )r   r   r   formatr   r    r!   test_formata   s      
z-create_testcase.<locals>.TestDate.test_formatN)__name__
__module____qualname____doc__r"   r&   r    r$   r    r!   TestDateP   s   r+   )unittestZTestCaseZ
TestLoaderZloadTestsFromTestCase)r   r   r   r%   r+   r    r$   r!   create_testcaseH   s    r-   c               	   C   sB   t  } t D ],\}}|D ]\}}}| t|||| qq| S )z<
    Construct a TestSuite instance for all test cases.
    )r,   Z	TestSuite
TEST_CASESitemsZaddTestr-   )Zsuiter   testsr   r   r%   r    r    r!   
test_suiter   s    
 
r1   c                 C   s   t  S )N)r1   )loaderr0   patternr    r    r!   
load_tests   s    r4   __main__)ZdefaultTest)r*   r,   datetimer   Zisodater   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r.   r-   r1   r4   r'   mainr    r    r    r!   <module>   sV   *
