Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(167622)

Side by Side Diff: Lib/test/test_keyword.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_json/test_tool.py ('k') | Lib/test/test_logging.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import keyword 1 import keyword
2 import unittest 2 import unittest
3 from test import support 3 from test import support
4 import filecmp 4 import filecmp
5 import os 5 import os
6 import sys 6 import sys
7 import subprocess 7 import subprocess
8 import shutil 8 import shutil
9 import textwrap 9 import textwrap
10 10
(...skipping 28 matching lines...) Expand all
39 class TestKeywordGeneration(unittest.TestCase): 39 class TestKeywordGeneration(unittest.TestCase):
40 40
41 def _copy_file_without_generated_keywords(self, source_file, dest_file): 41 def _copy_file_without_generated_keywords(self, source_file, dest_file):
42 with open(source_file, 'rb') as fp: 42 with open(source_file, 'rb') as fp:
43 lines = fp.readlines() 43 lines = fp.readlines()
44 nl = lines[0][len(lines[0].strip()):] 44 nl = lines[0][len(lines[0].strip()):]
45 with open(dest_file, 'wb') as fp: 45 with open(dest_file, 'wb') as fp:
46 fp.writelines(lines[:lines.index(b"#--start keywords--" + nl) + 1]) 46 fp.writelines(lines[:lines.index(b"#--start keywords--" + nl) + 1])
47 fp.writelines(lines[lines.index(b"#--end keywords--" + nl):]) 47 fp.writelines(lines[lines.index(b"#--end keywords--" + nl):])
48 48
49 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
49 def _generate_keywords(self, grammar_file, target_keyword_py_file): 50 def _generate_keywords(self, grammar_file, target_keyword_py_file):
50 proc = subprocess.Popen([sys.executable, 51 proc = subprocess.Popen([sys.executable,
51 KEYWORD_FILE, 52 KEYWORD_FILE,
52 grammar_file, 53 grammar_file,
53 target_keyword_py_file], stderr=subprocess.PIPE ) 54 target_keyword_py_file], stderr=subprocess.PIPE )
54 stderr = proc.communicate()[1] 55 stderr = proc.communicate()[1]
55 return proc.returncode, stderr 56 return proc.returncode, stderr
56 57
57 @unittest.skipIf(not os.path.exists(GRAMMAR_FILE), 58 @unittest.skipIf(not os.path.exists(GRAMMAR_FILE),
58 'test only works from source build directory') 59 'test only works from source build directory')
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 self.assertRegex(stderr, b'(?ms)' + NONEXISTENT_FILE.encode()) 130 self.assertRegex(stderr, b'(?ms)' + NONEXISTENT_FILE.encode())
130 131
131 def test_missing_keywords_py_file_produces_error(self): 132 def test_missing_keywords_py_file_produces_error(self):
132 rc, stderr = self._generate_keywords(os.devnull, NONEXISTENT_FILE) 133 rc, stderr = self._generate_keywords(os.devnull, NONEXISTENT_FILE)
133 self.assertNotEqual(rc, 0) 134 self.assertNotEqual(rc, 0)
134 self.assertRegex(stderr, b'(?ms)' + NONEXISTENT_FILE.encode()) 135 self.assertRegex(stderr, b'(?ms)' + NONEXISTENT_FILE.encode())
135 136
136 137
137 if __name__ == "__main__": 138 if __name__ == "__main__":
138 unittest.main() 139 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_json/test_tool.py ('k') | Lib/test/test_logging.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+