????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.55 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/ |
Upload File : |
import unittest
from test import support
import os
import sys
import subprocess
SYMBOL_FILE = support.findfile('symbol.py')
GRAMMAR_FILE = os.path.join(os.path.dirname(__file__),
'..', '..', 'Include', 'graminit.h')
TEST_PY_FILE = 'symbol_test.py'
class TestSymbolGeneration(unittest.TestCase):
def _copy_file_without_generated_symbols(self, source_file, dest_file):
with open(source_file) as fp:
lines = fp.readlines()
with open(dest_file, 'w') as fp:
fp.writelines(lines[:lines.index("#--start constants--\n") + 1])
fp.writelines(lines[lines.index("#--end constants--\n"):])
def _generate_symbols(self, grammar_file, target_symbol_py_file):
proc = subprocess.Popen([sys.executable,
SYMBOL_FILE,
grammar_file,
target_symbol_py_file], stderr=subprocess.PIPE)
stderr = proc.communicate()[1]
return proc.returncode, stderr
def compare_files(self, file1, file2):
with open(file1) as fp:
lines1 = fp.readlines()
with open(file2) as fp:
lines2 = fp.readlines()
self.assertEqual(lines1, lines2)
@unittest.skipIf(not os.path.exists(GRAMMAR_FILE),
'test only works from source build directory')
def test_real_grammar_and_symbol_file(self):
output = support.TESTFN
self.addCleanup(support.unlink, output)
self._copy_file_without_generated_symbols(SYMBOL_FILE, output)
exitcode, stderr = self._generate_symbols(GRAMMAR_FILE, output)
self.assertEqual(b'', stderr)
self.assertEqual(0, exitcode)
self.compare_files(SYMBOL_FILE, output)
if __name__ == "__main__":
unittest.main()