How to use extract_version method in autotest

Best Python code snippet using autotest_python

test_prf_finder.py

Source:test_prf_finder.py Github

copy

Full Screen

...373class ExtractVersionTestCase(TestCase):374 """Verify that release version names are correctly extracted."""375 def test_extract_version_common_name(self):376 """Verify the common file names."""377 version = extract_version('emacs-21.10.tar.gz')378 self.assertEqual(version, '21.10')379 version = extract_version('emacs-21.10.01.tar.gz')380 self.assertEqual(version, '21.10.01')381 version = extract_version('emacs-21.10.01.2.tar.gz')382 self.assertEqual(version, '21.10.01.2')383 version = extract_version('bzr-1.15rc1.tar.gz')384 self.assertEqual(version, '1.15rc1')385 version = extract_version('bzr-1.15_rc1.tar.gz')386 self.assertEqual(version, '1.15-rc1')387 version = extract_version('bzr-1.15_beta1.tar.gz')388 self.assertEqual(version, '1.15-beta1')389 def test_extract_version_ignores_uncommon_names(self):390 """Unknown file extension is not included in version."""391 # Bug #412015. If there is no filename extension that Launchpad392 # understands after the version number, we have a dud match.393 version = extract_version('bzr-1.15_beta1.tar.gz.asc')394 self.assertEqual(version, None)395 version = extract_version('bzr-1.15_beta1.tar.7z')396 self.assertEqual(version, None)397 version = extract_version('bzr-1.15_beta1.bckup')398 self.assertEqual(version, None)399 def test_extract_version_debian_name(self):400 """Verify that the debian-style .orig suffix is handled."""401 version = extract_version('emacs-21.10.orig.tar.gz')402 self.assertEqual(version, '21.10')403 def test_extract_version_name_with_supported_types(self):404 """Verify that the file's mimetype is supported."""405 version = extract_version('emacs-21.10.tar.gz')406 self.assertEqual(version, '21.10')407 version = extract_version('emacs-21.10.tar')408 self.assertEqual(version, '21.10')409 version = extract_version('emacs-21.10.gz')410 self.assertEqual(version, '21.10')411 version = extract_version('emacs-21.10.tar.Z')412 self.assertEqual(version, '21.10')413 version = extract_version('emacs-21.10.tar.bz2')414 self.assertEqual(version, '21.10')415 version = extract_version('emacs-21.10.zip')416 self.assertEqual(version, '21.10')417 def test_extract_version_name_with_flavors(self):418 """Verify that language, processor, and packaging are removed."""419 version = extract_version('furiusisomount-0.8.1.0_de_DE.tar.gz')420 self.assertEqual(version, '0.8.1.0')421 version = extract_version('glow-0.2.0_all.deb')422 self.assertEqual(version, '0.2.0')423 version = extract_version('glow-0.2.1_i386.deb')424 self.assertEqual(version, '0.2.1')425 version = extract_version('ipython-0.8.4.win32-setup.exe')426 self.assertEqual(version, '0.8.4')427 version = extract_version('Bazaar-1.16.1.win32-py2.5.exe')428 self.assertEqual(version, '1.16.1')429 version = extract_version(' Bazaar-1.16.0-OSX10.5.dmg')430 self.assertEqual(version, '1.16.0')431 version = extract_version('Bazaar-1.16.2-OSX10.4-universal-py25.dmg')432 self.assertEqual(version, '1.16.2')433 version = extract_version('Bazaar-1.16.3.exe')434 self.assertEqual(version, '1.16.3')435 version = extract_version('partitionmanager-21-2.noarch.rpm')436 self.assertEqual(version, '21-2')437 version = extract_version('php-fpm-0.6~5.3.1.tar.gz')438 self.assertEqual(version, '0.6')439 version = extract_version('u1f-google-1.2.4.apk')440 self.assertEqual(version, '1.2.4')441 version = extract_version('unetbootin-linux-603.bin')442 self.assertEqual(version, '603')443 def test_extract_version_name_with_uppercase(self):444 """Verify that the file's version is lowercases."""445 version = extract_version('client-2.4p1A.tar.gz')446 self.assertEqual(version, '2.4p1a')447 def test_extract_version_name_with_bad_characters(self):448 """Verify that the file's version is lowercases."""449 version = extract_version('vpnc-0.2-rm+zomb-pre1.tar.gz')450 self.assertEqual(version, '0.2-rm-zomb-pre1')451 version = extract_version('warzone2100-2.0.5_rc1.tar.bz2')...

Full Screen

Full Screen

version_utils.py

Source:version_utils.py Github

copy

Full Screen

...22 new_version = '.'.join(splitted_version)23 return new_version24 @staticmethod25 def diff_version(version1, version2):26 if VersionUtils.extract_version(version1, Version.MAJOR) > VersionUtils.extract_version(version2, Version.MAJOR):27 return 128 elif VersionUtils.extract_version(version1, Version.MAJOR) < VersionUtils.extract_version(version2, Version.MAJOR):29 return -130 else:31 if VersionUtils.extract_version(version1, Version.MINOR) > VersionUtils.extract_version(version2, Version.MINOR):32 return 133 elif VersionUtils.extract_version(version1, Version.MINOR) < VersionUtils.extract_version(version2, Version.MINOR):34 return -135 else:36 if VersionUtils.extract_version(version1, Version.PATCH) > VersionUtils.extract_version(version2, Version.PATCH):37 return 138 elif VersionUtils.extract_version(version1, Version.PATCH) < VersionUtils.extract_version(version2, Version.PATCH):39 return -140 else:41 return 042 @staticmethod43 def extract_version(version, version_type):44 try:45 splitted_version = version.replace('-SNAPSHOT', '').split('.')46 return int(splitted_version[len(splitted_version) - version_type.value])47 except Exception as e:48 return -149 @staticmethod50 def adjust_versions():51 config = Config()52 project = ProjectManagerStrategy.get_instance(os.getcwd())53 git = GitHelper()54 git.checkout_and_pull(config.master_branch)55 master_version = project.actual_version()56 incremented_version = VersionUtils.get_new_version(master_version, Version.MINOR, True, 1)57 new_version = '{}.{}.0'.format(VersionUtils.extract_version(incremented_version, Version.MAJOR), VersionUtils.extract_version(incremented_version, Version.MINOR))58 git.checkout_and_pull(config.staging_branch)59 project.update_version(new_version)60 git.commit_and_push_update_message(config.staging_branch, new_version)61 @staticmethod62 def format_version(format, version, project_name=''):63 formatted_version = format64 formatted_version = formatted_version.replace('{project}', project_name)65 formatted_version = formatted_version.replace('{major}', str(VersionUtils.extract_version(version, Version.MAJOR)))66 formatted_version = formatted_version.replace('{minor}', str(VersionUtils.extract_version(version, Version.MINOR)))67 formatted_version = formatted_version.replace('{patch}', str(VersionUtils.extract_version(version, Version.PATCH)))68 return formatted_version69class Version(Enum):70 NONE = 071 PATCH = 172 MINOR = 2...

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