How to use compare_versions method in autotest

Best Python code snippet using autotest_python

util.py

Source:util.py Github

copy

Full Screen

...86 def __gt__(self, other: "Version") -> bool:87 return self.cmp_value() > other.cmp_value()88 def __str__(self) -> str:89 return self.string90def compare_versions(a: Union[Version, str], b: Union[Version, str]):91 """92 >>> compare_versions("1.0.0", "1.0.1")93 -194 >>> compare_versions("2.0.0", "1.0.1")95 196 >>> compare_versions("1.2.3u2", "1.2.3")97 198 >>> compare_versions("1.2.3a2", "1.2.3")99 -1100 >>> compare_versions("2.0.0", "2.0.0beta3")101 1102 >>> compare_versions("2.0.1", "2.0.0~beta3")103 1104 >>> compare_versions("2.0.0", "2.0.0~beta3")105 1106 >>> compare_versions("2.5.30~dev", "2.5.30")107 -1108 >>> compare_versions("2.5.30~dev2", "2.5.30~dev1")109 1110 >>> compare_versions("2.6beta", "2.5.30~dev1")111 1112 >>> compare_versions("2.6beta", "2.6")113 -1114 >>> compare_versions("2.6beta", "2.6.0")115 -1116 >>> compare_versions("2.6beta", "2.6.1")117 -1118 >>> compare_versions("2.6.0beta1", "2.6.1")119 -1120 >>> compare_versions("5.9.1.1", "5.9.1dev")121 1122 >>> compare_versions("5.9.1.1", "5.9.2dev")123 -1124 >>> compare_versions("3.8.1qemu2.2.0", "3.9.1qemu2.2.0")125 -1126 >>> compare_versions("3.8.1qemu2.4.0", "3.8.1qemu2.2.0")127 1128 >>> compare_versions("1.22.2-1", "1.22.2")129 1130 >>> compare_versions("1.22.2-0", "1.22.2")131 1132 >>> compare_versions("3.3-0", "3.4")133 -1134 >>> compare_versions("3.3-0", "3.3-1")135 -1136 >>> compare_versions("3.3~fs0", "3.4")137 -1138 >>> compare_versions("3.3~fs0", "3.3~fs1")139 -1140 >>> compare_versions("1.22.2fs1", "1.22.2")141 1142 >>> compare_versions("1.22.2fs0", "1.22.2")143 1144 """145 # >>> compare_versions("2.6.0beta1", "2.6.0beta1.1")146 # -1147 # >>> compare_versions("2.6.0beta2", "2.6.0beta1.1")148 # 1149 if isinstance(a, Version):150 pass151 elif isinstance(a, str):152 a = Version(a)153 else:154 raise TypeError("Not a valid version string or object")155 if isinstance(b, Version):156 pass157 elif isinstance(b, str):158 b = Version(b)159 else:160 raise TypeError("Not a valid version string or object")161 # cmp is gone in Python 3...

Full Screen

Full Screen

test_version.py

Source:test_version.py Github

copy

Full Screen

...10 "Test version checks"11 def test_version_equal(self):12 dot_kapitan_version = "0.22.0"13 current_version = "0.22.0"14 result = compare_versions(dot_kapitan_version, current_version)15 self.assertEqual(result, "equal")16 def test_version_rc_equal(self):17 dot_kapitan_version = "0.22.0-rc.1"18 current_version = "0.22.0-rc.1"19 result = compare_versions(dot_kapitan_version, current_version)20 self.assertEqual(result, "equal")21 def test_version_major_equal(self):22 dot_kapitan_version = "0.22"23 current_version = "0.22.1"24 result = compare_versions(dot_kapitan_version, current_version)25 self.assertEqual(result, "equal")26 def test_version_one_rc_major_equal(self):27 dot_kapitan_version = "0.22"28 current_version = "0.22.1-rc.1"29 result = compare_versions(dot_kapitan_version, current_version)30 self.assertEqual(result, "equal")31 def test_version_greater(self):32 dot_kapitan_version = "0.22.1"33 current_version = "0.22.0"34 result = compare_versions(dot_kapitan_version, current_version)35 self.assertEqual(result, "greater")36 def test_version_one_rc_greater(self):37 dot_kapitan_version = "0.22.0"38 current_version = "0.22.0-rc.1"39 result = compare_versions(dot_kapitan_version, current_version)40 self.assertEqual(result, "greater")41 def test_version_both_rc_greater(self):42 dot_kapitan_version = "0.22.1-rc.1"43 current_version = "0.22.0-rc.1"44 result = compare_versions(dot_kapitan_version, current_version)45 self.assertEqual(result, "greater")46 def test_version_both_rc_major_greater(self):47 dot_kapitan_version = "0.23.0-rc.1"48 current_version = "0.22.0-rc.1"49 result = compare_versions(dot_kapitan_version, current_version)50 self.assertEqual(result, "greater")51 def test_version_lower(self):52 dot_kapitan_version = "0.22.0"53 current_version = "0.22.1"54 result = compare_versions(dot_kapitan_version, current_version)55 self.assertEqual(result, "lower")56 def test_version_one_rc_lower(self):57 dot_kapitan_version = "0.22.0-rc.1"58 current_version = "0.22.0"59 result = compare_versions(dot_kapitan_version, current_version)60 self.assertEqual(result, "lower")61 def test_version_both_rc_lower(self):62 dot_kapitan_version = "0.22.0-rc.1"63 current_version = "0.22.1-rc.1"64 result = compare_versions(dot_kapitan_version, current_version)65 self.assertEqual(result, "lower")66 def test_version_both_rc_major_lower(self):67 dot_kapitan_version = "0.22.0-rc.1"68 current_version = "0.23.0-rc.1"69 result = compare_versions(dot_kapitan_version, current_version)...

Full Screen

Full Screen

utils_test.py

Source:utils_test.py Github

copy

Full Screen

1from vulnix.utils import compare_versions, split_components, haskeys2def test_compare_versions():3 """Tests from https://nixos.org/nix/manual/#ssec-version-comparisons"""4 assert -1 == compare_versions('1.0', '2.3')5 assert -1 == compare_versions('2.1', '2.3')6 assert 0 == compare_versions('2.3', '2.3')7 assert 1 == compare_versions('2.5', '2.3')8 assert 1 == compare_versions('3.1', '2.3')9 assert 1 == compare_versions('2.3.1', '2.3')10 assert 1 == compare_versions('2.3.1', '2.3a')11 assert 1 == compare_versions('2.3', '2.3pre')12 assert -1 == compare_versions('2.3pre1', '2.3')13 assert -1 == compare_versions('2.3pre3', '2.3pre12')14 assert -1 == compare_versions('2.3a', '2.3c')15 assert -1 == compare_versions('2.3pre1', '2.3c')16 assert -1 == compare_versions('2.3pre1', '2.3q')17def test_split_components():18 assert ['2', '3', 'pre', '1'] == list(split_components('2.3pre1'))19 assert ['2019', '11', '01'] == list(split_components('2019-11-01'))20 assert ['5', '1', 'a', 'lts'] == list(split_components('5.1a-lts'))21def test_haskeys():22 assert not haskeys({}, 'foo')23 assert haskeys({'foo': 1}, 'foo')24 assert not haskeys({'foo': 1}, 'foo', 'bar')25 assert haskeys({'foo': {'bar': 1}}, 'foo', 'bar')...

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