????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 18.219.31.133 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/home/b8009/Python-3.6.3/Lib/test/test_tools/ |
Upload File : |
'''Test Tools/scripts/fixcid.py.''' from io import StringIO import os, os.path import runpy import sys from test import support from test.test_tools import skip_if_missing, scriptsdir import unittest skip_if_missing() class Test(unittest.TestCase): def test_parse_strings(self): old1 = 'int xx = "xx\\"xx"[xx];\n' old2 = "int xx = 'x\\'xx' + xx;\n" output = self.run_script(old1 + old2) new1 = 'int yy = "xx\\"xx"[yy];\n' new2 = "int yy = 'x\\'xx' + yy;\n" self.assertMultiLineEqual(output, "1\n" "< {old1}" "> {new1}" "{new1}" "2\n" "< {old2}" "> {new2}" "{new2}".format(old1=old1, old2=old2, new1=new1, new2=new2) ) def test_alter_comments(self): output = self.run_script( substfile= "xx yy\n" "*aa bb\n", args=("-c", "-",), input= "/* xx altered */\n" "int xx;\n" "/* aa unaltered */\n" "int aa;\n", ) self.assertMultiLineEqual(output, "1\n" "< /* xx altered */\n" "> /* yy altered */\n" "/* yy altered */\n" "2\n" "< int xx;\n" "> int yy;\n" "int yy;\n" "/* aa unaltered */\n" "4\n" "< int aa;\n" "> int bb;\n" "int bb;\n" ) def test_directory(self): os.mkdir(support.TESTFN) self.addCleanup(support.rmtree, support.TESTFN) c_filename = os.path.join(support.TESTFN, "file.c") with open(c_filename, "w") as file: file.write("int xx;\n") with open(os.path.join(support.TESTFN, "file.py"), "w") as file: file.write("xx = 'unaltered'\n") script = os.path.join(scriptsdir, "fixcid.py") output = self.run_script(args=(support.TESTFN,)) self.assertMultiLineEqual(output, "{}:\n" "1\n" '< int xx;\n' '> int yy;\n'.format(c_filename) ) def run_script(self, input="", *, args=("-",), substfile="xx yy\n"): substfilename = support.TESTFN + ".subst" with open(substfilename, "w") as file: file.write(substfile) self.addCleanup(support.unlink, substfilename) argv = ["fixcid.py", "-s", substfilename] + list(args) script = os.path.join(scriptsdir, "fixcid.py") with support.swap_attr(sys, "argv", argv), \ support.swap_attr(sys, "stdin", StringIO(input)), \ support.captured_stdout() as output, \ support.captured_stderr(): try: runpy.run_path(script, run_name="__main__") except SystemExit as exit: self.assertEqual(exit.code, 0) return output.getvalue()