How to use getargvlist method in tox

Best Python code snippet using tox_python

test_config.py

Source:test_config.py Github

copy

Full Screen

...160 """)161 reader = IniReader(config._cfg)162 reader.addsubstitions(item1="with space", item2="grr")163 #py.test.raises(tox.exception.ConfigError,164 # "reader.getargvlist('section', 'key1')")165 assert reader.getargvlist('section', 'key1') == []166 x = reader.getargvlist("section", "key2")167 assert x == [["cmd1", "with space", "grr"],168 ["cmd2", "grr"]]169 def test_argvlist_multiline(self, tmpdir, newconfig):170 config = newconfig("""171 [section]172 key2=173 cmd1 {item1} \ # a comment174 {item2}175 """)176 reader = IniReader(config._cfg)177 reader.addsubstitions(item1="with space", item2="grr")178 #py.test.raises(tox.exception.ConfigError,179 # "reader.getargvlist('section', 'key1')")180 assert reader.getargvlist('section', 'key1') == []181 x = reader.getargvlist("section", "key2")182 assert x == [["cmd1", "with space", "grr"]]183 def test_argvlist_quoting_in_command(self, tmpdir, newconfig):184 config = newconfig("""185 [section]186 key1=187 cmd1 'with space' \ # a comment188 'after the comment'189 """)190 reader = IniReader(config._cfg)191 x = reader.getargvlist("section", "key1")192 assert x == [["cmd1", "with space", "after the comment"]]193 def test_argvlist_positional_substitution(self, tmpdir, newconfig):194 config = newconfig("""195 [section]196 key2=197 cmd1 []198 cmd2 {posargs:{item2} \199 other}200 """)201 reader = IniReader(config._cfg)202 posargs = ['hello', 'world']203 reader.addsubstitions(posargs, item2="value2")204 #py.test.raises(tox.exception.ConfigError,205 # "reader.getargvlist('section', 'key1')")206 assert reader.getargvlist('section', 'key1') == []207 argvlist = reader.getargvlist("section", "key2")208 assert argvlist[0] == ["cmd1"] + posargs209 assert argvlist[1] == ["cmd2"] + posargs210 reader = IniReader(config._cfg)211 reader.addsubstitions([], item2="value2")212 #py.test.raises(tox.exception.ConfigError,213 # "reader.getargvlist('section', 'key1')")214 assert reader.getargvlist('section', 'key1') == []215 argvlist = reader.getargvlist("section", "key2")216 assert argvlist[0] == ["cmd1"]217 assert argvlist[1] == ["cmd2", "value2", "other"]218 def test_positional_arguments_are_only_replaced_when_standing_alone(self, tmpdir, newconfig):219 config = newconfig("""220 [section]221 key=222 cmd0 []223 cmd1 -m '[abc]'224 cmd2 -m '\'something\'' []225 cmd3 something[]else226 """)227 reader = IniReader(config._cfg)228 posargs = ['hello', 'world']229 reader.addsubstitions(posargs)230 argvlist = reader.getargvlist('section', 'key')231 assert argvlist[0] == ['cmd0'] + posargs232 assert argvlist[1] == ['cmd1', '-m', '[abc]']233 assert argvlist[2] == ['cmd2', '-m', "something"] + posargs234 assert argvlist[3] == ['cmd3', 'something[]else']235 def test_substition_with_multiple_words(self, newconfig):236 inisource = """237 [section]238 key = py.test -n5 --junitxml={envlogdir}/junit-{envname}.xml []239 """240 config = newconfig(inisource)241 reader = IniReader(config._cfg)242 posargs = ['hello', 'world']243 reader.addsubstitions(posargs, envlogdir='ENV_LOG_DIR', envname='ENV_NAME')244 expected = ['py.test', '-n5', '--junitxml=ENV_LOG_DIR/junit-ENV_NAME.xml', 'hello', 'world']245 assert reader.getargvlist('section', 'key')[0] == expected246 def test_getpath(self, tmpdir, newconfig):247 config = newconfig("""248 [section]249 path1={HELLO}250 """)251 reader = IniReader(config._cfg)252 reader.addsubstitions(toxinidir=tmpdir, HELLO="mypath")253 x = reader.getpath("section", "path1", tmpdir)254 assert x == tmpdir.join("mypath")255 def test_getbool(self, tmpdir, newconfig):256 config = newconfig("""257 [section]258 key1=True259 key2=False...

Full Screen

Full Screen

tox_backticks.py

Source:tox_backticks.py Github

copy

Full Screen

...17 setenv = venv.envconfig.setenv18 value = setenv.definitions[variable]19 cmdstr = value[1:-1]20 if LooseVersion(tox.__version__) < LooseVersion("3.21.0"):21 argvlist = _ArgvlistReader.getargvlist(reader, cmdstr, replace=True)22 else:23 argvlist = _ArgvlistReader.getargvlist(24 reader, cmdstr, replace=True, name="setenv"25 )26 argv = argvlist[0]27 with venv.new_action('backticks', venv.envconfig.envdir) as action:28 result = venv._pcall(29 argv,30 cwd=venv.envconfig.changedir,31 action=action,32 redirect=True,33 returnout=True,34 ignore_ret=False,35 )36 action.setactivity('backticks', '{}={}'.format(variable, result))37 setenv.definitions[variable] = result38 setenv.resolved = {}39 return result40@hookimpl41def tox_runtest_pre(venv):42 """Post process config after parsing."""43 setenv = venv.envconfig.setenv44 backtick_variables = dict(45 (variable, _get_used_envvars(value))46 for variable, value in setenv.definitions.items()47 if len(value) > 2 and value.startswith('`') and value.endswith('`')48 )49 if not backtick_variables:50 return51 reader = setenv.reader52 while backtick_variables:53 if len(backtick_variables) == 1:54 variable = list(backtick_variables)[0]55 _run_backtick(reader, venv, variable)56 break57 unresolved = set(backtick_variables)58 resolved = [59 variable for variable, uses in backtick_variables.items()60 if not uses.intersection(unresolved)61 ]62 for variable in resolved:63 _run_backtick(reader, venv, variable)64 del backtick_variables[variable]65 venv.envconfig.commands = reader.getargvlist('commands')66 venv.envconfig.commands_pre = reader.getargvlist('commands_pre')...

Full Screen

Full Screen

tox_run_command.py

Source:tox_run_command.py Github

copy

Full Screen

1import tox.config2from tox import hookimpl3def getargvlist(reader, command):4 return tox.config._ArgvlistReader.getargvlist(reader, command)5@hookimpl6def tox_addoption(parser):7 parser.add_argument('--run-command', help='run this command instead of configured commands')8@hookimpl9def tox_configure(config):10 alternative_cmd = config.option.run_command11 if alternative_cmd:12 for env in config.envlist:13 reader = config.envconfigs[env]._reader14 env_commands = getargvlist(reader, alternative_cmd)...

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