Best Python code snippet using Testify_python
random_testing.py
Source:random_testing.py
...103 self.generate_process_parameters = True104class LpsOnePointRuleRewriteTest(ProcessTest):105 def __init__(self, name, settings):106 super(LpsOnePointRuleRewriteTest, self).__init__(name, ymlfile('lpstransform'), settings)107 self.add_command_line_options('t2', ['-alps-one-point-rule-rewriter'])108class LpsConfcheckTest(ProcessTauTest):109 def __init__(self, name, confluence_type, settings):110 self.option_map = { 'commutative' : 'C',111 'commutative-disjoint' : 'c',112 'disjoint' : 'd',113 'triangular' : 'T',114 'trivial' : 'Z'115 }116 assert confluence_type in self.option_map117 super(LpsConfcheckTest, self).__init__(name, ymlfile('lpsconfcheck'), settings)118 self.add_command_line_options('t2', ['-x' + self.option_map[confluence_type]])119class LtscompareTest(ProcessTauTest):120 def __init__(self, name, equivalence_type, settings):121 assert equivalence_type in ['bisim', 'bisim-gv', 'bisim-gjkw', 'branching-bisim', 'branching-bisim-gv', 'branching-bisim-gjkw', 'dpbranching-bisim', 'dpbranching-bisim-gv', 'dpbranching-bisim-gjkw', 'weak-bisim', 'dpweak-bisim', 'sim', 'ready-sim' , 'trace', 'weak-trace']122 super(LtscompareTest, self).__init__(name, ymlfile('ltscompare'), settings)123 self.add_command_line_options('t3', ['-e' + equivalence_type])124 self.add_command_line_options('t4', ['-e' + equivalence_type])125class StochasticLtscompareTest(StochasticProcessTest):126 def __init__(self, name, settings):127 super(StochasticLtscompareTest, self).__init__(name, ymlfile('stochastic-ltscompare'), settings)128class BisimulationTest(ProcessTauTest):129 def __init__(self, name, equivalence_type, settings):130 assert equivalence_type in ['bisim', 'bisim-gv', 'bisim-gjkw', 'branching-bisim', 'branching-bisim-gv', 'branching-bisim-gjkw', 'weak-bisim']131 super(BisimulationTest, self).__init__(name, ymlfile('bisimulation'), settings)132 self.add_command_line_options('t3', ['-e' + equivalence_type])133 self.add_command_line_options('t4', ['-e' + equivalence_type])134 if equivalence_type in ['branching-bisim-gv', 'branching-bisim-gjkw']:135 self.add_command_line_options('t7', ['-bbranching-bisim'])136 elif equivalence_type in ['bisim', 'bisim-gv', 'bisim-gjkw']:137 self.add_command_line_options('t7', ['-bstrong-bisim'])138 else:139 self.add_command_line_options('t7', ['-b' + equivalence_type])140class Lps2ltsAlgorithmsTest(ProcessTauTest):141 def __init__(self, name, settings):142 super(Lps2ltsAlgorithmsTest, self).__init__(name, ymlfile('lps2lts-algorithms'), settings)143 # randomly choose an algorithm144 actions = random.choice(['a', 'a,b', 'a,b,c'])145 options = [random.choice(['--deadlock', '--divergence', '--nondeterminism', '--action={}'.format(actions)])]146 options = [random.choice(['--deadlock', '--nondeterminism', '--action={}'.format(actions)])]147 if 'divergence' in options[0]:148 tau_actions = random.choice(['', '', 'b', 'b,c'])149 if tau_actions:150 options.append('--tau={}'.format(tau_actions))151 self.add_command_line_options('t2', options)152 self.add_command_line_options('t3', options)153class LpsConstelmTest(ProcessTest):154 def __init__(self, name, settings):155 super(LpsConstelmTest, self).__init__(name, ymlfile('lpsconstelm'), settings)156 self.generate_process_parameters = True157class LpsBinaryTest(ProcessTest):158 def __init__(self, name, settings):159 super(LpsBinaryTest, self).__init__(name, ymlfile('lpsbinary'), settings)160 self.generate_process_parameters = True161class LpsstategraphTest(ProcessTest):162 def __init__(self, name, settings):163 super(LpsstategraphTest, self).__init__(name, ymlfile('lpsstategraph'), settings)164 self.generate_process_parameters = True165class Lps2pbesTest(ProcessTest):166 def __init__(self, name, settings):167 super(Lps2pbesTest, self).__init__(name, ymlfile('lps2pbes'), settings)168 def create_inputfiles(self, runpath = '.'):169 super(Lps2pbesTest, self).create_inputfiles(runpath)170 self.inputfiles.append(mcrl2file('examples/modal-formulas/nodeadlock.mcf'))171class Lts2pbesTest(ProcessTest):172 def __init__(self, name, settings):173 super(Lts2pbesTest, self).__init__(name, ymlfile('lts2pbes'), settings)174 def create_inputfiles(self, runpath = '.'):175 super(Lts2pbesTest, self).create_inputfiles(runpath)176 self.inputfiles.append(mcrl2file('examples/modal-formulas/nodeadlock.mcf'))177class LtsconvertsymbolicTest(ProcessTest):178 def __init__(self, name, settings):179 super(LtsconvertsymbolicTest, self).__init__(name, ymlfile('ltsconvertsymbolic'), settings)180class PbesTest(RandomTest):181 def __init__(self, name, ymlfile, settings):182 super(PbesTest, self).__init__(name, ymlfile, settings)183 self.equation_count = 4184 self.atom_count = 4185 self.propvar_count = 3186 self.use_quantifiers = True187 self.use_integers = True188 def create_inputfiles(self, runpath = '.'):189 filename = '{0}.txt'.format(self.name)190 p = make_pbes(self.equation_count, self.atom_count, self.propvar_count, self.use_quantifiers, use_integers=self.use_integers)191 write_text(filename, str(p))192 self.inputfiles += [filename]193# N.B. does not work yet due to unusable abstraction map194class PbesabsintheTest(PbesTest):195 def __init__(self, name, settings):196 super(PbesabsintheTest, self).__init__(name, ymlfile('pbesabsinthe'), settings)197# N.B. This test has been disabled, since the tool has been deprecated.198class PbesabstractTest(PbesTest):199 def __init__(self, name, settings):200 super(PbesabstractTest, self).__init__(name, ymlfile('pbesabstract'), settings)201class PbesbddsolveTest(PbesTest):202 def __init__(self, name, settings):203 super(PbesbddsolveTest, self).__init__(name, ymlfile('pbesbddsolve'), settings)204 self.use_integers = False205 self.use_quantifiers = False206class PbesconstelmTest(PbesTest):207 def __init__(self, name, settings):208 super(PbesconstelmTest, self).__init__(name, ymlfile('pbesconstelm'), settings)209class PbesparelmTest(PbesTest):210 def __init__(self, name, settings):211 super(PbesparelmTest, self).__init__(name, ymlfile('pbesparelm'), settings)212class PbespareqelmTest(PbesTest):213 def __init__(self, name, settings):214 super(PbespareqelmTest, self).__init__(name, ymlfile('pbespareqelm'), settings)215class Pbespor1Test(PbesTest):216 def __init__(self, name, settings):217 super(Pbespor1Test, self).__init__(name, ymlfile('pbespor1'), settings)218class Pbespor2Test(ProcessTest):219 def __init__(self, name, settings):220 super(Pbespor2Test, self).__init__(name, ymlfile('pbespor2'), settings)221 def create_inputfiles(self, runpath = '.'):222 super(Pbespor2Test, self).create_inputfiles(runpath)223 filename = '{0}.mcf'.format(self.name, self.settings)224 formula = random_state_formula_generator.make_modal_formula()225 write_text(filename, str(formula))226 self.inputfiles += [filename]227class PbesrewrTest(PbesTest):228 def __init__(self, name, rewriter, settings):229 super(PbesrewrTest, self).__init__(name, ymlfile('pbesrewr'), settings)230 self.add_command_line_options('t2', ['-p' + rewriter])231class PbestransformTest(PbesTest):232 def __init__(self, name, rewriter, settings):233 super(PbestransformTest, self).__init__(name, ymlfile('pbestransform'), settings)234 self.add_command_line_options('t2', ['-a' + rewriter])235class PbesinstTest(PbesTest):236 def __init__(self, name, options, settings):237 super(PbesinstTest, self).__init__(name, ymlfile('pbesinst'), settings)238 self.add_command_line_options('t2', options)239class PbespgsolveTest(PbesTest):240 def __init__(self, name, settings):241 super(PbespgsolveTest, self).__init__(name, ymlfile('pbespgsolve'), settings)242class PbesstategraphTest(PbesTest):243 def __init__(self, name, settings):244 super(PbesstategraphTest, self).__init__(name, ymlfile('pbesstategraph'), settings)245class PbessymbolicbisimTest(PbesTest):246 def __init__(self, name, settings):247 super(PbessymbolicbisimTest, self).__init__(name, ymlfile('pbessymbolicbisim'), settings)248class PbessolvesymbolicTest(PbesTest):249 def __init__(self, name, settings):250 super(PbessolvesymbolicTest, self).__init__(name, ymlfile('pbessolvesymbolic'), settings)251 252class Pbes2boolTest(PbesTest):253 def __init__(self, name, settings):254 super(Pbes2boolTest, self).__init__(name, ymlfile('pbessolve'), settings)255class Pbes2boolDepthFirstTest(PbesTest):256 def __init__(self, name, settings):257 super(Pbes2boolDepthFirstTest, self).__init__(name, ymlfile('pbessolve'), settings)258 self.add_command_line_options('t2', ['-zdepth-first'])259 self.add_command_line_options('t3', ['-zdepth-first'])260 self.add_command_line_options('t4', ['-zdepth-first'])261 self.add_command_line_options('t5', ['-zdepth-first'])262 self.add_command_line_options('t6', ['-zdepth-first'])263 self.add_command_line_options('t7', ['-zdepth-first'])264 self.add_command_line_options('t8', ['-zdepth-first'])265class Pbes2bool_counter_exampleTest(ProcessTest):266 def __init__(self, name, optimization, settings):267 super(Pbes2bool_counter_exampleTest, self).__init__(name, ymlfile('pbessolve-counter-example'), settings)268 if optimization in [4, 5]:269 self.add_command_line_options('t3', ['-l{}'.format(optimization), '--aggressive', '--prune-todo-list'])270 else:271 self.add_command_line_options('t3', ['-l{}'.format(optimization), '--prune-todo-list'])272 def create_inputfiles(self, runpath = '.'):273 super(Pbes2bool_counter_exampleTest, self).create_inputfiles(runpath)274 filename = '{0}.mcf'.format(self.name, self.settings)275 formula = random_state_formula_generator.make_modal_formula()276 write_text(filename, str(formula))277 self.inputfiles += [filename]278class Pbes_unify_parametersTest(PbesTest):279 def __init__(self, name, settings):280 super(Pbes_unify_parametersTest, self).__init__(name, ymlfile('pbes-unify-parameters'), settings)281class Pbes_srfTest(PbesTest):282 def __init__(self, name, settings):283 super(Pbes_srfTest, self).__init__(name, ymlfile('pbes-srf'), settings)284# N.B does not work due to unknown expressions (F_or)285class SymbolicExplorationTest(PbesTest):...
carla_test.py
Source:carla_test.py
...18 signal.signal(signal.SIGTERM, sigterm_handler)19 # Define and parse command line arguments20 argparser = argparse.ArgumentParser()21 utils.add_driving_options(argparser)22 gym_wrapper.CarlaEnv.add_command_line_options(argparser)23 argparser.add_argument('--checkpoint_path', type=str, default='a2d_trained')24 subparsers = argparser.add_subparsers(title='available benchmarks', dest='benchmark')25 parser_corl2017 = subparsers.add_parser('corl2017')26 benchmarks.Corl2017Benchmark.add_command_line_options(parser_corl2017)27 parser_nocrash = subparsers.add_parser('nocrash')28 benchmarks.NoCrashBenchmark.add_command_line_options(parser_nocrash)29 parser_occluded = subparsers.add_parser('occluded')30 scenarios.OccludedPedestrianScenario.add_command_line_options(parser_occluded)31 parser_overtaking = subparsers.add_parser('overtaking')32 scenarios.OvertakingTruckScenario.add_command_line_options(parser_overtaking)33 args = argparser.parse_args()34 env_names = dict(35 corl2017='Corl2017',36 nocrash='NoCrash',37 occluded='OccludedPedestrian',38 overtaking='OvertakingTruck',39 waypoint='WaypointFollowing'40 )41 with torch.no_grad():42 params = torch.load(os.path.join(args.checkpoint_path, "args.pt"))43 params.fps = args.fps44 if args.benchmark == 'nocrash':45 params.empty_only = args.empty_only46 params.regular_only = args.regular_only...
pytest_shortcuts.py
Source:pytest_shortcuts.py
...16 The shortcuts are expanded very early so as to allow the edited options to be17 processed by other plugins/parts of pytest.18 """19 shortcuts = dict(parse_shortcut(item) for item in early_config.getini("shortcuts"))20 add_command_line_options(shortcuts, parser)21 expand_shortcuts(shortcuts, args)22def add_command_line_options(shortcuts, parser):23 for shortcut, new_args in shortcuts.items():24 parser.addoption(25 shortcut,26 action="store_true",27 help="Shortcut for {}".format(" ".join(new_args)),28 )29def expand_shortcuts(shortcuts, raw_args):30 for shortcut, new_args in shortcuts.items():31 if shortcut in raw_args:32 pos = raw_args.index(shortcut)33 raw_args[pos : pos + 1] = new_args34def parse_shortcut(item):35 assert ":" in item, "Invalid shortcut definition"36 key, val = item.split(":", 1)...
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!!