%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/reportlab/lib/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/reportlab/lib/__pycache__/testutils.cpython-312.pyc

�

׸�eY3���ddlZde_[dZdZddlZddlZddlZddlZddlZddl	m
Z
ddlZddlm
Z
mZmZmZd�Zd�Zdadadad	�Zej.j1d
d�dk7rdndfZd
�Zd�Zd'd�Zdd�d�Zd(d�ZGd�de
�ZGd�d�Z Gd�de �Z!Gd�de �Z"Gd�dejF�Z$Gd�dejF�Z%Gd�d ejF�Z&d)d!�Z'd"�Z(d#�Z)d*d$�Z*d*d%�Z+d*d&�Z,y)+�NTz4.0.1aProvides support for the test suite.

The test suite as a whole, and individual tests, need to share
certain support functions.  We have to put these in here so they
can always be imported, and so that individual tests need to import
nothing more than "reportlab.whatever..."
)�ConfigParser)�isCompactDistro�
__rl_loader__�rl_isdir�	asUnicodec�8�ddlm}m}	|�S#|$rYywxYw)Nr��
_getPMBackend�
RenderPMErrorF)�reportlab.graphics.renderPMr
rr	s  �9/usr/lib/python3/dist-packages/reportlab/lib/testutils.py�haveRenderPMrs$��H����������s���c���	d}t|d�}|jd�|j�tjj|�rtj|�yy#YyxYw)Nz00DELETE.ME�wz$test of writability - can be deleted�r)�open�write�close�os�path�isfile�remove)�D�fn�fs   r
�
isWritablersZ��	�
����S�M��	���6�7�	���	�
�7�7�>�>�"���I�I�b�M������s�A#A'�'A+c�d�trtStjD�cgc]}|jd�s�|dd��}}|s%tj
j
dd�}|r|g}|rY|da	t	jt�|D]4}|tjvs�tjj|��6nT|dk(sJd��tjjtjd	�}|st	j�}|att�std
�ad	dl}|jd	atjj#t �s@tjj%tjj't ��atjjt �}tjj)|d�atjj-t*�s=tjj)tjj|�d�atjj-t*�sm|dk(rftjjtjd	�}|st	j�}tjj'|�andat*rAtjj/d	tjjt*��tScc}w#Y���xYw)z�Is it a writable file system distro being invoked within
    test directory?  If so, can write test output here.  If not,
    it had better go in a temp directory.  Only do this once per
    processz	--outdir=�	N�RL_TEST_OUTDIR�����__main__z2setOutDir should only be called in the main scriptr�reportlab_test�tests)�_OUTDIR�sys�argv�
startswithr�environ�get�makedirsrr�dirname�getcwdr�get_rl_tempdir�	reportlab�__path__�RL_HOME�isabs�normpath�abspath�join�testsFolder�isdir�insert)�name�dr�	scriptDirr/�topDirs      r
�	setOutDirr=+s���w�����>�1�A�L�L��$=��1�2��>�A�>���J�J�N�N�+�B�/�����a���B�%��	��K�K�� ��	#�A��C�H�H�}�������"�	#��Z��T� T�T���'�'�/�/�#�(�(�1�+�.�	��B�I�I�K�)����g�� �!1�2������q�!�G�
�7�7�=�=��!�2�7�7�+;�+;�B�G�G�O�O�G�<T�+U�7�
�W�W�_�_�W�
%�F��'�'�,�,�v�g�.�K�
�7�7�=�=��%��g�g�l�l�2�7�7�?�?�6�#:�7�C��
�7�7�=�=��%�����g�g�o�o�c�h�h�q�k�2�I���	�	��i��'�'�/�/�)�4�K��K��������"�'�'�/�/�+�6�7��N��M	?��	��s�L%�L%�.L*�*L/�OFFLINE_MOCK�1z,http://www.reportlab.com/rsrc/encryption.gifc�,�|tvrettjj	t
tjj
|��d�5}|j�cddd�Sddlm	}||�j�S#1swYyxYw)N�rbr)�urlopen)
�	_mockumaprrrr5r6�basename�read�urllib.requestrB)r9rrBs   r
�mockUrlReadrG^so���y��
�"�'�'�,�,�{�2�7�7�+;�+;�D�+A�B�4�
H�	�A��6�6�8�	�	�	+��t�}�!�!�#�#�		�	�s�B
�
Bc�h�tt�}|r tjj	||�}|S)z�This works out where to write test output.  If running
    code in a locked down file system, this will be a
    temp directory; otherwise, the output of 'test_foo.py' will
    normally be a file called 'test_foo.pdf', next door.
    )r=�__name__rrr5)rrs  r
�
outputfilerJfs)��	�(��A�	�r�w�w�|�|�A�b�!�1��H�c��tj|�jjd�dk(r$t	d�}|t
k7rt
d|z�yyy)NrIr"r z,Logs and output files written to folder "%s")r&�	_getframe�f_localsr*rJr%�print)�depth�outDirs  r
�
printLocationrRpsM��
�}�}�U��$�$�(�(��4�j�@��B����7�?��@�6�I�J��ArK)�testMethodPrefixc��tj�}tj�}|r||_|D]"}|j	|j|���$|S)z<Return a test suite with tests loaded from provided classes.)�unittest�	TestSuite�
TestLoaderrS�addTest�loadTestsFromTestCase)rS�classes�suite�loader�Cs     r
�makeSuiteForClassesr^vsV��
��� �E�
�
 �
 �
"�F��"2���
�7��
�
�
�f�2�2�1�5�6�7��LrKc�<�tjj}	t||dd��}g}|j�D]G}|r|ddk(s|s�|ddk7s�|j
d�d}|s�0|j|||���I|S#t$rgcYSwxYw)aGReturns a list of filenames as listed in the CVS/Entries file.

    'folder' is the folder that should contain the CVS subfolder.
    If there is no such subfolder an empty list is returned.
    'files' is a boolean; 1 and 0 means to return files or not.
    'folders' is a boolean; 1 and 0 means to return folders or not.
    �CVS�Entriesrr�/r)rrr5r�IOError�	readlines�split�append)�folder�files�foldersr5r�
allEntries�line�entrys        r
�
getCVSEntriesrm�s����7�7�<�<�D����f�e�Y�/�0��
�J����
�7���t�A�w�#�~���Q��3���J�J�s�O�A�&�E���!�!�$�v�u�"5�6�7�������	��s�B
�
B�Bc�:�eZdZdZej
d�Zd�Zy)�ExtConfigParserz7A slightly extended version to return lists of strings.z\s*\[.*\]\s*c��tj|||�}|jdd�}|jj	|�rt|tdi�S|S)zECoerce option to a list of strings or return unchanged if that fails.�
r N)rr*�replace�pat�match�eval�__builtins__)�self�section�option�value�vals     r
�
getstringlistzExtConfigParser.getstringlist�sQ��� � ��w��7���m�m�D�"�%���8�8�>�>�#����\�$�/�0�0��LrKN)rI�
__module__�__qualname__�__doc__�re�compilersr|�rKr
roro�s��=�
�"�*�*�_�
%�C�rKroc�$�eZdZdZdd�Zd�Zd�Zy)�GlobDirectoryWalkerz<A forward iterator that traverses files in a directory tree.c���d|_||_|jdtj�tj
j
|�r|g|_g|_yt�rtrt|�std|z��|ttj�ttj�zd|_|jtjz}t|�}t!t#|fd�t!t%|fd�t!tj&j)������|_|jj+�g|_y)Nrrbz"%s" is not a directoryc��||dS�Nr�)�x�ns  r
�<lambda>z.GlobDirectoryWalker.__init__.<locals>.<lambda>�s���1�2��rKc�$�|j|�Sr�)r()r��pfxs  r
r�z.GlobDirectoryWalker.__init__.<locals>.<lambda>�s��UV�Ua�Ua�be�Uf�rK)�index�patternrrr�seprr7�stackrhrrr�
ValueError�len�archive�	directory�list�map�filter�_files�keys�sort)rwr�r�r�r�s     r
�__init__zGlobDirectoryWalker.__init__�s����
�������#�b�f�f�%�
�7�7�=�=��#�#��D�J��D�J�"�$�M��)�AT� �!:�Y�!F�G�G�&�s�=�+@�+@�'A�#�b�f�f�+�'M�'N�O�D�N��.�.����'�C��C��A��c�a�"6�t�F�PS�Cf�gk�ly�mA�mA�mF�mF�mH�hI�=J�8K�L�M�D�J��J�J�O�O���D�JrKc��		|j|j}|jdz|_tjj	|j
|�}tjj
|�r:tjj|�s|jj|�tj||j�r|S��#t$rx|jj�|_tj|j
�|_|j|j
|j�|_d|_Y��wxYw)Nrr)rhr�rrr5r�r7�islinkr�rf�fnmatchr��
IndexError�pop�listdir�filterFiles)rwr��file�fullnames    r
�__getitem__zGlobDirectoryWalker.__getitem__�s����
$��z�z�$�*�*�-��!�Z�Z�!�^��
��7�7�<�<�����=���7�7�=�=��*�2�7�7�>�>�(�3K��J�J�%�%�h�/��?�?�4����6�#�O�#���
�!%�����!1����Z�Z����7��
�!�-�-�d�n�n�d�j�j�I��
���
�

�s�-C�A>E�Ec��|S)z/Filter hook, overwrite in subclasses as needed.r�)rwrgrhs   r
r�zGlobDirectoryWalker.filterFiles�s	���rKN)�*)rIr}r~rr�r�r�r�rKr
r�r��s��B��"$�(rKr�c��eZdZdZdd�Zd�Zy)�RestrictedGlobDirectoryWalkerz&An restricted directory tree iterator.Nc��tj|||�|dk(rg}gj}t|tt
f�r|D]
}||��nt|t�r||�tjdk7r>|jD�cgc]"}|jdtj���$c}|_y|j|_ycc}w)Nrb)r�r�rf�
isinstance�tupler��strrr��__self__rr�ignorePatterns)rwr�r��ignore�ip�p�_s       r
r�z&RestrictedGlobDirectoryWalker.__init__�s����$�$�T�9�g�>��T�>��F�
�Y�Y���f�e�D�\�*��
���1��
�
��s�
#��v�J�OQ�v�v�Y\�}�r�{�{�K�!��	�	�#�b�f�f� 5�K���%'�[�[�	
���Ks�
'Cc�*�tj}g}t|�D]X\}}|jD]D}|||�s(|tjj||�|�s�4|j
|��F�Z|j�|D]}||=�|S)z9Filters all items from files matching patterns to ignore.)r��	enumerater�rrr5rf�reverse)rwrgrh�fnm�indicesToDelete�irr�s        r
r�z)RestrictedGlobDirectoryWalker.filterFiles�s����o�o�����U�#�	.�C�A�a��(�(�
.���q�!�9��B�G�G�L�L���$:�1� =�#�*�*�1�-�
.�	.�	���!� �	�A��a��	��rK)r�N)rIr}r~rr�r�r�rKr
r�r��s��,�2�
rKr�c��eZdZdZd�Zy)�CVSGlobDirectoryWalkerz4An directory tree iterator that checks for CVS data.c��tjj}t|�}|rWg}t	t|��D]$}||}|||�|vs�|j
|��&|j�|D]}||=�|S)z�Filters files not listed in CVS subfolder.

        This will look in the CVS subfolder of 'folder' for
        a file named 'Entries' and filter all elements from
        the 'files' list that are not listed in 'Entries'.
        )rrr5rm�ranger�rfr�)rwrgrhr5�cvsFilesr�r�rs        r
r�z"CVSGlobDirectoryWalker.filterFiless����w�w�|�|�� ��(��� �O��3�u�:�&�
.���!�H�����?�(�2�#�*�*�1�-�
.�
�#�#�%�$�
���!�H�
��rKN)rIr}r~rr�r�rKr
r�r�s
��:�rKr�c��eZdZdZd�Zd�Zy)�SecureTestCasea�Secure testing base class with additional pre- and postconditions.

    We try to ensure that each test leaves the environment it has
    found unchanged after the test is performed, successful or not.

    Currently we restore sys.path and the working directory, but more
    of this could be added easily, like removing temporary files or
    similar things.

    Use this as a base class replacing unittest.TestCase and call
    these methods in subclassed versions before doing your own
    business!
    c�f�tjdd|_tj�|_y)z0Remember sys.path and current working directory.N)r&r�_initialPathrr-�_initialWorkDir�rws r
�setUpzSecureTestCase.setUp0s ���H�H�Q�K���!�y�y�{��rKc�l�|jt_tj|j
�y)z0Restore previous sys.path and working directory.N)r�r&rr�chdirr�r�s r
�tearDownzSecureTestCase.tearDown5s!���$�$���
����%�%�&rKN)rIr}r~rr�r�r�rKr
r�r�!s���+�
'rKr�c�$�eZdZdd�Zee�Zy)�NearTestCasec���t|ttf�r"t||z
�|kDrt	|�d|����yt||�D]&\}}t||z
�|kDs�t	|�d|����y)Nz
 not near )r��float�int�abs�AssertionError�zip)�a�b�accuracy�ae�bes     r
�
assertNearzNearTestCase.assertNear;sr���a��s��$��1�Q�3�x�� �$��A�%>�?�?�!��Q�q��
D���2��r�"�u�:�h�&�(�Q��)B�C�C�
DrKN)g�h㈵��>)rIr}r~r��staticmethodr�rKr
r�r�:s��D��j�)�JrKr�c�*�eZdZdZdd�Zd�Zd�Zd�Zy)�ScriptThatMakesFileTestzyRuns a Python script at OS level, expecting it to produce a file.

    It CDs to the working directory to run the script.c�z�||_||_||_||_tj
j
|�yr�)r;�
scriptName�outFileName�verboserU�TestCaser�)rwr;r�r�r�s     r
r�z ScriptThatMakesFileTest.__init__Is3��"���$���&���������"�"�4�(rKc�
�tj�|_|j}tjj|�s$tjj
t|�}tj|�tjj|j�sJd|jz��tjj|j�r tj|j�yy)NzScript %s not found!)
rr-�cwdr;rr2r5r6r�rr�r�r)rwr;s  r
r�zScriptThatMakesFileTest.setUpQs����9�9�;����.�.�	��w�w�}�}�Y�'��g�g�l�l�;�y�9�I�
������w�w�~�~�d�o�o�.�X�0F����0X�X�.�
�7�7�>�>�$�*�*�+��I�I�d�&�&�'�,rKc�B�tj|j�yr�)rr�r�r�s r
r�z ScriptThatMakesFileTest.tearDown]s��
������rKc�@�tjdk(xrdxsd}ddl}|jtj|j
f�}|jrt|�tjj|j�sJd|jz��y)N�win32z"%s" %sz%s %srzFile %s not created!)r&�platform�
subprocess�check_output�
executabler�r�rOrrrr�)rw�fmtr��outs    r
�runTestzScriptThatMakesFileTest.runTest`sw���l�l�G�#�1�	�<�W����%�%�s�~�~�d�o�o�&F�G���<�<��#�J��w�w�~�~�d�.�.�/�Z�1G�$�JZ�JZ�1Z�Z�/rKN)r)rIr}r~rr�r�r�r�r�rKr
r�r�Es��:�)�
(��	[rKr�c�l�t|�t|�k(r||k(St||�t||�k(Sr�)�typer)r�r��encs   r
�equalStringsr�ks3����7�D��G�#�1�a�4�K��1�S�)9�9�Q�s�;K�)K�KrKc�V�||k7r$tdt|��dt|����yy)NzStrings unequal
exp: z
got: )rO�ascii)�rr�s  r
�eqCheckr�ns#���!�t�
�U�1�X�e�A�h�G�H�rKc��	ddl}y#YyxYw)NrFT��rlextrar�s r
�
rlextraNeededr�rs��������s��c��������fd�}|S)Nc�J���tj������fd��}|S)Nc�����rOtjjdd�dk(r,td�jxs��d�j
�d����t
j�����|i|��S)N�RL_indicateSkips�0r?z

skipping �.� )rr)r*rOr}rIrU�skipIf)�args�kwdsr}�cond�func�reasons  ����r
�wrapperz(rlSkipIf.<locals>.inner.<locals>.wrapper{su�����
�
���'9�#�>��C��
�
�/�/�
'�Z�	(��$�-�-���&��E�F�5�/�8�?�?�4��/��5�t�C�d�C�CrK)�	functools�wraps)rrr}rrs` ���r
�innerzrlSkipIf.<locals>.innerzs'���	����	�	D�
�	D�
�rKr�)rrr}rs``` r
�rlSkipIfrys�����LrKc� �t|||��S)N�r}�r)rrr}s   r
�rlSkipUnlessr�s����H�V�z�:�:rKc��td||��S)NTr
r)rr}s  r
�rlSkipr�s���D��:�6�6rK)r)rr)�utf8r�)-r/�_rl_testing�__version__rr&rr�r�r�configparserrrU�reportlab.lib.utilsrrrrrrr%r1r6r=r)r*rCrGrJrRr^rmror�r�r�r�r�r�r�r�r�r�rrrr�rKr
�<module>rs(����	��
���	��'�&�&�%��S�S��
���
����-�`�
�
���~�c�2�C�7��>�
�	�$�
�K�37�	��<�l��.+�+�\�$7��B�0��8'�X�&�&�'�2	*�8�$�$�	*�$[�h�/�/�$[�LL�I��	�;�7rK

Zerion Mini Shell 1.0