How to use _set_trace method in robotframework-pageobjects

Best Python code snippet using robotframework-pageobjects_python

InputLine.py

Source:InputLine.py Github

copy

Full Screen

...82 self.entry[key]['state'] = 'readonly'83 self.entry[key]['foreground'] = colors.foreground84 85 # disallow fixed and shared variables86 self.variable['shared'] = self._set_trace(self.variable['shared'],87 'unfix', self._unfix)88 self.variable['fixed'] = self._set_trace(self.variable['fixed'],89 'unshare', self._unshare)90 91 # set modify all synchronization92 for k in ('p0', 'blo', 'bhi', 'fixed'):93 # set new trace callback94 self.variable[k] = self._set_trace(self.variable[k], 95 'modify_all', 96 partial(self._modify_all, col=k))97 98 # ======================================================================= #99 def _modify_all(self, *_, col):100 """101 Do modify all synchronization. Make other lines of the same id equal 102 in value103 """104 105 # check if enabled106 if not (self.bfit.fit_files.set_as_group.get() or self.variable['shared'].get()):107 return 108 109 # disable trace110 self.variable[col], tr = self._pop_trace(self.variable[col], 'modify_all')111 112 # set 113 self.bfit.fit_files.set_lines(pname=self.pname, 114 col=col, 115 value=self.variable[col].get(), 116 skipline=self)117 118 # re-enable trace119 self.variable[col] = self._set_trace(self.variable[col], 'modify_all', tr)120 121 # ======================================================================= #122 def _pop_trace(self, var, name):123 """124 Remove and return trace function125 """126 127 # check if variable has trace dict128 if not hasattr(var, 'trace_id') or name not in var.trace_id.keys():129 return (var, None)130 131 # pop132 tr = var.trace_id[name]133 var.trace_remove("write", tr[0])134 del var.trace_id[name]135 136 # return 137 return (var, tr[1])138 139 # ======================================================================= #140 def _set_trace(self, var, name, function):141 """142 Set the trace functions143 """144 145 # no input146 if function is None:147 return var148 149 # check if variable has trace dict150 if not hasattr(var, 'trace_id'):151 var.trace_id = {}152 153 # check if trace exists154 self._pop_trace(var, name)155 156 # add trace157 var.trace_id[name] = (var.trace_add("write", function), function)158 159 return var160 161 # ======================================================================= #162 def _unfix(self, *_):163 """164 disallow fixed shared parameters165 """166 if self.variable['shared'].get():167 self.variable['fixed'].set(False)168 169 # ======================================================================= #170 def _unshare(self, *_):171 """172 disallow fixed shared parameters173 """174 if self.variable['fixed'].get():175 self.variable['shared'].set(False)176 # ======================================================================= #177 def assign_inputs(self):178 """179 Make sure the inputs are saved to fitdata.fitpar DataFrame180 """ 181 182 # check if valid183 if not self.pname:184 return185 186 # assign187 gen = self.data.gen_set_from_var188 for k in ('p0', 'blo', 'bhi', 'fixed', 'shared'):189 # set new trace callback190 self.variable[k] = self._set_trace(self.variable[k], 191 'sync_fitpar', 192 gen(self.pname, k, self.variable[k]))193 194 # ======================================================================= #195 def assign_shared(self):196 """197 Link the shared values198 """ 199 200 # no key201 if not self.pname:202 return203 # get dict of shared boolean var204 share_var = self.bfit.fit_files.share_var205 206 # check if key is present207 if self.pname not in share_var.keys():208 share_var[self.pname] = BooleanVar()209 210 # assign key 211 self.variable['shared'] = share_var[self.pname]212 213 # set trace to uncheck fixed box214 self.variable['shared'] = self._set_trace(self.variable['shared'], 215 'unfix_{id}'.format(id=self.data.id), 216 self._unfix)217 218 # link to checkbox219 self.entry['shared'].config(variable=self.variable['shared'])220 221 # ======================================================================= #222 def degrid(self):223 """224 Remove the entries225 """226 self.label.destroy()227 228 for i, key in enumerate(self.columns):229 self.entry[key].destroy()230 231 # ======================================================================= #232 def disable(self):233 """234 Prevent editing235 """ 236 for k, e in self.entry.items():237 if k not in ('chi',):238 e.configure(state='disabled')239 240 # ======================================================================= #241 def enable(self):242 """243 Allow editing244 """ 245 for k, e in self.entry.items():246 if k in ('res', 'dres+', 'dres-', 'chi'):247 e.configure(state='readonly')248 else:249 e.configure(state='normal')250 251 # ======================================================================= #252 def get(self, col):253 """254 get values255 256 col: str, name of column to get257 """258 259 # wildcards260 if col == '*':261 return {c:self.get(c) for c in self.columns}262 263 # get single value264 if col in self.variable.keys():265 v = self.variable[col].get()266 267 if type(v) is str:268 269 if v == '':270 return np.nan271 272 try:273 v = float(v)274 except ValueError as errmsg:275 self.logger.exception("Bad input.")276 messagebox.showerror("Error", str(errmsg))277 raise errmsg278 279 return v280 # ======================================================================= #281 def grid(self, row):282 """283 Grid the entries284 """285 self.label.grid(column=0, row=row, sticky='e')286 287 for i, key in enumerate(self.columns):288 289 if not row == 2 and key == 'chi':290 pass291 elif key == 'chi':292 self.entry[key].grid(column=i+1, row=row, rowspan=100, padx=5)293 else:294 self.entry[key].grid(column=i+1, row=row, padx=5) 295 296 # ======================================================================= #297 def set(self, pname=None, **values):298 """299 set values300 301 pname: string, parameter name (ex: 1_T1)302 values: keyed by self.columns, the numerical or boolean values for each 303 column to take304 """305 306 # label307 if pname is not None:308 self.pname = pname309 self.label.config(text=pname) 310 311 # assign inputs312 self.assign_shared()313 self.assign_inputs()314 315 # check if line is constrained316 constr_set = self.bfit.fit_files.pop_fitconstr.constraints_are_set317 if pname in self.data.constrained.keys() and constr_set:318 self.disable()319 self.variable['fixed'].set(False)320 self.variable['shared'].set(False)321 else:322 self.enable()323 324 # set values325 for k, v in values.items():326 327 # disable traces328 self.variable[k], tr = self._pop_trace(self.variable[k], 'modify_all')329 330 # blank331 if str(v) == 'nan':332 333 # set as blank334 if type(self.variable[k]) == StringVar:335 self.variable[k].set('')336 337 # set chi box color338 if k == 'chi':339 self.entry['chi']['readonlybackground']=colors.readonly340 341 # set boolean342 elif type(v) is bool:343 self.variable[k].set(v)344 345 # set string346 elif type(v) is str:347 self.variable[k].set(v)348 349 # set float350 else:351 352 v = float(v)353 354 if k == 'chi':355 356 # set number decimal places357 n_figs = 2358 359 # set color360 if v > self.bfit.fit_files.chi_threshold:361 self.entry['chi']['readonlybackground']='red'362 else:363 self.entry['chi']['readonlybackground']=colors.readonly364 365 else:366 n_figs = self.bfit.rounding367 368 # round to n_figs significant figures decimal places369 try:370 v_decimal = v - int(v)371 v_decimal = float('{:.{p}g}'.format(v_decimal, p=n_figs))372 v = int(v) + v_decimal373 except OverflowError:374 pass375 self.variable[k].set('{:.{p}g}'.format(v, p=8))376 377 # set traces378 self.variable[k] = self._set_trace(self.variable[k], 'modify_all', tr)379 self.variable[k] = self._set_trace(self.variable[k], 'sync_fitpar', 380 self.data.gen_set_from_var(self.pname, 381 k, ...

Full Screen

Full Screen

pdb.py

Source:pdb.py Github

copy

Full Screen

...23 from pdb import set_trace as _set_trace24 if frame is None:25 import sys26 frame = sys._getframe().f_back27 return _set_trace(frame)28def restore_hook():29 try:30 from PyQt5.QtCore import pyqtRestoreInputHook31 except ImportError:32 from PyQt4.QtCore import pyqtRestoreInputHook33 try:34 pyqtRestoreInputHook()35 except Exception, e:36 print 'pyqtRestoreInputHook: %r' % e...

Full Screen

Full Screen

debug_functions.py

Source:debug_functions.py Github

copy

Full Screen

...7 try:8 from ipdb import set_trace as _set_trace9 except ImportError as e:10 from pdb import set_trace as _set_trace...

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 robotframework-pageobjects 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