How to use _setup_common method in autotest

Best Python code snippet using autotest_python

subcommand_unittest.py

Source:subcommand_unittest.py Github

copy

Full Screen

...185 return self.god.create_mock_class(cmd, 'subcommand')186 def _get_tasklist(self):187 return [self._get_cmd(lambda x: x * 2, (3,)),188 self._get_cmd(lambda: None, [])]189 def _setup_common(self):190 tasklist = self._get_tasklist()191 for task in tasklist:192 task.fork_start.expect_call()193 return tasklist194 def test_success(self):195 tasklist = self._setup_common()196 for task in tasklist:197 task.fork_waitfor.expect_call(timeout=None).and_return(0)198 (subcommand.cPickle.load.expect_call(task.result_pickle)199 .and_return(6))200 task.result_pickle.close.expect_call()201 subcommand.parallel(tasklist)202 self.god.check_playback()203 def test_failure(self):204 tasklist = self._setup_common()205 for task in tasklist:206 task.fork_waitfor.expect_call(timeout=None).and_return(1)207 (subcommand.cPickle.load.expect_call(task.result_pickle)208 .and_return(6))209 task.result_pickle.close.expect_call()210 self.assertRaises(subcommand.error.AutoservError, subcommand.parallel,211 tasklist)212 self.god.check_playback()213 def test_timeout(self):214 self.god.stub_function(subcommand.time, 'time')215 tasklist = self._setup_common()216 timeout = 10217 subcommand.time.time.expect_call().and_return(1)218 for task in tasklist:219 subcommand.time.time.expect_call().and_return(1)220 task.fork_waitfor.expect_call(timeout=timeout).and_return(None)221 (subcommand.cPickle.load.expect_call(task.result_pickle)222 .and_return(6))223 task.result_pickle.close.expect_call()224 self.assertRaises(subcommand.error.AutoservError, subcommand.parallel,225 tasklist, timeout=timeout)226 self.god.check_playback()227 def test_return_results(self):228 tasklist = self._setup_common()229 tasklist[0].fork_waitfor.expect_call(timeout=None).and_return(0)230 (subcommand.cPickle.load.expect_call(tasklist[0].result_pickle)231 .and_return(6))232 tasklist[0].result_pickle.close.expect_call()233 error = Exception('fail')234 tasklist[1].fork_waitfor.expect_call(timeout=None).and_return(1)235 (subcommand.cPickle.load.expect_call(tasklist[1].result_pickle)236 .and_return(error))237 tasklist[1].result_pickle.close.expect_call()238 self.assertEquals(subcommand.parallel(tasklist, return_results=True),239 [6, error])240 self.god.check_playback()241class test_parallel_simple(unittest.TestCase):242 def setUp(self):...

Full Screen

Full Screen

julia_comps.py

Source:julia_comps.py Github

copy

Full Screen

...12 get_py2jl_apply_linear,13 remove_component)14def _initialize_common(self):15 self.options.declare('jl_id', types=int)16def _setup_common(self):17 self._jl_id = self.options['jl_id']18 self._julia_setup = get_py2jl_setup(self._jl_id)19 input_data, output_data, partials_data = self._julia_setup(self._jl_id)20 for var in input_data:21 self.add_input(var.name, shape=var.shape, val=var.val,22 units=var.units)23 for var in output_data:24 self.add_output(var.name, shape=var.shape, val=var.val,25 units=var.units)26 for data in partials_data:27 self.declare_partials(data.of, data.wrt,28 rows=data.rows, cols=data.cols,29 val=data.val)30class JuliaExplicitComp(om.ExplicitComponent):31 def initialize(self):32 _initialize_common(self)33 def setup(self):34 _setup_common(self)35 self._julia_compute = get_py2jl_compute(self._jl_id)36 self._julia_compute_partials = get_py2jl_compute_partials(self._jl_id)37 def compute(self, inputs, outputs):38 inputs_dict = dict(inputs)39 outputs_dict = dict(outputs)40 self._julia_compute(self._jl_id, inputs_dict, outputs_dict)41 def compute_partials(self, inputs, partials):42 if self._julia_compute_partials:43 inputs_dict = dict(inputs)44 partials_dict = {}45 for of_wrt in self._declared_partials:46 partials_dict[of_wrt] = partials[of_wrt]47 self._julia_compute_partials(self._jl_id, inputs_dict, partials_dict)48 def __del__(self):49 remove_component(self.options['jl_id'])50class JuliaImplicitComp(om.ImplicitComponent):51 def initialize(self):52 _initialize_common(self)53 def setup(self):54 _setup_common(self)55 self._julia_apply_nonlinear = get_py2jl_apply_nonlinear(self._jl_id)56 self._julia_linearize = get_py2jl_linearize(self._jl_id)57 self._julia_guess_nonlinear = get_py2jl_guess_nonlinear(self._jl_id)58 self._julia_solve_nonlinear = get_py2jl_solve_nonlinear(self._jl_id)59 self._julia_apply_linear = get_py2jl_apply_linear(self._jl_id)60 # Trying to avoid the exception61 #62 # RuntimeError: AssembledJacobian not supported for matrix-free subcomponent.63 #64 # when the Julia component doesn't implement apply_linear!.65 if self._julia_apply_linear:66 def apply_linear(self, inputs, outputs, d_inputs, d_outputs, d_residuals, mode):67 inputs_dict = dict(inputs)68 outputs_dict = dict(outputs)...

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

Helpful

NotHelpful