OwlCyberSecurity - MANAGER
Edit File: test_searchengine.cpython-35.opt-1.pyc
��Yf�,������������������@���s��d��Z��d�d�l�Z�d�d�l�Z�d�d�l�m�Z�m�Z�m�Z�d�d�l�j�Z �d�d�l �m�Z�d�d�l �m�Z�m�Z�d�d�l �m�Z�d�d����Z�d �d ����Z�Gd�d����d���Z�Gd �d����d�e�j���Z�Gd�d����d�e�j���Z�Gd�d����d�e�j���Z�Gd�d����d�e�j���Z�Gd�d����d�e�j���Z�Gd�d����d�e�j���Z�Gd�d����d�e�j���Z�e�d�k�r{e�j�d�d�d�d���d�S)z9Test functions and SearchEngine class in SearchEngine.py.�����N)� BooleanVar� StringVar�TclError)�SearchEngine)�Var�Mbox)�Textc���������������C���s���t��t�_�t��t�_�t�t�_�d��S)N)r����ser���r���r����tkMessageBox��r���r����H/opt/alt/python35/lib64/python3.5/idlelib/idle_test/test_searchengine.py�setUpModule���s���� r ���c���������������C���s���t��t�_��t�t�_�t�t�_�d��S)N)r���r ���r���r ���r���r���r���r����tearDownModule���s���� r���c���������������@���s���e��Z�d��Z�d�d����Z�d�S)�Mockc�������������O���s���d��S)Nr���)�self�args�kwargsr���r���r����__init__���s����z Mock.__init__N)�__name__� __module__�__qualname__r���r���r���r���r���r������s���r���c���������������@���s���e��Z�d��Z�d�d����Z�d�S)�GetTestc�������������C���s~���t��j�}�t�t��_�z[�t����}�t��j�|���}�|��j�|�t��j���|��j�|�j�|���|��j�t��j�|���|���Wd��|�t��_�Xd��S)N)r ���r���r����getZassertIsInstanceZassertIsZ _searchengine)r���Zsaved_Engine�root�enginer���r���r����test_get#���s���� zGetTest.test_getN)r���r���r���r���r���r���r���r���r���!���s���r���c���������������@���s���e��Z�d��Z�d�d����Z�d�S)�GetLineColTestc�������������C���sb���|��j��t�j�d���d���|��j��t�j�d���d ���|��j�t�t�j�d���|��j�t�t�j�d���d��S) Nz1.0����r���z1.11����z1.0 lineend�end)r���r���)r���r���)�assertEqualr ���Zget_line_colZassertRaises� ValueError)r���r���r���r����test_get_line_col1���s����z GetLineColTest.test_get_line_colN)r���r���r���r"���r���r���r���r���r���/���s���r���c���������������@���s���e��Z�d��Z�d�d����Z�d�S)�GetSelectionTestc�������������C���sy���t�����}�|�j�d�d���d�d����}�|�|�_�|��j�t�j�|���d ���d�d����}�|�|�_�|��j�t�j�|���d ���d��S)N�1.0zHello World!c�������������S���s*���|��d�k�r�d�S|��d�k�r �d�St����d��S)Nz sel.firstz1.0zsel.lastz1.12)r���)�sr���r���r����selK���s ������z0GetSelectionTest.test_get_selection.<locals>.sel�1.12c�������������S���s���|��d�k�r�d�St����d��S)N�insertz1.5)r���)r%���r���r���r����markS���s�����z1GetSelectionTest.test_get_selection.<locals>.mark�1.5)r$���r'���)r*���r*���)�mockTextr(����indexr ���r ���Z get_selection)r����textr&���r)���r���r���r����test_get_selectionE���s���� z#GetSelectionTest.test_get_selectionN)r���r���r���r.���r���r���r���r���r#���8���s��� r#���c���������������@���s���e��Z�d��Z�d�d����Z�d�S)�ReverseSearchTestc�������������C���s����|��j��}�d�}�t�j�d���}�|�t�j�|�|�t�|�����j����d ���|�t�j�|�|�d���j����d ���|�t�j�|�|�d���j����d���|�t�j�|�|�d���j����d���|�t�j�|�|�d���d����d��S) NzHere is an 'is' test text.�is��������� ���������������)r1���r2���)r1���r2���)r4���r5���)r4���r5���)r ����re�compiler ���Zsearch_reverse�len�span)r����Equal�line�progr���r���r����test_search_reverse]���s���� ("""z%ReverseSearchTest.test_search_reverseN)r���r���r���r>���r���r���r���r���r/���[���s���r/���c���������������@���sX���e��Z�d��Z�d�d����Z�d�d����Z�d�d����Z�d�d����Z�d �d ����Z�d�d����Z�d �S)�SearchEngineTestc�������������C���s���t��j�d�d����|��_�d��S)Nr���)r ���r���r���)r���r���r���r����setUpk���s����zSearchEngineTest.setUpc�������������C���sW��|��j��}�|��j�}�|�|�j����d���|�j�d���|�|�j����d���|�|�j����d���|�j�j�d���|�|�j����d���|�|�j����d���|�j�j�d���|�|�j����d���|�|�j ����d���|�j �j�d���|�|�j ����d���|�|�j����d���|�j�j�d���|�|�j����d���|�|�j ����d���|�j�j�d���|�|�j ����d���d��S)N���helloFr���Tr���)r���r ����getpat�setpatZisre�revar�setZiscase�casevarZisword�wordvarZiswrap�wrapvarZisback�backvar)r���r���r;���r���r���r����test_is_getp���s(���� zSearchEngineTest.test_is_getc�������������C���sc���|��j��}�|�j�d���|��j�|�j����d���|�j�j�d���|�j�d���|��j�|�j����d���d��S)Nz\sr���z\\s)r���Zsetcookedpatr ���rC���rE���rF���)r���r���r���r���r����test_setcookedpat����s���� z"SearchEngineTest.test_setcookedpatc�������������C���s����|��j��}�|��j�}�|�|�j����d���|�j�d���|�|�j����d���|�j�j�d���|�|�j����d���|�j�j�d���|�j�d���|�|�j����d���|�j�j�d���|�|�j����d���d��S)NrA���rB���Tz \bhello\bFz\sz\\s)r���r ���ZgetcookedpatrD���rH���rF���rE���)r���r���r;���r���r���r����test_getcookedpat����s���� z"SearchEngineTest.test_getcookedpatc�������������C���s����|��j��}�|��j�}�|�j�d���|�j����}�|�|�j�t�j�d�t�j���j���|�j�j �d���|�j����}�|�|�j�t�j�d���j�d���|�j�d���|�|�j����d����|�j�d���|�j �j �d���|�|�j����d����|��j�t�j�j �d���d��S)NZHellor���r���rA����+z1Error: nothing to repeat at position 0 Pattern: +)r���r ���rD���Zgetprog�patternr7���r8���� IGNORECASErG���rF���rE���r���� showerror�message)r���r���r;���Ztemppatr���r���r����test_getprog����s���� " zSearchEngineTest.test_getprogc�������������C���s����t��j�}�|��j�}�d�}�d�}�|�|��j�j�|�|���d����|�|�j�d���d�|�d�}�|�|�j�|���|�|��j�j�|�|�d���d����|�|�j�d���|�d�7}�|�|�j�|���d��S)Nz[a-zz$unexpected end of regular expressionzRegular expression errorzError: z Pattern: [a-zr4���z Offset: 5)r���rQ���r ���r���Zreport_error�titlerR���)r���rQ���r;����pat�msgZexpected_messager���r���r����test_report_error����s���� z"SearchEngineTest.test_report_errorN) r���r���r���r@���rK���rL���rM���rS���rW���r���r���r���r���r?���h���s���r?���c���������������@���s.���e��Z�d��Z�e�d�d������Z�d�d����Z�d�S)� SearchTestc�������������C���sq���t�����|��_�d�}�|��j�j�d�|���t�j�d���|��_�t�j�d����|��_�d�d����|��j�_ �d�d����|��j�_ �d��S)Nz&First line Line with target Last line z1.0�targetc��������������W���s ���d�|��f�S)N�fr���)r���r���r���r����<lambda>����s����z'SearchTest.setUpClass.<locals>.<lambda>c��������������W���s ���d�|��f�S)N�br���)r���r���r���r���r[�������s����)r+���r-���r(���r7���r8���rU���r ���r���r����search_forward�search_backward)�cls� test_textr���r���r���� setUpClass����s����zSearchTest.setUpClassc���������� ���C���s��|��j��}�|��j�}�|�j�}�|��j�}�|��j�}�|�j�j�d����|�|�|���d����d�d����}�|�|�_�|�|�|�|���d�|�|�d�d�d�d�f�f���|�j�j�d���|�|�|�|���d�|�|�d�d�d�d�f�f���|�j�j�d���|�j �j�d���|�|�|�|���d�|�|�d�d�d�d�f�f���|�j �j�d���d �d ����}�|�|�_�|�|�|�|���d�|�|�d�d�d�d�f�f���|�|�|�|�d���d�|�|�d�d �d�d�f�f���|�j �j�d���|�|�|�|���d�|�|�d�d �d�d�f�f���|�|�|�|�d���d�|�|�d�d�d�d�f�f���d��S)Nc�������������S���s���|��d�k�r�d�St����d��S)Nr(���z1.5)r���)r%���r���r���r���r)�������s�����z$SearchTest.test_search.<locals>.markrZ���r���r4���TFr\���c�������������S���s*���|��d�k�r�d�S|��d�k�r �d�St����d��S)Nz sel.firstz2.10zsel.lastz2.16)r���)r%���r���r���r���r&�������s ������z#SearchTest.test_search.<locals>.sel��������� ���) r ���r���Zsearch_textr-���rU���ZpatvarrF���r,���rI���rJ���)r���r;���r����searchr-���rU���r)���r&���r���r���r����test_search����s.���� ... .1.zSearchTest.test_searchN)r���r���r����classmethodra���rf���r���r���r���r���rX�������s���rX���c���������������@���sF���e��Z�d��Z�e�d�d������Z�d�d����Z�d�d����Z�d�d����Z�d �S) �ForwardBackwardTestc�������������C���s����t��j�d����|��_�t����|��_�d�d����|��j�_�d�}�|��j�j�d�|���t�j�d���|��_ �d�|��_ �t�j�d ���|��_�t�j�d ���|��_�d��S) Nc�������������S���s���d�S)Nz4.0r���)r,���r���r���r���r[�����s����z0ForwardBackwardTest.setUpClass.<locals>.<lambda>z&First line Line with target Last line z1.0rY���rb���rd���rc���Zxyzz\w*�rd���rc���)rb���ri���) r ���r���r���r+���r-���r,���r(���r7���r8���rU����res�failpat�emptypat)r_���r`���r���r���r���ra�����s���� zForwardBackwardTest.setUpClassc����������������s���d������f�d�d���}�|�S)Nr���c����������������s@��������j��|��|�|�|�|���}�|�r<�|�d�|�d�j����f�S|�S)Nr���r���)r-���r:���)rU���r<����colZwrap�okrj���)�funcr���r���r���re��� ��s����z/ForwardBackwardTest.make_search.<locals>.searchr���)r���ro���re���r���)ro���r���r����make_search��s����zForwardBackwardTest.make_searchc�������������C���s ��|��j��}�|��j�|��j�j���}�|��j�}�|�|�|�d�d�d���|��j���|�|�|�d�d�d���|��j���|�|�|�d�d�d���d����|�|�|�d�d�d���|��j���|�|�|��j�d�d�d���d����|�|�|��j�d�d�d�d �d��d���|�|�|��j�d�d�d���|��j���d��S)Nr���r���T����Frb���rd���� ���rn����rr���rr���)rb���rs���)r ���rp���r���r]���rU���rj���rk���rl���)r���r;���ZforwardrU���r���r���r����test_search_forward&��s���� %z'ForwardBackwardTest.test_search_forwardc�������������C���s��|��j��}�|��j�|��j�j���}�|��j�}�|�|�|�d�d�d���|��j���|�|�|�d�d�d���|��j���|�|�|�d�d�d���d����|�|�|�d�d�d���|��j���|�|�|��j�d�d�d���d����|�|�|��j�d�d �d�d �d��d���|�|�|��j�d�d�d���d���d��S)Nrq���r4���Trb���r���Frc���rr���rd���rn����rr���rr���)rb���ru����r4���rr���)rb���rv���)r ���rp���r���r^���rU���rj���rk���rl���)r���r;���ZbackwardrU���r���r���r����test_search_backward7��s���� %z(ForwardBackwardTest.test_search_backwardN)r���r���r���rg���ra���rp���rt���rw���r���r���r���r���rh�����s���rh����__main__� verbosityrb����exit)�__doc__r7���ZunittestZtkinterr���r���r���Ztkinter.messageboxZ messageboxr ���Zidlelibr���r ���Zidlelib.idle_test.mock_tkr���r���r���r+���r ���r���r���ZTestCaser���r���r#���r/���r?���rX���rh���r����mainr���r���r���r����<module>���s&��� # `=C