Server IP : 103.119.228.120 / Your IP : 18.117.192.64 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/ssl/lib/mysqlsh/lib/python3.9/idlelib/idle_test/ |
Upload File : |
"Test zzdummy, coverage 100%." from idlelib import zzdummy import unittest from test.support import requires from tkinter import Tk, Text from unittest import mock from idlelib import config from idlelib import editor from idlelib import format usercfg = zzdummy.idleConf.userCfg testcfg = { 'main': config.IdleUserConfParser(''), 'highlight': config.IdleUserConfParser(''), 'keys': config.IdleUserConfParser(''), 'extensions': config.IdleUserConfParser(''), } code_sample = """\ class C1(): # Class comment. def __init__(self, a, b): self.a = a self.b = b """ class DummyEditwin: get_selection_indices = editor.EditorWindow.get_selection_indices def __init__(self, root, text): self.root = root self.top = root self.text = text self.fregion = format.FormatRegion(self) self.text.undo_block_start = mock.Mock() self.text.undo_block_stop = mock.Mock() class ZZDummyTest(unittest.TestCase): @classmethod def setUpClass(cls): requires('gui') root = cls.root = Tk() root.withdraw() text = cls.text = Text(cls.root) cls.editor = DummyEditwin(root, text) zzdummy.idleConf.userCfg = testcfg @classmethod def tearDownClass(cls): zzdummy.idleConf.userCfg = usercfg del cls.editor, cls.text cls.root.update_idletasks() for id in cls.root.tk.call('after', 'info'): cls.root.after_cancel(id) # Need for EditorWindow. cls.root.destroy() del cls.root def setUp(self): text = self.text text.insert('1.0', code_sample) text.undo_block_start.reset_mock() text.undo_block_stop.reset_mock() zz = self.zz = zzdummy.ZzDummy(self.editor) zzdummy.ZzDummy.ztext = '# ignore #' def tearDown(self): self.text.delete('1.0', 'end') del self.zz def checklines(self, text, value): # Verify that there are lines being checked. end_line = int(float(text.index('end'))) # Check each line for the starting text. actual = [] for line in range(1, end_line): txt = text.get(f'{line}.0', f'{line}.end') actual.append(txt.startswith(value)) return actual def test_init(self): zz = self.zz self.assertEqual(zz.editwin, self.editor) self.assertEqual(zz.text, self.editor.text) def test_reload(self): self.assertEqual(self.zz.ztext, '# ignore #') testcfg['extensions'].SetOption('ZzDummy', 'z-text', 'spam') zzdummy.ZzDummy.reload() self.assertEqual(self.zz.ztext, 'spam') def test_z_in_event(self): eq = self.assertEqual zz = self.zz text = zz.text eq(self.zz.ztext, '# ignore #') # No lines have the leading text. expected = [False, False, False, False, False, False, False] actual = self.checklines(text, zz.ztext) eq(expected, actual) text.tag_add('sel', '2.0', '4.end') eq(zz.z_in_event(), 'break') expected = [False, True, True, True, False, False, False] actual = self.checklines(text, zz.ztext) eq(expected, actual) text.undo_block_start.assert_called_once() text.undo_block_stop.assert_called_once() def test_z_out_event(self): eq = self.assertEqual zz = self.zz text = zz.text eq(self.zz.ztext, '# ignore #') # Prepend text. text.tag_add('sel', '2.0', '5.end') zz.z_in_event() text.undo_block_start.reset_mock() text.undo_block_stop.reset_mock() # Select a few lines to remove text. text.tag_remove('sel', '1.0', 'end') text.tag_add('sel', '3.0', '4.end') eq(zz.z_out_event(), 'break') expected = [False, True, False, False, True, False, False] actual = self.checklines(text, zz.ztext) eq(expected, actual) text.undo_block_start.assert_called_once() text.undo_block_stop.assert_called_once() def test_roundtrip(self): # Insert and remove to all code should give back original text. zz = self.zz text = zz.text text.tag_add('sel', '1.0', 'end-1c') zz.z_in_event() zz.z_out_event() self.assertEqual(text.get('1.0', 'end-1c'), code_sample) if __name__ == '__main__': unittest.main(verbosity=2)