Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: autotest.py

Issue 29350244: Issue 4374 - Made Python code part of jshydra comply with our coding practices (Closed)
Patch Set: Rebased and fixed typo Created Aug. 30, 2016, 12:01 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « abp_rewrite.py ('k') | tox.ini » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: autotest.py
===================================================================
--- a/autotest.py
+++ b/autotest.py
@@ -13,30 +13,34 @@
def run_tests():
- testDir = os.path.join(os.path.dirname(__file__), 'autotest')
+ test_dir = os.path.join(os.path.dirname(__file__), 'autotest')
succeed = True
- for file in os.listdir(testDir):
- if not re.search(r'^test_.*\.js$', file):
+ for filename in os.listdir(test_dir):
+ if not re.search(r'^test_.*\.js$', filename):
continue
- file = os.path.join(testDir, file)
- handle = open(file, 'r')
+ filename = os.path.join(test_dir, filename)
name = None
- arguments = None
- for line in handle:
- match = re.search(r'^//\s*([A-Za-z]+):\s*(.*?)\s*$', line)
- if match and match.group(1).lower() == 'name':
- name = match.group(2)
- elif match and match.group(1).lower() == 'arguments':
- arguments = match.group(2).split(' ')
- handle.close()
+ args = None
- if arguments == None:
+ with open(filename, 'r') as file:
+ for line in file:
+ match = re.search(r'^//\s*([A-Za-z]+):\s*(.*?)\s*$', line)
+ if match:
+ key = match.group(1).lower()
+ if key == 'name':
+ name = match.group(2)
+ elif key == 'arguments':
Sebastian Noack 2016/08/30 12:03:06 I accidentally replaced this string as well when r
Vasily Kuznetsov 2016/08/30 13:25:30 Oops, I missed it too. Good catch!
+ args = match.group(2).split()
+
+ if args is None:
continue
- output = abp_rewrite.rewrite_js(arguments, file)
- expected = open(file + '.expected', 'rU').read()
+ output = abp_rewrite.rewrite_js(args, filename)
+ with open(filename + '.expected', 'rU') as file:
+ expected = file.read()
+
if output == expected:
print(name + ' passed')
else:
@@ -44,8 +48,8 @@
print(name + ' failed! Log:')
for line in difflib.unified_diff(expected.splitlines(),
output.splitlines(),
- fromfile=file + '.expected',
- tofile=file + '.output'):
+ fromfile=filename + '.expected',
+ tofile=filename + '.output'):
print(line)
print()
« no previous file with comments | « abp_rewrite.py ('k') | tox.ini » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld