Best Python code snippet using autotest_python
test_get_package_name.py
Source:test_get_package_name.py
2from debpacker.toolchain.toolchain import _get_package_name3class TestGetPackageName(TestCase):4 def test_fix_underscore(self):5 expected = 'zenterio-intel-i686-linux-2.6.39-gcc-4.5.1-uclibc-0.9.27'6 actual = _get_package_name('intel-i686_linux-2.6.39_gcc-4.5.1_uclibc-0.9.27')7 self.assertEqual(expected, actual)8 def test_fix_upper_case_characters(self):9 expected = 'zenterio-intelce-i686'10 actual = _get_package_name('IntelCE-i686')11 self.assertEqual(expected, actual)12 def test_fix_single_compress_format(self):13 expected = 'zenterio-package'14 actual = _get_package_name('package.tgz')15 self.assertEqual(expected, actual)16 def test_fix_multiple_extensions_compress_format(self):17 expected = 'zenterio-package'18 actual = _get_package_name('package.tar.gz')19 self.assertEqual(expected, actual)20 def test_fix_tar_bz2_format(self):21 expected = 'zenterio-package'22 actual = _get_package_name('package.tar.bz2')23 self.assertEqual(expected, actual)24 def test_fix_all(self):25 expected = 'zenterio-intelce-i686-linux-2.6.39-gcc-4.5.1-uclibc-0.9.27'26 actual = _get_package_name('IntelCE-i686_linux-2.6.39_gcc-4.5.1_uclibc-0.9.27')...
__init__.py
Source:__init__.py
...3import rosunit4import rostest5from catkin_pkg.package import parse_package6from .test_case import TestCase7def _get_package_name(test_case: type) -> str:8 path = Path(inspect.getfile(test_case))9 while not path.samefile(path.root):10 if (path / "package.xml").exists():11 package = parse_package(path / "package.xml", warnings=[])12 return package.name13 path = path.parent14 raise Exception(f"Could not determine package name for TestCase {test_case}")15def run_unit_tests(*test_cases: type):16 """Run all the specified unit TestCases"""17 for i in test_cases:18 assert issubclass(i, TestCase), f"Test case {i} does not inherit from base bitbots TestCase"19 rosunit.unitrun(_get_package_name(i), i.__name__, i)20def run_rostests(*test_cases: type):21 """Run all the specified rostest TestCases"""22 for i in test_cases:23 assert issubclass(i, TestCase), f"Test case {i} does not inherit from base bitbots TestCase"...
app.py
Source:app.py
1import subprocess2from typing import List3def run_subprocess(command: List[str]) -> str:4 return subprocess.run(command, capture_output=True).stdout.decode()5def _get_package_name(command: List[str]) -> List[str]:6 output = run_subprocess(command) 7 return [line.split()[0] for line in output.split("\n") if len(line.split()) > 0]8def get_package_names():9 poetry_show_outdated = ["poetry", "show", "--outdated"]10 all_packages = _get_package_name(poetry_show_outdated)11 no_dev_packages = _get_package_name(poetry_show_outdated + ["--no-dev"])12 dev_packages = list(set(all_packages) - set(no_dev_packages))13 return no_dev_packages, dev_packages14def update_all_packages():15 no_dev_packages, dev_packages = get_package_names()16 for package in no_dev_packages:17 subprocess.run(18 ["poetry", "add", f"{package}@latest"],19 )20 for package in dev_packages:21 subprocess.run(22 ["poetry", "add", "--dev", f"{package}@latest"]23 )24if __name__ == "__main__":25 update_all_packages()
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!!