HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_graphlib.cpython-310.pyc
o

�i_!�@sZddlmZddlZddlZddlZddlmZGdd�dej�Ze	dkr+e�
�dSdS)�)�chainN)�assert_python_okc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#S)$�TestTopologicalSortcspdd�}t�|�}|�t||��t|��t�|�}t|����|D]}�fdd�|D�}|�t|�|�q"dS)NcssL�|��|��r$|��}|D]}|�|�qtt|��V|��s	dSdS�N)�prepare�	is_active�	get_ready�done�tuple�sorted)�ts�nodes�node�r�//usr/local/lib/python3.10/test/test_graphlib.py�static_order_with_groups
s��zATestTopologicalSort._test_graph.<locals>.static_order_with_groupscsh|]}t���qSr)�next)�.0�element��itrr�	<setcomp>sz2TestTopologicalSort._test_graph.<locals>.<setcomp>)�graphlib�TopologicalSorter�assertEqual�list�iter�static_order�set)�self�graphZexpectedrr�groupZtsgrouprrr�_test_graph	s

�zTestTopologicalSort._test_graphc	Cs�t��}|��D]
\}}|j|g|�R�qz|��W�tjyI}z |j\}}|�d�t	t
|��d�t	t
|d���WYd}~dSd}~ww)N� �)rr�items�addrZ
CycleError�argsZassertIn�join�map�str)	rr �cyclerr�	dependson�e�msg�seqrrr�
_assert_cycles
�
6��z!TestTopologicalSort._assert_cyclec
Cs(|�dhddhddhddhddhd�gd��|�diid	g�|�d
d�td�D�d
d�tddd�D��|�dhdhdhdhdhdhdhdhd�gd��|�ddgdgddgdgdgdgdgdgdggd�
gd��|�ddggdggd�gd��|�ddggdggdgdggd�gd��dS) N�����)r$�	�
r1r2))r3r5r4)r2r1)r$r6r7��r8cSsi|]}||dh�qSr9r�r�xrrr�
<dictcomp>3sz9TestTopologicalSort.test_simple_cases.<locals>.<dictcomp>r7cSsg|]}|f�qSrrr:rrr�
<listcomp>3sz9TestTopologicalSort.test_simple_cases.<locals>.<listcomp>������
��)r$r3r?r5r1r@rArB))r8rC)r5rB)r?rA)r3r@)r$r1r$�r6)
rr8r$r3r?r5rDr4r2r6))r6)r?)r3r2)r8r5r4)rD�r$�r)rr8r$r3))r8r3rErF)rr8r$r3r?r5rD))r8r3rD)r$r5)rr?)r"�range�rrrr�test_simple_cases*s> �$�$��� �z%TestTopologicalSort.test_simple_casescCs>|�dhdhdhd�ddg�|�t�t�t�d�dg�dS)Nr$r?rD)r8r3r5)r$r?rD)r"rrHrrr�test_no_dependenciesRs z(TestTopologicalSort.test_no_dependenciescCsh|�dhdhgd�d�ddg�t��}|�dd�|�dd�|�dd�|�g|���ddg�dS)Nr$r?)r$r?r?r?r?r?)r8r3r)r$r?)rr8r3r8)r"rrr&rr�rrrrr�test_the_node_multiple_timesWs z0TestTopologicalSort.test_the_node_multiple_timescCs<dd�td�D�}t�d|i�}|�t|���gd��dS)Ncss�|]	}d|dVqdS)r$r8Nrr:rrr�	<genexpr>cs�z@TestTopologicalSort.test_graph_with_iterables.<locals>.<genexpr>r5r)r8r3r5r4r6r)rGrrrrr)rr,rrrr�test_graph_with_iterablesbsz-TestTopologicalSort.test_graph_with_iterablescCsjt��}|�dd�|�dd�|�dd�|�dd�t�dhd�i�}|�g|���g|����dS)Nr8r$r3r?r5>r$r3r?r5)rrr&rr)rr�ts2rrr�1test_add_dependencies_for_same_node_incrementallygs zETestTopologicalSort.test_add_dependencies_for_same_node_incrementallycCs|�ig�dSr)r"rHrrr�
test_emptyrszTestTopologicalSort.test_emptyc	Cs�|�ddhiddg�|�dhdhd�gd��|�dhdhdhd�gd��|�dhdhdhdhd	hd
�gd��|�dhdhdhdhdhd	hd
�gd��|�dhdhddhdhd�ddg�dS)Nr8r$)r8r$)r8r$r8r3)r8r$r3)r8r3r$r8r?rD)r8r$r3r5r?r5r4)r8r$r3r?rDr4)r8r$r3r?)r0rHrrr�
test_cycleus&*(zTestTopologicalSort.test_cyclecCs�t��}|�td��|��Wd�n1swY|�td��
|�d�Wd�n1s4wY|�td��
|��Wd�dS1sOwYdS)Nz prepare\(\) must be called firstr3)rr�assertRaisesRegex�
ValueErrorrr	rrKrrr�test_calls_before_prepare�s
��
"�z-TestTopologicalSort.test_calls_before_preparecCsJt��}|��|�td��
|��Wd�dS1swYdS)Nz!cannot prepare\(\) more than once)rrrrSrTrKrrr�test_prepare_multiple_times�s

"�z/TestTopologicalSort.test_prepare_multiple_timescCs�t��}|�dddd�|�ddd�|��|��|�td��
|�d�Wd�n1s1wY|�td��|�d�Wd�dS1sMwYdS)Nr8r$r3r?znode 2 was not passed outz#node 24 was not added using add\(\)�)rrr&rrrSrTr	rKrrr�test_invalid_nodes_in_done�s�"�z.TestTopologicalSort.test_invalid_nodes_in_donecCs�t��}|�dddd�|�dd�|��|�|��d�|�|��d�|�d�|�|��d�|�|��d�|�d�|�d�|�|��d�|�|��d�|�d�|�|��d�|�|���dS)	Nr8r$r3r?)r3r?rrEr9)	rrr&rrrr	�assertFalserrKrrr�	test_done�s 



zTestTopologicalSort.test_donecCs�t��}|�dd�|��|�|���|�|��d�|�|���|�d�|�|���|�|��d�|�|���|�d�|�	|���dS)Nr8r$rEr9)
rrr&rZ
assertTruerrrr	rYrKrrr�test_is_active�s

z"TestTopologicalSort.test_is_activecCsJt��}|�t|jt�d�|�t|jdt��|�t|jt�t��dS)Nr8)rrZassertRaises�	TypeErrorr&�dictrKrrr�test_not_hashable_nodes�sz+TestTopologicalSort.test_not_hashable_nodescCs�dd�}t��}|�ddd�|�dd�|�dd�|�d	d
�|�dd
�t��}|�dd�|�ddd�|�dd
�|�d	d
�|�dd�|�t||��t||���dS)Ncss>�|��|��r|��}|j|�t|�V|��s	dSdSr)rrrr	r)rr
rrr�
get_groups�s�

�z^TestTopologicalSort.test_order_of_insertion_does_not_matter_between_groups.<locals>.get_groupsr3r$r8rr?r5rDr4)rrr&rr)rr_rrOrrr�6test_order_of_insertion_does_not_matter_between_groups�s zJTestTopologicalSort.test_order_of_insertion_does_not_matter_between_groupscCs@dd�}|d�}|d�}|�|d�|�|d�|�||�dS)NcSs8d}tj��}d|d<t|�|d<td|fi|��}|S)Naxif 1:
                import graphlib
                ts = graphlib.TopologicalSorter()
                ts.add('blech', 'bluch', 'hola')
                ts.add('abcd', 'blech', 'bluch', 'a', 'b')
                ts.add('a', 'a string', 'something', 'b')
                ts.add('bluch', 'hola', 'abcde', 'a', 'b')
                print(list(ts.static_order()))
                TZ
__cleanenvZPYTHONHASHSEEDz-c)�os�environ�copyr*r)�seed�code�env�outrrr�check_order_with_hash_seed�s
	zlTestTopologicalSort.test_static_order_does_not_change_with_the_hash_seed.<locals>.check_order_with_hash_seedi�i�z�)ZassertNotEqualr)rrhZrun1Zrun2rrr�4test_static_order_does_not_change_with_the_hash_seed�szHTestTopologicalSort.test_static_order_does_not_change_with_the_hash_seedN)�__name__�
__module__�__qualname__r"r0rIrJrLrNrPrQrRrUrVrXrZr[r^r`rjrrrrrs$(
r�__main__)�	itertoolsrrraZunittestZtest.support.script_helperrZTestCaserrk�mainrrrr�<module>su�