Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # June 20, 2018
- # Script to update browser test files
- # Darko
- ASYNC_PATH = '/Users/jmortenson/Code/zendesk/support-rule-admin/spec/browser/async/scenarios'
- SYNC_PATH = '/Users/jmortenson/Code/zendesk/support-rule-admin/spec/browser/scenarios'
- # os.walk(path) returns a triple with: (full_path, list of subdirectories, list of files in path directory)
- import os
- for child in os.walk(ASYNC_PATH):
- if child[2] == []:
- continue
- for filename in child[2]:
- lines = []
- with open(child[0] + '/' + filename, 'r') as f:
- lines = f.readlines()
- for linenumber, line in enumerate(lines):
- if 'beforeEach(() => browser.respondWithAccount());' in line or 'beforeEach(() => browser.respondWithUser());' in line:
- indent = line[0:line.find('b')].count(' ') * ' '
- lines.insert(linenumber, indent + 'beforeEach(() => browser.respondWithTimezones());' + '\n')
- break
- with open(child[0] + '/' + filename, 'w') as f:
- f.writelines(lines)
- for child in os.walk(SYNC_PATH):
- if child[2] == []:
- continue
- for filename in child[2]:
- lines = []
- with open(child[0] + '/' + filename, 'r') as f:
- lines = f.readlines()
- for linenumber, line in enumerate(lines):
- if 'browser.respondWithAccount();' in line or 'browser.respondWithUser();' in line:
- indent = line[0:line.find('b')].count(' ') * ' '
- lines.insert(linenumber, indent + 'browser.respondWithTimezones();' + '\n')
- break
- with open(child[0] + '/' + filename, 'w') as f:
- f.writelines(lines)
Add Comment
Please, Sign In to add comment