Best Python code snippet using tox_python
test_tested_versions.py
Source:test_tested_versions.py
...7)8def test_tested_versions_sorts_on_constructor():9 assert TestedVersions(10 [11 parse_version("0.0.1"),12 parse_version("0.0.3"),13 parse_version("0.0.2"),14 ]15 ).versions == [16 parse_version("0.0.1"),17 parse_version("0.0.2"),18 parse_version("0.0.3"),19 ]20def test_tested_versions_is_frozen():21 try:22 TestedVersions([]).versions = [parse_version("0.0.1")]23 raise Exception("We should not have gotten here")24 except attr.exceptions.FrozenInstanceError:25 pass26def test_parse_supported_semantic_version():27 assert parse_version(" 1.2.3 # test!") == SemanticVersion(28 True, "1.2.3 # test!", 1, 2, 3, "", "test!"29 )30def test_parse_semantic_version_equality_ignores_supported_flag():31 assert parse_version("!1.2.3") == SemanticVersion(32 False, "1.2.3 # test!", 1, 2, 3, "", "test!"33 )34def test_parse_semantic_version_equality_ignores_comment():35 # We disregard support in equality checks36 assert parse_version("1.2.3 # comment") == parse_version("1.2.3")37def test_parse_semantic_version_preserve_original_version_string():38 assert (39 SemanticVersion(False, " 1.2.3 # test!", 1, 2, 3, "", "test!").version40 == " 1.2.3 # test!"41 )42def test_semantic_version_sorting_ignores_supported_flag():43 assert parse_version("!1.2.3") < parse_version("1.2.4")44def test_semantic_version_always_smaller_than_non_semantic_version():45 assert parse_version("!1.2.3") < parse_version("0.1")46def test_non_semantic_versions_are_sorted_lexicographically():47 assert parse_version("0.11") < parse_version("0.2")48def test_sorting_mixed_version_types():49 assert sorted(50 [parse_version("1.3.5"), parse_version("0.2"), parse_version("1.2.3")]51 ) == [parse_version("1.2.3"), parse_version("1.3.5"), parse_version("0.2")]52def test_consecutive_semantic_version_range():53 assert (54 _get_supported_version_ranges(55 TestedVersions(56 [57 parse_version("0.0.1"),58 parse_version("0.0.2"),59 parse_version("0.0.3"),60 ]61 )62 )63 == ["0.0.1~0.0.3"]64 )65def test_semantic_version_ranges_with_break():66 assert (67 _get_supported_version_ranges(68 TestedVersions(69 [70 parse_version("0.0.1"),71 parse_version("0.0.2"),72 parse_version("!0.0.3"),73 parse_version("0.0.4"),74 parse_version("0.0.5"),75 ]76 )77 )78 == ["0.0.1~0.0.2", "0.0.4~0.0.5"]79 )80def test_semantic_version_ranges_with_break_and_minor_jump():81 assert (82 _get_supported_version_ranges(83 TestedVersions(84 [85 parse_version("0.0.1"),86 parse_version("0.0.2"),87 parse_version("!0.0.3"),88 parse_version("0.0.4"),89 parse_version("0.1.1"),90 ]91 )92 )93 == ["0.0.1~0.0.2", "0.0.4~0.1.1"]94 )95def test_semantic_version_ranges_with_break_and_major_jump():96 assert (97 _get_supported_version_ranges(98 TestedVersions(99 [100 parse_version("0.0.1"),101 parse_version("0.0.2"),102 parse_version("!0.0.3"),103 parse_version("0.0.4"),104 parse_version("1.0.0"),105 ]106 )107 )108 == ["0.0.1~0.0.2", "0.0.4", "1.0.0"]109 )110def test_semantic_version_ranges_with_unsupported_beginning():111 assert (112 _get_supported_version_ranges(113 TestedVersions(114 [115 parse_version("!0.0.1"),116 parse_version("0.0.2"),117 parse_version("0.0.3"),118 ]119 )120 )121 == ["0.0.2~0.0.3"]122 )123def test_semantic_version_ranges_with_multiple_unsupported_beginning():124 assert (125 _get_supported_version_ranges(126 TestedVersions(127 [128 parse_version("!0.0.1"),129 parse_version("!0.0.2"),130 parse_version("0.0.3"),131 ]132 )133 )134 == ["0.0.3"]135 )136def test_semantic_version_ranges_with_unsupported_ending():137 assert (138 _get_supported_version_ranges(139 TestedVersions(140 [141 parse_version("0.0.1"),142 parse_version("0.0.2"),143 parse_version("!0.0.3"),144 ]145 )146 )147 == ["0.0.1~0.0.2"]148 )149def test_semantic_version_ranges_with_multiple_unsupported_ending():150 assert (151 _get_supported_version_ranges(152 TestedVersions(153 [154 parse_version("0.0.1"),155 parse_version("!0.0.2"),156 parse_version("!0.0.3"),157 ]158 )159 )160 == ["0.0.1"]161 )162def test_semantic_version_ranges_with_multiple_unsupported_beginning_and_breaks():163 assert (164 _get_supported_version_ranges(165 TestedVersions(166 [167 parse_version("!0.0.1"),168 parse_version("0.0.2"),169 parse_version("0.0.3"),170 parse_version("0.1.0"),171 parse_version("!0.1.1"),172 parse_version("1.0.1"),173 ]174 )175 )176 == ["0.0.2~0.1.0", "1.0.1"]177 )178def test_skipping_non_semantic_versions():179 assert (180 _get_supported_version_ranges(181 TestedVersions(182 [183 parse_version("!0.0.1"),184 parse_version("0.0.2"),185 parse_version("0.0.3"),186 parse_version("0.1.0"),187 parse_version("!0.2"),188 parse_version("nonsemantic"),189 ]190 )191 )192 == ["0.0.2~0.1.0", "nonsemantic"]193 )194def test_skipping_multiple_non_semantic_versions():195 assert (196 _get_supported_version_ranges(197 TestedVersions(198 [199 parse_version("!0.0.1"),200 parse_version("0.0.2"),201 parse_version("0.0.3"),202 parse_version("0.1.0"),203 parse_version("!0.2"),204 parse_version("!nonsemantic"),205 ]206 )207 )208 == ["0.0.2~0.1.0"]209 )210def test_non_semantic_version_ranges():211 assert (212 _get_supported_version_ranges(213 TestedVersions(214 [215 parse_version("!0.0.1"),216 parse_version("0.0.2"),217 parse_version("0.0.3"),218 parse_version("0.1.0"),219 parse_version("!0.2"),220 parse_version("nonsemantic1"),221 parse_version("nonsemantic2"),222 ]223 )224 )225 == ["0.0.2~0.1.0", "nonsemantic1", "nonsemantic2"]...
has_version.py
Source:has_version.py
1import ansible2from pkg_resources import parse_version3has_ansible_v1 = parse_version(ansible.__version__) < parse_version('2.0.0')4has_ansible_v2 = parse_version(ansible.__version__) >= parse_version('2.0.0')5has_ansible_v24 = parse_version(ansible.__version__) >= parse_version('2.4.0')6has_ansible_v28 = parse_version(ansible.__version__) >= parse_version('2.8.0.dev0') \7 or parse_version(ansible.__version__) >= parse_version('2.8.0')8has_ansible_v29 = parse_version(ansible.__version__) >= parse_version('2.9.0')9has_ansible_v212 = parse_version(ansible.__version__) >= parse_version('2.12.0')...
test_third_party.py
Source:test_third_party.py
1from unittest import TestCase2from pkg_resources import parse_version3class TestPkgResources(TestCase):4 def test_parse_version(self):5 self.assertGreater(parse_version('3.4.1'), parse_version('3.4.0'))6 self.assertGreater(parse_version('3.4.1'), parse_version('3.4.dev'))...
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!!