How to use test_remove_args method in autotest

Best Python code snippet using autotest_python

clean.py

Source:clean.py Github

copy

Full Screen

1# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other2# Spack Project Developers. See the top-level COPYRIGHT file for details.3#4# SPDX-License-Identifier: (Apache-2.0 OR MIT)5import argparse6import os7import shutil8import collections9import llnl.util.tty as tty10import spack.caches11import spack.cmd.test12import spack.cmd.common.arguments as arguments13import spack.repo14import spack.stage15import spack.config16from spack.paths import lib_path, var_path17description = "remove temporary build files and/or downloaded archives"18section = "build"19level = "long"20class AllClean(argparse.Action):21 """Activates flags -s -d -f -m and -p simultaneously"""22 def __call__(self, parser, namespace, values, option_string=None):23 parser.parse_args(['-sdfmpt'], namespace=namespace)24def setup_parser(subparser):25 subparser.add_argument(26 '-s', '--stage', action='store_true',27 help="remove all temporary build stages (default)")28 subparser.add_argument(29 '-d', '--downloads', action='store_true',30 help="remove cached downloads")31 subparser.add_argument(32 '-f', '--failures', action='store_true',33 help="force removal of all install failure tracking markers")34 subparser.add_argument(35 '-m', '--misc-cache', action='store_true',36 help="remove long-lived caches, like the virtual package index")37 subparser.add_argument(38 '-p', '--python-cache', action='store_true',39 help="remove .pyc, .pyo files and __pycache__ folders")40 subparser.add_argument(41 '-t', '--test-stage', action='store_true',42 help="remove all files in Spack test stage")43 subparser.add_argument(44 '-a', '--all', action=AllClean, help="equivalent to -sdfmpt", nargs=045 )46 arguments.add_common_arguments(subparser, ['specs'])47def clean(parser, args):48 # If nothing was set, activate the default49 if not any([args.specs, args.stage, args.downloads, args.failures,50 args.misc_cache, args.test_stage, args.python_cache]):51 args.stage = True52 # Then do the cleaning falling through the cases53 if args.specs:54 specs = spack.cmd.parse_specs(args.specs, concretize=True)55 for spec in specs:56 msg = 'Cleaning build stage [{0}]'57 tty.msg(msg.format(spec.short_spec))58 package = spack.repo.get(spec)59 package.do_clean()60 if args.stage:61 tty.msg('Removing all temporary build stages')62 spack.stage.purge()63 if args.downloads:64 tty.msg('Removing cached downloads')65 spack.caches.fetch_cache.destroy()66 if args.failures:67 tty.msg('Removing install failure marks')68 spack.installer.clear_failures()69 if args.misc_cache:70 tty.msg('Removing cached information on repositories')71 spack.caches.misc_cache.destroy()72 if args.test_stage:73 tty.msg("Removing files in test stage")74 test_remove_args = collections.namedtuple('args', ['name'])(None)75 spack.cmd.test.test_remove(test_remove_args)76 if args.python_cache:77 tty.msg('Removing python cache files')78 for directory in [lib_path, var_path]:79 for root, dirs, files in os.walk(directory):80 for f in files:81 if f.endswith('.pyc') or f.endswith('.pyo'):82 fname = os.path.join(root, f)83 tty.debug('Removing {0}'.format(fname))84 os.remove(fname)85 for d in dirs:86 if d == '__pycache__':87 dname = os.path.join(root, d)88 tty.debug('Removing {0}'.format(dname))...

Full Screen

Full Screen

test_init.py

Source:test_init.py Github

copy

Full Screen

...48 restart_script_path='fake',49 runner_path='fake')50 init.uninstall()51 self.assertIs(os.path.isfile(init_fd.name), False)52 def test_remove_args(self):53 cmd_arg = ("--include-command restart-unit --enablement-timeout 1"54 " /home/myhome --expire-time 946598401 --restart")55 expected = ("--include-command restart-unit --enablement-timeout 1"56 " /home/myhome")57 result = Init._remove_args(cmd_arg)58 self.assertEqual(result, expected)59 def test_remove_args_restart_in_middle_of_string(self):60 cmd_arg = ("--include-command restart-unit --enablement-timeout 1"61 " /home/myhome --restart --expire-time 946598401")62 expected = ("--include-command restart-unit --enablement-timeout 1"63 " /home/myhome")64 result = Init._remove_args(cmd_arg)65 self.assertEqual(result, expected)66 def test_remove_args_no_expire_time_and_no_restart(self):...

Full Screen

Full Screen

test_utils.py

Source:test_utils.py Github

copy

Full Screen

...27 assert merge_kwargs({"a": 1, "b": 2}, a=3) == {"a": 3, "b": 2}28 assert len(wrn) == 129 assert issubclass(wrn[0].category, PapermillParameterOverwriteWarning)30 assert wrn[0].message.__str__() == "Callee will overwrite caller's argument(s): a=3"31def test_remove_args():32 assert remove_args(["a"], a=1, b=2, c=3) == {"c": 3, "b": 2}33def test_retry():34 m = Mock(side_effect=RuntimeError(), __name__="m", __module__="test_s3", __doc__="m")35 wrapped_m = retry(3)(m)36 with pytest.raises(RuntimeError):37 wrapped_m("foo")38 m.assert_has_calls([call("foo"), call("foo"), call("foo")])39def test_chdir():40 old_cwd = Path.cwd()41 with TemporaryDirectory() as temp_dir:42 with chdir(temp_dir):43 assert Path.cwd() != old_cwd44 assert Path.cwd() == Path(temp_dir)45 assert Path.cwd() == old_cwd

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