Best Python code snippet using tempest_python
workspace.py
Source: workspace.py
...87 self._write_file()88 @lockutils.synchronized('workspaces', external=True)89 def list_workspaces(self):90 self._populate()91 self._validate_workspaces()92 return self.workspaces93 def _workspace_name_exists(self, name):94 if name in self.workspaces:95 print("A workspace already exists with name: {0}.".format(96 name))97 sys.exit(1)98 def _validate_path(self, path):99 if not os.path.exists(path):100 print("Path does not exist.")101 sys.exit(1)102 @lockutils.synchronized('workspaces', external=True)103 def register_new_workspace(self, name, path, init=False):104 """Adds the new workspace and writes out the new workspace config"""105 self._populate()106 path = os.path.abspath(os.path.expanduser(path))107 # This only happens when register is called from outside of init108 if not init:109 self._validate_path(path)110 self._workspace_name_exists(name)111 self.workspaces[name] = path112 self._write_file()113 def _validate_workspaces(self):114 if self.workspaces is not None:115 self.workspaces = {n: p for n, p in self.workspaces.items()116 if os.path.exists(p)}117 self._write_file()118 def _write_file(self):119 with open(self.path, 'w') as f:120 f.write(yaml.dump(self.workspaces))121 def _populate(self):122 if not os.path.isfile(self.path):123 return124 with open(self.path, 'r') as f:125 self.workspaces = yaml.safe_load(f) or {}126class TempestWorkspace(command.Command):127 def take_action(self, parsed_args):...
MSDFitTest.py
Source: MSDFitTest.py
...16 UserDefinedFunction='name=ExpDecay,Height=1,Lifetime=6',17 NumBanks=5, BankPixelWidth=1, XUnit='QSquared', XMin=0.0,18 XMax=5.0, BinWidth=0.1)19 self._ws = sample20 def _validate_workspaces(self, msd_ws, param_ws, fit_ws):21 """22 Validates the various workspaces produced by MSDFit.23 @param msd_ws The MSD workspace24 @param param_ws The fit parameter table workspace25 @param fit_ws The fit workspace group26 """27 # First validate workspace types28 self.assertTrue(isinstance(msd_ws, MatrixWorkspace), 'MSD workspace should be a MatrixWorkspace')29 self.assertTrue(isinstance(param_ws, ITableWorkspace), 'Fit parameter workspace should be a TableWorkspace')30 self.assertTrue(isinstance(fit_ws, WorkspaceGroup), 'Fit workspace should be a WorkspaceGroup')31 # Validate number of items in groups32 self.assertEqual(fit_ws.getNumberOfEntries(), 5)33 # Validate MSD property workspaces34 self.assertEqual(len(msd_ws.readX(0)), 5)35 self.assertEqual(len(msd_ws.readX(1)), 5)36 def test_basic_run(self):37 """38 Tests a basic run providing the MSD workspace as output.39 """40 MSDFit(InputWorkspace=self._ws,41 XStart=0.0, XEnd=5.0,42 SpecMin=0, SpecMax=4,43 OutputWorkspace='msd')44 self.assertTrue(mtd.doesExist('msd_Parameters'), 'Should have a parameter WS with the default name')45 self.assertTrue(mtd.doesExist('msd_Workspaces'), 'Should have a fit WS with the default name')46 self._validate_workspaces(mtd['msd'], mtd['msd_Parameters'], mtd['msd_Workspaces'])47 def test_basic_run_given_names(self):48 """49 Tests a basic run providing names of all output workspaces.50 """51 msd, param, fit = MSDFit(InputWorkspace=self._ws,52 XStart=0.0, XEnd=5.0,53 SpecMin=0, SpecMax=4)54 self._validate_workspaces(msd, param, fit)55 def test_fail_spec_min(self):56 """57 Tests validation for SpecMin >= 0.58 """59 with self.assertRaises(RuntimeError):60 msd, param, fit = MSDFit(InputWorkspace=self._ws,61 XStart=0.0, XEnd=5.0,62 SpecMin=-1, SpecMax=0)63 def test_fail_spec_min(self):64 """65 Tests validation for SpecMin >= num histograms.66 """67 self.assertRaises(RuntimeError,68 MSDFit,...
Check out the latest blogs from LambdaTest on this topic:
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!