How to use safepath method in Nose

Best Python code snippet using nose

runtests.py

Source:runtests.py Github

copy

Full Screen

1#!/usr/bin/env python2# inspired by - http://mxr.mozilla.org/mozilla-central/source/testing/xpcshell/runxpcshelltests.py3import sys, os, os.path, signal, re4from optparse import OptionParser5from subprocess import Popen, PIPE, STDOUT6# Uses jsshell https://developer.mozilla.org/en/Introduction_to_the_JavaScript_shell7def safePath(path):8 return path.replace("\\","/");9class ProcessingTests(object):10 testharnessdir = safePath(os.path.dirname(os.path.abspath(__file__)));11 toolsdir = safePath(os.path.dirname(os.path.abspath(__file__)));12 testsPassed = 013 testsFailed = 014 testsFailedKnown = 015 linesCalled = set()16 codeLines = set()17 def __init__(self):18 self.knownFailures = set()19 f = open(safePath(os.path.join(self.toolsdir, '..', 'test', 'KNOWN-FAILURES')), 'r')20 for line in f.readlines():21 if line.startswith('#') or line.lstrip().rstrip() == '':22 continue23 self.knownFailures.add(line.rstrip('\r\n'))24 f.close()25 def isKnownFailure(self, testpath):26 # Assumes abs path for testpath (path already Unix format)27 pos = testpath.find("/test/")28 if pos > -1 and testpath[pos+1:] in self.knownFailures:29 return True30 else:31 return False32 def shouldSkipTest(self, testPattern, testPath):33 if testPattern:34 # Normalize paths to Unix style35 testPattern = testPattern.replace('\\', '/')36 testPath = testPath.replace('\\', '/')37 # we support *.js and * .pde tests, as well as passing dirs.38 # assume a dir name doesn't end with .js or .pde39 if testPattern.endswith('.js') or testPattern.endswith('.pde'):40 if testPath.endswith(testPattern):41 return False42 else:43 # assume this is a dir, so just look for the pattern in the path44 if testPath.find(testPattern) > -1:45 return False46 return True47 def runParserTests(self, jsshell, testPattern=None, summaryOnly=False, processingPath=None):48 """Get all .pjs in test/parser/ files as JSON, and run through the test harness, faking a DOM"""49 jsshell = safePath(os.path.abspath(jsshell))50 parsertestdir = safePath(os.path.join(self.toolsdir, '..', 'test', 'parser'))51 processing_js = None52 if processingPath:53 processing_js = safePath(os.path.join(self.toolsdir, '..', processingPath.replace('/', os.sep)))54 else:55 processing_js = safePath(os.path.join(self.toolsdir, '..', 'processing.js'))56 print "\nRunning processing.js Parser Tests:"57 for root, dirs, filenames in os.walk(parsertestdir):58 for filename in filenames:59 sys.stdout.flush()60 sys.stderr.flush()61 # If a single test file name is given, only test that file62 fullpath = safePath(os.path.abspath(os.path.join(root, filename)))63 if testPattern and self.shouldSkipTest(testPattern, fullpath):64 continue65 if filename.endswith('.pde'):66 one_test = 'var parserTest = {name:"%s", body: snarf("%s")};\n' % (fullpath,67 safePath(os.path.relpath(fullpath)))68 testCmd = [jsshell,69 '-f', safePath(os.path.join(self.toolsdir, 'fake-dom.js')),70 '-f', processing_js, #os.path.join(self.toolsdir, '..', 'processing.js'),71 '-e', one_test,72 '-f', safePath(os.path.join(self.toolsdir, 'fake-extensions.js')),73 '-f', safePath(os.path.join(self.toolsdir, 'test-harness.js'))]74 proc = Popen(testCmd, stdout=PIPE, stderr=PIPE)75 stdout, stderr = proc.communicate()76 if stderr:77 # we failed to parse, and died in the js shell78 if self.isKnownFailure(fullpath):79 print "KNOWN-FAILURE: " + fullpath80 self.testsFailedKnown += 181 else:82 print "TEST-FAILED: " + fullpath83 print stderr84 self.testsFailed += 185 elif stdout:86 # TEST-SUMMARY: passed/failed87 m = re.search('^TEST-SUMMARY: (\d+)/(\d+)', stdout, re.MULTILINE)88 if m and m.group:89 self.testsPassed += int(m.group(1))90 if self.isKnownFailure(fullpath):91 self.testsFailedKnown += int(m.group(2))92 else:93 self.testsFailed += int(m.group(2))94 if int(m.group(2)) > 0:95 if self.isKnownFailure(fullpath):96 print "KNOWN-FAILURE: " + fullpath97 else:98 print "TEST-FAILED: " + fullpath99 print re.sub("\n?TEST-SUMMARY: (\d+)\/(\d+)(\nLINES-CALLED: ([\d,]+))?\n?", "", stdout)100 print stderr101 else:102 if self.isKnownFailure(fullpath):103 # we shouldn't pass if we are expecting to fail!104 print "TEST-FAILED (known failure passed!): " + fullpath105 self.testsPassed -= 1106 self.testsFailed += 1107 else:108 if not summaryOnly:109 print "TEST-PASSED: " + fullpath110 else:111 # Shouldn't happen!112 self.testsFailed += 1113 print "TEST-FAILED: " + fullpath + ". Test died:"114 print stdout115 m2 = re.search('^LINES-CALLED: ([\d,]+)', stdout, re.MULTILINE)116 if m2 and m2.group:117 for ln in m2.group(1).split(','):118 self.linesCalled.add(int(ln))119 def runUnitTests(self, jsshell, testPattern=None, summaryOnly=False, processingPath=None):120 """Run all .js unit tests in test/unit through the test harness."""121 # TODO: add support for doing .pjs unit tests.122 unittestdir = safePath(os.path.join(self.toolsdir, '..', 'test', 'unit'))123 jsshell = safePath(os.path.abspath(jsshell))124 processing_js = None125 if processingPath:126 processing_js = safePath(os.path.join(self.toolsdir, '..', processingPath.replace('/', os.sep)))127 else:128 processing_js = safePath(os.path.join(self.toolsdir, '..', 'processing.js'))129 print "\nRunning processing.js Unit Tests:"130 for root, dirs, filenames in os.walk(unittestdir):131 for filename in filenames:132 sys.stdout.flush()133 sys.stderr.flush()134 # If a single test file name is given, only test that file135 fullpath = safePath(os.path.abspath(os.path.join(root, filename)))136 if testPattern and self.shouldSkipTest(testPattern, fullpath):137 continue138 testCmd = None139 if filename.endswith('.js'):140 # Read the test file so we can wrap it properly:141 f = open(fullpath, 'r')142 testFile = ''.join(f.readlines()).replace("'", "\'").replace('"', '\"');143 f.close()144 # We wrap all tests in a function so as to replace the context with the Processing context145 wrapper = "function _testWrapper(ctx) { with (ctx) { %s \n _runTest(); }}\n" % testFile146 testCmd = [jsshell, '-e', 'var _testName = "%s"; %s;' % (fullpath, wrapper),147 '-f', safePath(os.path.join(self.toolsdir, 'fake-dom.js')),148 '-f', processing_js, #os.path.join(self.toolsdir, '..', 'processing.js'),149 '-f', safePath(os.path.join(self.toolsdir, 'test-harness.js'))]150 elif filename.endswith('.pde'):151 execTest = 'eval(new Processing(canvas, \'UnitTests();\' + snarf("%s") + \'\\n_printTestSummary();\'));' % safePath(os.path.relpath(fullpath))152 testCmd = [jsshell,153 '-f', safePath(os.path.join(self.toolsdir, 'fake-dom.js')),154 '-f', processing_js, #os.path.join(self.toolsdir, '..', 'processing.js'),155 '-f', safePath(os.path.join(self.toolsdir, 'test-harness-lib.js')),156 '-e', execTest]157 else:158 continue159 proc = Popen(testCmd, stdout=PIPE, stderr=PIPE)160 stdout, stderr = proc.communicate()161 if stdout:162 # TEST-SUMMARY: passed/failed163 m = re.search('^TEST-SUMMARY: (\d+)/(\d+)', stdout, re.MULTILINE)164 if m and m.group:165 self.testsPassed += int(m.group(1))166 if self.isKnownFailure(fullpath):167 self.testsFailedKnown += int(m.group(2))168 else:169 self.testsFailed += int(m.group(2))170 if int(m.group(2)) > 0:171 if self.isKnownFailure(fullpath):172 print "KNOWN-FAILURE: " + fullpath173 else:174 print "TEST-FAILED: " + fullpath175 print re.sub("\n?TEST-SUMMARY: (\d+)\/(\d+)(\nLINES-CALLED: ([\d,]+))?\n?", "", stdout)176 print stderr177 else:178 if self.isKnownFailure(fullpath):179 # we shouldn't pass if we are expecting to fail!180 print "TEST-FAILED (known failure passed!): " + fullpath181 self.testsPassed -= 1182 self.testsFailed += 1183 else:184 if not summaryOnly:185 print "TEST-PASSED: " + fullpath186 else:187 # Shouldn't happen!188 self.testsFailed += 1189 print "TEST-FAILED: " + fullpath + ". Test died:"190 print stdout191 elif stderr:192 # Shouldn't happen!193 self.testsFailed += 1194 print "TEST-FAILED: " + fullpath + ". Test exited early:"195 print stderr196 m2 = re.search('^LINES-CALLED: ([\d,]+)', stdout, re.MULTILINE)197 if m2 and m2.group:198 for ln in m2.group(1).split(','):199 self.linesCalled.add(int(ln))200 def initCodeLines(self, processingPath):201 if processingPath:202 processing_js = safePath(os.path.join(self.toolsdir, '..', processingPath.replace('/', os.sep)))203 else:204 processing_js = safePath(os.path.join(self.toolsdir, '..', 'processing.js'))205 f = open(processing_js, 'r')206 for line in f.readlines():207 if line.startswith('var __pjsCodeLines'):208 for ln in line.partition('[')[2].partition(']')[0].split(','):209 self.codeLines.add(int(ln))210 break211 f.close()212def main():213 parser = OptionParser()214 parser.add_option("-s", "--summary-only",215 action="store_true", dest="summaryOnly", default=False,216 help="only print failed tests info.")217 parser.add_option("-p", "--parser-only",218 action="store_true", dest="parserOnly", default=False,219 help="only run parser tests.")220 parser.add_option("-u", "--unit-only",221 action="store_true", dest="unitOnly", default=False,222 help="only run unit tests.")223 parser.add_option("-t", "--single-test",224 type="string", dest="testPattern", default=None,225 help="single test filename or dir to be tested")226 parser.add_option("-l", "--library",227 type="string", dest="processingPath", default=None,228 help="use a different processing.js library")229 parser.add_option("-c", "--test-coverage",230 type="string", dest="coverageResultPath", default=None,231 help="save test coverage results to the file")232 options, args = parser.parse_args()233 if len(args) < 1:234 print >>sys.stderr, """Usage: %s <path to jsshell>235 or: %s --test singletest.pjs <path to jsshell>""" % (sys.argv[0], sys.argv[0])236 sys.exit(1)237 ptests = ProcessingTests()238 ptests.initCodeLines(options.processingPath)239 if options.parserOnly:240 ptests.runParserTests(args[0],241 testPattern=options.testPattern,242 summaryOnly=options.summaryOnly,243 processingPath=options.processingPath)244 elif options.unitOnly:245 ptests.runUnitTests(args[0],246 testPattern=options.testPattern,247 summaryOnly=options.summaryOnly,248 processingPath=options.processingPath)249 else:250 ptests.runParserTests(args[0],251 testPattern=options.testPattern,252 summaryOnly=options.summaryOnly,253 processingPath=options.processingPath)254 ptests.runUnitTests(args[0],255 testPattern=options.testPattern,256 summaryOnly=options.summaryOnly,257 processingPath=options.processingPath)258 print "\nTEST SUMMARY: %s passed, %s failed (%s known), %s total" % (ptests.testsPassed,259 ptests.testsFailed,260 ptests.testsFailedKnown,261 (ptests.testsPassed + ptests.testsFailed + ptests.testsFailedKnown))262 if len(ptests.codeLines) > 0:263 print "\nCODE COVERAGE: %s called, %s total, %s percent" % (len(ptests.linesCalled),264 len(ptests.codeLines),265 round(len(ptests.linesCalled) * 100.0 / len(ptests.codeLines), 1))266 if options.coverageResultPath:267 f = open(options.coverageResultPath, 'w')268 for line in sorted(ptests.codeLines):269 if line in ptests.linesCalled:270 f.write("+%s\n" % (line))271 else:272 f.write("-%s\n" % (line))273 f.close()274if __name__ == '__main__':...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1"""2skill THEIA-IDE3Copyright (C) 2018 Andreas Lorensen4This program is free software: you can redistribute it and/or modify5it under the terms of the GNU General Public License as published by6the Free Software Foundation, either version 3 of the License, or7(at your option) any later version.8This program is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11GNU General Public License for more details.12You should have received a copy of the GNU General Public License13along with this program. If not, see <http://www.gnu.org/licenses/>.14"""15from mycroft import MycroftSkill, intent_file_handler16import os17import tarfile18import subprocess19import signal20from psutil import virtual_memory21class TheiaIde(MycroftSkill):22 def __init__(self):23 MycroftSkill.__init__(self)24 def initialize(self):25 self.log.info("Initialize THEIA IDE...")26 if (self.settings.get("workspace") is not True or27 self.settings.get("workspace") == ''):28 self.settings["workspace"] = str(self.config_core.get('data_dir') +29 '/' +30 self.config_core.get('skills', {})31 .get('msm', {})32 .get('directory'))33 if (self.settings.get("theia installed") is not True or34 self.settings.get("theia installed") is None):35 self.install_theia()36 if not self.pid_exists(self.settings.get("theia_pid")):37 self.settings["theia_pid"] = None38 if (self.settings.get("auto_start") and39 self.settings.get("theia_pid") is None):40 self.run_theia()41 @intent_file_handler('stop.intent')42 def handle_ide_stop(self, message):43 if self.stop_theia():44 self.speak_dialog('ide_stopped')45 else:46 self.speak_dialog('ide_is_not_running')47 @intent_file_handler('start.intent')48 def handle_ide_start(self, message):49 url = os.uname().nodename + " kolon 3000"50 if self.run_theia():51 self.speak_dialog('ide_started', data={"url": url})52 else:53 self.speak_dialog('ide_already_running', data={"url": url})54 @intent_file_handler('restart.intent')55 def handle_ide_restart(self, message):56 url = os.uname().nodename + " kolon 3000"57 self.stop_theia()58 if self.run_theia():59 self.speak_dialog('ide_started', data={"url": url})60 def stop_theia(self):61 self.log.info("Stopping IDE")62 SafePath = self.file_system.path63 if self.settings.get("theia_pid") is not None:64 try:65 os.killpg(self.settings.get("theia_pid"), signal.SIGTERM)66 except Exception:67 proc = subprocess.Popen('pkill -f "yarn theia start"',68 cwd=SafePath,69 preexec_fn=os.setsid,70 shell=True)71 proc.wait()72 self.settings["theia_pid"] = None73 return True74 else:75 return False76 def run_theia(self):77 if self.settings.get("theia_pid)") is None:78 self.log.info("Starting IDE")79 SafePath = self.file_system.path80 theia_proc = subprocess.Popen(SafePath + '/theia_run.sh ' +81 self.settings.get("workspace") +82 ' >/dev/null 2>/dev/null ',83 cwd=SafePath,84 preexec_fn=os.setsid, shell=True)85 self.settings["theia_pid"] = theia_proc.pid86 return True87 else:88 return False89 def install_theia(self):90 SafePath = self.file_system.path91 platform = 'Unknown'92 if self.config_core.get('enclosure', {}).get('platform'):93 platform = self.config_core.get('enclosure', {}).get('platform')94 if not os.path.isfile(SafePath + '/theia_run.sh'):95 self.speak_dialog('install_start')96 GitRepo = ('https://api.github.com/repos/andlo/' +97 'theia-for-mycroft/releases/latest')98 if platform == "mycroft_mark_1":99 self.log.info('Platform Mark_1 - ' +100 'ThiaIDE cant run on a this device')101 self.speak_dialog('platform_not_supported')102 self.settings['theia installed'] = 'False'103 return104 elif platform == "picroft":105 self.log.info("Downloading precompiled package for the " +106 platform + " platform.")107 self.speak_dialog('downloading', data={"platform": platform})108 curl = ('curl -s ' + GitRepo + ' | jq -r ".assets[] ' +109 ' | select(.name | contains(\\"picroft\\")) ' +110 ' | .browser_download_url"' +111 ' | wget -O theiaide.tgz -i - ' +112 ' >/dev/null 2>/dev/null')113 proc = subprocess.Popen(curl, cwd=SafePath,114 preexec_fn=os.setsid,115 shell=True)116 proc.wait()117 precompiled = True118 else:119 self.log.info('Platform ' + platform +120 ' - no precompiled package')121 self.speak_dialog('cloning',122 data={"platform": platform})123 mem = int(virtual_memory().total/(1024**2))124 if mem < 4000:125 self.log.info('Memmory on device is ' + mem +126 ' that is not enough.')127 self.log.info('Sorry.')128 self.speak_dialog('cant.install.low.memmory')129 else:130 self.log.info('Downloading and compiling')131 self.log.info("Cloning and build package for the " +132 platform + " platform.")133 cmd = ('git clone ' +134 'https://github.com/andlo/theia-for-mycroft.git')135 proc = subprocess.Popen(cmd,136 cwd=SafePath,137 preexec_fn=os.setsid,138 shell=True)139 proc.wait()140 folder = SafePath + '/theia-for-mycroft'141 proc = subprocess.Popen('mv ' + folder + '/* .',142 cwd=SafePath,143 preexec_fn=os.setsid,144 shell=True)145 proc.wait()146 proc = subprocess.Popen('rmdir -rf ' + folder,147 cwd=SafePath,148 preexec_fn=os.setsid,149 shell=True)150 proc.wait()151 precompiled = False152 try:153 if precompiled is True:154 filename = SafePath + '/theiaide.tgz'155 self.log.info("Unpacking....")156 package = tarfile.open(filename)157 package.extractall(SafePath)158 package.close()159 os.remove(filename)160 if precompiled is False:161 self.log.info('Compiling THEIA IDE - ' +162 'This can take a while....')163 cmd = SafePath + "/build_release.sh >/dev/null 2>/dev/null"164 proc = subprocess.Popen(cmd,165 cwd=SafePath,166 preexec_fn=os.setsid,167 shell=True)168 proc.wait()169 self.log.info("Installed OK")170 self.settings['theia installed'] = 'True'171 self.speak_dialog('installed_OK')172 return True173 except Exception:174 self.log.info("Theia not installed - something went wrong!")175 self.speak_dialog('installed_BAD')176 return False177 def pid_exists(self, pid):178 try:179 os.kill(pid, 0)180 return True181 except Exception:182 return False183def create_skill():...

Full Screen

Full Screen

views.py

Source:views.py Github

copy

Full Screen

...28def createdir(request):29 path = request.POST.get('d', '')30 name = request.POST.get('n', '')31 if path and name:32 os.makedirs(safepath(settings.ROXY_ROOT, path, name))33 return ok()34@csrf_exempt35def deletedir(request):36 path = request.POST.get('d', '')37 if path:38 shutil.rmtree(safepath(settings.ROXY_ROOT, path))39 return ok()40@csrf_exempt41def movedir(request):42 path_from = request.POST.get('d', '')43 path_to = request.POST.get('n', '')44 if path_from and path_to:45 shutil.move(46 safepath(settings.ROXY_ROOT, path_from),47 safepath(settings.ROXY_ROOT, path_to)48 )49 return ok()50@csrf_exempt51def copydir(request):52 path_from = request.POST.get('d', '')53 path_to = request.POST.get('n', '')54 if path_from and path_to:55 shutil.copytree(56 safepath(settings.ROXY_ROOT, path_from),57 safepath(settings.ROXY_ROOT, path_to, os.path.basename(path_from))58 )59 return ok()60@csrf_exempt61def renamedir(request):62 path = request.POST.get('d', '')63 new_name = request.POST.get('n')64 if path and new_name:65 shutil.move(66 safepath(settings.ROXY_ROOT, path),67 safepath(settings.ROXY_ROOT, os.path.dirname(path), new_name)68 )69 return ok()70@csrf_exempt71def fileslist(request):72 rel_path = request.GET.get('d', '.')73 full_path = os.path.join(settings.ROXY_ROOT, rel_path)74 files = []75 for fname in next(os.walk(full_path))[2]:76 abs_path = os.path.join(full_path, fname)77 file_info = {78 'p': '/' + os.path.join(rel_path, fname),79 'w': 0, 'h': 0, 's': 0, 't': 080 }81 stats = os.stat(abs_path)82 file_info['s'] = stats.st_size83 file_info['t'] = stats.st_mtime84 try:85 im = Image.open(abs_path)86 file_info['w'], file_info['h'] = im.size87 except IOError:88 pass89 files.append(file_info)90 return json_response(files)91@csrf_exempt92def upload(request):93 path = request.POST.get('d', '')94 files = request.FILES.getlist('files[]')95 if path:96 for mfile in files:97 upload = Upload(mfile)98 return ok()99@csrf_exempt100def deletefile(request):101 path = request.POST.get('f', '')102 if path:103 os.remove(safepath(settings.ROXY_ROOT, path))104 return ok()105@csrf_exempt106def uploaddir(request):107 return err()108@csrf_exempt109def movefile(request):110 path_from = request.POST.get('f', '')111 path_to = request.POST.get('n', '')112 if path_from and path_to:113 shutil.move(114 safepath(settings.ROXY_ROOT, path_from),115 safepath(settings.ROXY_ROOT, path_to)116 )117 return ok()118@csrf_exempt119def copyfile(request):120 path_from = request.POST.get('d', '')121 path_to = request.POST.get('n', '')122 if path_from and path_to:123 shutil.copy(124 safepath(settings.ROXY_ROOT, path_from),125 safepath(settings.ROXY_ROOT, path_to, os.path.basename(path_from))126 )127 return ok()128@csrf_exempt129def renamefile(request):130 path = request.POST.get('f', '')131 new_name = request.POST.get('n')132 if path and new_name:133 shutil.move(134 safepath(settings.ROXY_ROOT, path),135 safepath(settings.ROXY_ROOT, os.path.dirname(path), new_name)136 )137 return ok()138@csrf_exempt139def thumb(request):140 path = request.GET.get('f', '')141 width = request.GET.get('w', 100)142 height = request.GET.get('h', 100)143 if path:144 response = HttpResponse(content_type='image/jpeg')145 image = Image.open(safepath(settings.ROXY_ROOT, path)).convert('RGB')146 image.thumbnail((width, height))147 image.save(response, 'JPEG')148 return response149 return err()150@csrf_exempt151def download(request):152 path = request.GET.get('f', '')153 real_path = safepath(settings.ROXY_ROOT, path)154 filename = os.path.basename(real_path)155 response = FileResponse(open(real_path, 'rb'))156 response['Content-Disposition'] = 'attachment; filename=%s' % filename157 return response158@csrf_exempt159def downloaddir(request):160 path = request.GET.get('d', '')161 real_path = safepath(settings.ROXY_ROOT, path)162 dirname = os.path.split(real_path)[-1]163 pid, tmp_file = tempfile.mkstemp()164 filename = shutil.make_archive(165 os.path.basename(tmp_file),166 'zip', real_path167 )168 response = FileResponse(open(filename, 'rb'), content_type='application/zip')169 response['Content-Disposition'] = 'attachment; filename=%s.zip' % dirname...

Full Screen

Full Screen

coffee_safe.py

Source:coffee_safe.py Github

copy

Full Screen

1#!/usr/bin/python2import os3import csv4import json5from coffee_cookie import *6class CoffeeSafe:7 safePath = None8 loginSite ="https://venmo.com/account/sign-in/"9 loginUsername = None10 loginPassword = None11 loginUsernameSelector = ".auth-form-input[data-test=username]"12 loginPasswordSelector = ".auth-form-input[data-test=password]"13 loginSubmitSelector = ".auth-button"14 loginSMSSelector = ".mfa-button-code-prompt"15 loginMFAFormSelector = ".auth-form-input"16 17 cookie = None18 mfaFilename = None19 def __init__(self, safePath, venmoCredsFilename="venmo.csv", cookieFilename="coffee_cookie", mfaFilename="coffee_mfa"):20 self.safePath = safePath21 self.mfaFilename = mfaFilename22 venmoPath = os.path.join(safePath, venmoCredsFilename)23 self.setupFromConfigFile(venmoPath)24 # self.cookie = CoffeeCookie(safePath, cookieFilename)25 def setupFromConfigFile(self, safePath):26 with open(safePath, 'rb') as csvfile:27 csvreader = csv.reader(csvfile)28 csvcontents = [e for e in csvreader]29 self.setupFromConfigFileContents(csvcontents)30 def setupFromConfigFileContents(self, config):31 configKeys = config[0]32 configValues = config[1]33 configDict = dict(zip(configKeys, configValues))34 self.loginUsername = configDict["username"]35 self.loginPassword = configDict["password"]36 def verificationNumberPath(self):37 return os.path.join(self.safePath, self.mfaFilename)38 def writeVerificationNumber(self, number):39 numPath = self.verificationNumberPath()40 with open(numPath, 'w+') as numFile:41 numFile.write(number)42 return True43 def readVerificationNumber(self):44 numPath = self.verificationNumberPath()45 with open(numPath, 'rb') as numFile:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Nose automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful