How to use get_pwd method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...47 return getattr(self, 'cmd_' + cmdname, None)48 def lookupRel(self, name, adaptTo, base=None):49 shell = self.shell50 if base is None:51 base = shell.get_pwd()52 if name is None:53 ob = base54 elif name[0] == '$':55 o = shell.getvar(name[1:])56 if type(o) is str:57 ob = base[name]58 else:59 ob = o60 else:61 ob = base[name]62 binding.suggestParentComponent(shell, None, ob)63 if adaptTo is None:64 aob = ob65 else:66 aob = adapt(ob, adaptTo, None)67 if aob is not None:68 binding.suggestParentComponent(shell, None, aob)69 return ob, aob70 class cmd_cd(ShellCommand):71 """cd [name-or-$var] -- change directory72 with name, change current context to one named73 without name, change current context back to startup context"""74 args = ('', 0, 1)75 def cmd(self, cmd, args, stderr, **kw):76 shell = self.shell77 interactor = self.interactor78 last = shell.get_pwd()79 if not args:80 c = shell.get_home()81 ob = adapt(c, naming.IBasicContext, None)82 else:83 try:84 c, ob = interactor.lookupRel(args[0], naming.IBasicContext)85 except KeyError:86 print >>stderr, '%s: %s: no such variable' % (cmd, args[0])87 return88 except exceptions.NameNotFound:89 print >>stderr, '%s: %s: not found' % (cmd, args[0])90 return91 if ob is None:92 print >>stderr, '(not a context... using alternate handler)\n'93 shell.do_cd(c)94 shell.handle(c)95 shell.do_cd(last)96 else:97 shell.do_cd(ob)98 cmd_cd = binding.Make(cmd_cd)99 class ls_common(ShellCommand):100 """ls [-1|-l] [-s] [-R] [-r] [name-or-$var] -- list namespace contents101-1\tsingle column format102-l\tlong format (show object repr)103-R\trecursive listing104-r\treverse order105-s\tdon't sort list106name\tlist object named, else current context"""107 args = ('1lRrs', 0, 1)108 def cmd(self, cmd, opts, args, stdout, stderr, ctx=None, **kw):109 shell = self.shell110 interactor = self.interactor111 name = None112 if args:113 name = args[0]114 try:115 ob, ctx = interactor.lookupRel(name, naming.IReadContext, base=ctx)116 except KeyError:117 print >>stderr, '%s: %s: no such variable' % (cmd, args[0])118 return119 except exceptions.NameNotFound:120 print >>stderr, '%s: %s not found' % (cmd, args[0])121 return122 if ctx is None:123 if args:124 print >>stdout, `ob`125 else:126 print >>stderr, \127 "naming.IReadContext interface not supported by object"128 return129 if '-l' in opts:130 w = l = [(str(k), `v`) for k, v in ctx.items()]132 if '-s' not in opts: l.sort()133 if '-r' in opts: l.reverse()134 kl = max([len(x[0]) for x in l])135 vl = max([len(x[1]) for x in l])136 if kl+vl >= w:137 if kl < 40:138 vl = w - kl - 2139 elif vl < 40:140 kl = w - vl - 2141 else:142 kl = 30; vl = w - kl - 2143 for k, v in l:144 print >>stdout, k.ljust(kl)[:kl] + ' ' + v.ljust(vl)[:vl]145 elif '-1' in opts:146 l = [str(x) for x in ctx.keys()]147 if '-s' not in opts: l.sort()148 if '-r' in opts: l.reverse()149 print >>stdout, '\n'.join(l)150 else:151 l = [str(x) for x in ctx.keys()]152 shell.printColumns(stdout, l, '-s' not in opts, '-r' in opts)153 if '-R' in opts:154 for k, v in ctx.items():155 v = adapt(v, naming.IReadContext, None)156 if v is not None:157 print >>stdout, '\n%s:\n' % str(k)158 self.cmd(cmd, opts, [], stdout, stderr, ctx)159 class cmd_l(ls_common):160 """l [-s] [-R] [-r] [name] -- shorthand for ls -l. 'help ls' for more."""161 args = ('Rrs', 0, 1)162 def cmd(self, cmd, opts, args, stdout, stderr, **kw):163 opts['-l'] = None164 self.interactor.ls_common.cmd(165 self, cmd, opts, args, stdout, stderr, **kw)166 cmd_dir = binding.Make(ls_common)167 cmd_ls = binding.Make(ls_common)168 cmd_l = binding.Make(cmd_l)169 class cmd_pwd(ShellCommand):170 """pwd -- display current context"""171 def cmd(self, **kw):172 print ``173 cmd_pwd = binding.Make(cmd_pwd)174 class cmd_python(ShellCommand):175 """python -- enter python interactor"""176 def cmd(self, **kw):177 cmd_py = binding.Make(cmd_python)179 cmd_python = binding.Make(cmd_python)180 class cmd_help(ShellCommand):181 """help [cmd] -- help on commands"""182 args = ('', 0, 1)183 def cmd(self, stdout, stderr, args, **kw):184 if args:185 c = self.interactor.command(args[0])186 if c is None:187 print >>stderr, 'help: no such command: ' + args[0]188 else:189 print c.__doc__190 else:191 print >>stdout, 'Available commands:\n'192 stdout, self.interactor.command_names(), sort=1)194 cmd_help = binding.Make(cmd_help)195 class cmd_rm(ShellCommand):196 """rm name -- unbind name from context"""197 args = ('', 1, 1)198 def cmd(self, cmd, stderr, args, **kw):199 c = c = adapt(c, naming.IWriteContext, None)201 if c is None:202 print >>stderr, '%s: context is not writeable' % cmd203 return204 try:205 del c[args[0]]206 except exceptions.NameNotFound:207 print >>stderr, '%s: %s: not found' % (cmd, args[0])208 cmd_rm = binding.Make(cmd_rm)209 class cmd_bind(ShellCommand):210 """bind name objectname-or-$var -- bind name in context to object"""211 args = ('', 2, 2)212 def cmd(self, cmd, stderr, args, **kw):213 c = c = adapt(c, naming.IWriteContext, None)215 if c is None:216 print >>stderr, '%s: context is not writeable' % cmd217 return218 try:219 ob, aob = self.interactor.lookupRel(args[1], None)220 except KeyError:221 print >>stderr, '%s: %s: no such variable' % (cmd, args[1])222 return223 except exceptions.NameNotFound:224 print >>stderr, '%s: %s not found' % (cmd, args[1])225 return226 c.bind(args[0], ob)227 cmd_bind = binding.Make(cmd_bind)228 class cmd_ln(ShellCommand):229 """ln -s target name -- create LinkRef from name to target"""230 args = ('s', 2, 2)231 def cmd(self, cmd, stderr, args, **kw):232 c = c = adapt(c, naming.IWriteContext, None)234 if c is None:235 print >>stderr, '%s: context is not writeable' % cmd236 return237 if '-s' not in args:238 print >>stderr, '%s: only symbolic links (LinkRefs) are supported' % (cmd, args[1])239 return240 c.bind(args[1], naming.LinkRef(args[2]))241 cmd_ln = binding.Make(cmd_ln)242 class cmd_mv(ShellCommand):243 """mv oldname newname -- rename oldname to newname"""244 args = ('', 2, 2)245 def cmd(self, cmd, stderr, args, **kw):246 c = c = adapt(c, naming.IWriteContext, None)248 if c is None:249 print >>stderr, '%s: context is not writeable' % cmd250 return251 c.rename(args[0], args[1])252 cmd_mv = binding.Make(cmd_mv)253 class cmd_quit(ShellCommand):254 """quit -- leave n2 naming shell"""255 def cmd(self, **kw):256 self.interactor.stop()257 cmd_quit = binding.Make(cmd_quit)258 class cmd_ll(ShellCommand):259 """ll name -- lookupLink name"""260 args = ('', 1, 1)261 def cmd(self, stdout, args, **kw):262 c = r = c.lookupLink(args[0])264 print `r`265 cmd_ll = binding.Make(cmd_ll)266 class cmd_commit(ShellCommand):267 """commit -- commit current transaction and begin a new one"""268 def cmd(self, **kw):269 storage.commit( storage.begin( cmd_commit = binding.Make(cmd_commit)272 class cmd_abort(ShellCommand):273 """abort -- roll back current transaction and begin a new one"""274 def cmd(self, **kw):275 storage.abort( storage.begin( cmd_abort = binding.Make(cmd_abort)278 class cmd_mksub(ShellCommand):279 """mksub name -- create a subcontext"""280 args = ('', 1, 1)281 def cmd(self, cmd, stderr, args, **kw):282 c = c = adapt(c, naming.IWriteContext, None)284 if c is None:285 print >>stderr, '%s: context is not writeable' % cmd286 return287 c.mksub(args[0])288 cmd_md = binding.Make(cmd_mksub)289 cmd_mkdir = binding.Make(cmd_mksub)290 cmd_mksub = binding.Make(cmd_mksub)291 class cmd_rmsub(ShellCommand):292 """rmsub name -- remove a subcontext"""293 args = ('', 1, 1)294 def cmd(self, cmd, stderr, args, **kw):295 c = c = adapt(c, naming.IWriteContext, None)297 if c is None:298 print >>stderr, '%s: context is not writeable' % cmd299 return300 c.rmsub(args[0])301 cmd_rd = binding.Make(cmd_rmsub)302 cmd_rmdir = binding.Make(cmd_rmsub)303 cmd_rmsub = binding.Make(cmd_rmsub)304 class cmd_show(ShellCommand):305 """show [varname] -- show variable varname, or list variables"""306 args = ('', 0, 1)307 def cmd(self, cmd, stdout, stderr, args, **kw):308 if args:309 try:310 ob =[0])311 except KeyError:312 print >>stderr, '%s: %s: no such variable' % (cmd, args[0])313 return314 stdout.write(`ob` + '\n')315 else:316 stdout,, sort=1)318 cmd_show = binding.Make(cmd_show)319 class cmd_unset(ShellCommand):320 """unset varname -- delete variable"""321 args = ('', 1, 1)322 def cmd(self, cmd, stderr, args, **kw):323[0])324 cmd_unset = binding.Make(cmd_unset)325 class cmd_set(ShellCommand):326 """set [-n] varname [$var|name|string] -- set variable327-n\ttreat non-variable value as a name to look up instead of as a string328An unspecified value sets varname to the current context."""329 args = ('n', 1, 2)330 def cmd(self, cmd, stderr, args, opts, **kw):331 if len(args) == 1 or args[1] == '$' or opts.has_key('-n'):332 try:333 ob, aob = self.interactor.lookupRel((args + [None])[1], None)334 except KeyError:335 print >>stderr, '%s: %s: no such variable' % (cmd, args[1])336 return337 except exceptions.NameNotFound:338 print >>stderr, '%s: %s not found' % (cmd, args[1])339 return340 else:341 ob = args[1]342 try:343[0], ob)344 except KeyError:345 print >>stderr, '%s: %s may not be set' % (cmd, args[0])346 cmd_set = binding.Make(cmd_set)347 def complete(self, s, state):348 if state == 0:349 import readline350 lb = readline.get_line_buffer()351 lbl = lb.lstrip()352 bidx = readline.get_begidx()353 if bidx <= (len(lb) - len(lbl)):354 self.matches = self.command_names()355 else:356 c = adapt(, naming.IReadContext, None)357 if c is None:358 self.matches = []359 else:360 self.matches = [str(x) for x in c.keys()]361 self.matches = [x for x in self.matches if x.startswith(s)]362 try:363 return self.matches[state]364 except IndexError:365 return None366protocols.declareAdapter(367 lambda ns, proto: NamingInteractor(),368 provides = [IN2Interactor],369 forProtocols = [naming.IBasicContext]370)

Full Screen

Full Screen Github


Full Screen

...8def get_username():9 return "admin" + str(random.randint(1,1000))10# 生成密码11@pytest.fixture()12def get_pwd():13 return random.randint(100000,9999999999)14@pytest.fixture()15def get_login_data(get_username, get_pwd):16 return {"username": get_username, "pwd":get_pwd}17# 测试用例18def test_login(get_login_data):...

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:


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

Run autotest 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?