Server IP : 103.119.228.120 / Your IP : 13.58.34.132 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/share/doc/libxml2-python-2.9.1/ |
Upload File : |
#!/usr/bin/python -u import sys, unittest import libxml2 class TestCase(unittest.TestCase): def runTest(self): self.test1() self.test2() def setUp(self): libxml2.debugMemory(1) def tearDown(self): libxml2.cleanupParser() if libxml2.debugMemory(1) != 0: libxml2.dumpMemory() self.fail("Memory leak %d bytes" % (libxml2.debugMemory(1),)) else: print("OK") def failUnlessXmlError(self,f,args,exc,domain,code,message,level,file,line): """Run function f, with arguments args and expect an exception exc; when the exception is raised, check the libxml2.lastError for expected values.""" # disable the default error handler libxml2.registerErrorHandler(None,None) try: f(*args) except exc: e = libxml2.lastError() if e is None: self.fail("lastError not set") if 0: print("domain = ",e.domain()) print("code = ",e.code()) print("message =",repr(e.message())) print("level =",e.level()) print("file =",e.file()) print("line =",e.line()) print() self.failUnlessEqual(domain,e.domain()) self.failUnlessEqual(code,e.code()) self.failUnlessEqual(message,e.message()) self.failUnlessEqual(level,e.level()) self.failUnlessEqual(file,e.file()) self.failUnlessEqual(line,e.line()) else: self.fail("exception %s should have been raised" % exc) def test1(self): """Test readFile with a file that does not exist""" self.failUnlessXmlError(libxml2.readFile, ("dummy.xml",None,0), libxml2.treeError, domain=libxml2.XML_FROM_IO, code=libxml2.XML_IO_LOAD_ERROR, message='failed to load external entity "dummy.xml"\n', level=libxml2.XML_ERR_WARNING, file=None, line=0) def test2(self): """Test a well-formedness error: we get the last error only""" s = "<x>\n<a>\n</x>" self.failUnlessXmlError(libxml2.readMemory, (s,len(s),"dummy.xml",None,0), libxml2.treeError, domain=libxml2.XML_FROM_PARSER, code=libxml2.XML_ERR_TAG_NOT_FINISHED, message='Premature end of data in tag x line 1\n', level=libxml2.XML_ERR_FATAL, file='dummy.xml', line=3) if __name__ == "__main__": test = TestCase() test.setUp() test.test1() test.test2() test.tearDown()