How to use subst method in stestr

Best Python code snippet using stestr_python

subst.py

Source:subst.py Github

copy

Full Screen

...63 # such as env['HAVE_XYZ'] = 164 #print 'key = ', key65 #print ' straight env = ', env[key]66 #print ' str of the thing = ', str(env[key])67 #print ' subst(${}) of the thing = ', env.subst("${%s}" % key) 68 #print ' %s of the thing = ', "%s" % str(env[key])69 aa = env[key]70 if aa == []:71 aa = ''72 return aa73 #return str(env[key])74 #return env.subst("${%s}" % key)75# Builder related functions76##############################################################################77# Builder action78def _subst_action(target, source, env):79 # Substitute in the files80 pattern = env["SUBST_PATTERN"]81 replace = env["SUBST_REPLACE"]82 #print 'SUBSTITUTE: ', pattern, ' for ', replace83 for (t, s) in zip(target, source):84 _subst_file(str(t), str(s), env, pattern, replace)85 return 086# Builder message87def _subst_message(target, source, env):88 items = ["Substituting vars from %s to %s" % (s, t)...

Full Screen

Full Screen

test_linearity_check.py

Source:test_linearity_check.py Github

copy

Full Screen

1import os2import pytest3from cellmlmanip.printer import Printer4from chaste_codegen._linearity_check import KINDS, get_non_linear_state_vars, subst_deriv_eqs_non_linear_vars5from chaste_codegen._rdf import OXMETA6from chaste_codegen.tests.conftest import TESTS_FOLDER7@pytest.fixture(scope='session')8def state_vars(s_model):9 return s_model.get_state_variables(sort=False)10@pytest.fixture(scope='session')11def derivatives_eqs(s_model):12 return s_model.get_equations_for(s_model.get_derivatives(sort=False))13@pytest.fixture(scope='session')14def membrane_voltage_var(s_model):15 return s_model.get_variable_by_ontology_term((OXMETA, 'membrane_voltage'))16@pytest.fixture(scope='session')17def non_linear_state_vars(derivatives_eqs, membrane_voltage_var, state_vars):18 return get_non_linear_state_vars(derivatives_eqs, membrane_voltage_var, state_vars)19@pytest.fixture(scope='session')20def y_derivatives(s_model):21 return s_model.get_derivatives()22def test_kinds():23 assert str([{k: k.value} for k in KINDS]) == \24 '[{<KINDS.NONE: 1>: 1}, {<KINDS.LINEAR: 2>: 2}, {<KINDS.NONLINEAR: 3>: 3}]'25def test_wrong_params_get_non_linear_state_vars1():26 with pytest.raises(TypeError, match="'NoneType' object is not iterable"):27 get_non_linear_state_vars(None, None, None)28def test_wrong_params_get_non_linear_state_vars2(derivatives_eqs, membrane_voltage_var):29 with pytest.raises(AssertionError, match="Expecting state_vars and derivative_equations not to be empty"):30 get_non_linear_state_vars(derivatives_eqs, membrane_voltage_var, [])31def test_get_non_linear_state_vars(non_linear_state_vars):32 non_linear_state_vars = sorted(non_linear_state_vars, key=lambda s: Printer().doprint(s))33 expected = open(os.path.join(TESTS_FOLDER, 'test_linearity_check_non_linear_state_vars.txt'), 'r').read()34 assert str(non_linear_state_vars) == expected, str(non_linear_state_vars)35def test_wrong_params_subst_deriv_eqs3():36 with pytest.raises(AssertionError, match="membrane_voltage_var should be a cellmlmanip.Variable"):37 subst_deriv_eqs_non_linear_vars([1], [1, 2], None, [1, 2], None)38def test_wrong_params_subst_deriv_eqs4(membrane_voltage_var):39 with pytest.raises(AssertionError, match="Expecting y_derivatives to be Derivatives"):40 subst_deriv_eqs_non_linear_vars([1], [1, 2], membrane_voltage_var, [1, 2], None)41def test_wrong_params_subst_deriv_eqs5(y_derivatives, membrane_voltage_var):42 with pytest.raises(AssertionError, match="Expecting non_linear_state_vars all to be cellmlmanip.Variable"):43 subst_deriv_eqs_non_linear_vars(y_derivatives, [1, 2], membrane_voltage_var, [1, 2], None)44def test_wrong_params_subst_deriv_eqs6(y_derivatives, membrane_voltage_var, non_linear_state_vars):45 with pytest.raises(AssertionError, match="Expecting state_vars all to be cellmlmanip.Variable"):46 subst_deriv_eqs_non_linear_vars(y_derivatives, non_linear_state_vars, membrane_voltage_var, [1, 2], None)47def test_wrong_params_subst_deriv_eqs7(y_derivatives, membrane_voltage_var, non_linear_state_vars, state_vars):48 with pytest.raises(AssertionError, match="Expecting get_equations_for_func to be a callable"):49 subst_deriv_eqs_non_linear_vars(y_derivatives, non_linear_state_vars, membrane_voltage_var, state_vars, None)50def test_subst_deriv_eqs_non_linear_vars(s_model, y_derivatives, non_linear_state_vars, membrane_voltage_var,51 state_vars):52 deq = subst_deriv_eqs_non_linear_vars(y_derivatives, non_linear_state_vars, membrane_voltage_var, state_vars,53 s_model.get_equations_for)54 expected = open(os.path.join(TESTS_FOLDER, 'test_linearity_check_deq.txt'), 'r').read()...

Full Screen

Full Screen

substinfile.py

Source:substinfile.py Github

copy

Full Screen

...38 raise SCons.Errors.UserError, "SubstInFile requires SUBST_DICT to be set."39 d = dict(env['SUBST_DICT']) # copy it40 for (k,v) in d.items():41 if callable(v):42 d[k] = env.subst(v()).replace('\\','\\\\')43 elif SCons.Util.is_String(v):44 d[k] = env.subst(v).replace('\\','\\\\')45 else:46 raise SCons.Errors.UserError, "SubstInFile: key %s: %s must be a string or callable"%(k, repr(v))47 for (t,s) in zip(target, source):48 return do_subst_in_file(str(t), str(s), d)49 def subst_in_file_string(target, source, env):50 """This is what gets printed on the console."""51 return '\n'.join(['Substituting vars from %s into %s'%(str(s), str(t))52 for (t,s) in zip(target, source)])53 def subst_emitter(target, source, env):54 """Add dependency from substituted SUBST_DICT to target.55 Returns original target, source tuple unchanged.56 """57 d = env['SUBST_DICT'].copy() # copy it58 for (k,v) in d.items():59 if callable(v):60 d[k] = env.subst(v())61 elif SCons.Util.is_String(v):62 d[k]=env.subst(v)63 Depends(target, SCons.Node.Python.Value(d))64 return target, source65## env.Append(TOOLS = 'substinfile') # this should be automaticaly done by Scons ?!?66 subst_action = SCons.Action.Action( subst_in_file, subst_in_file_string )67 env['BUILDERS']['SubstInFile'] = Builder(action=subst_action, emitter=subst_emitter)68def exists(env):69 """70 Make sure tool exists.71 """...

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