How to use check_version method in avocado

Best Python code snippet using avocado_python

test_compatibleversion.py

Source:test_compatibleversion.py Github

copy

Full Screen

...6from compatibleversion import check_version7def test_problems():8 """Tests for expected exceptions."""9 with pytest.raises(ValueError):10 check_version('', '<1.0.0')11 with pytest.raises(ValueError):12 check_version('1.0.0', '')13 with pytest.raises(packaging.version.InvalidVersion):14 check_version('very bad version', '<1.0.0')15 with pytest.raises(packaging.version.InvalidVersion):16 check_version('very.bad.version', '<1.0.0')17 with pytest.raises(packaging.version.InvalidVersion):18 check_version('very.1.0', '<1.0.0')19 with pytest.raises(packaging.specifiers.InvalidSpecifier):20 check_version('1.0.0', 'very bad specifier')21 with pytest.raises(packaging.specifiers.InvalidSpecifier):22 check_version('0.0.0', '0.0.0')23 with pytest.raises(packaging.specifiers.InvalidSpecifier):24 check_version('0.0.0', '=0.0.0')25 with pytest.raises(packaging.specifiers.InvalidSpecifier):26 check_version('0.0.0', '!0.0.0')27def test_versions():28 """Tests for a variety of version types."""29 assert check_version('1.2.0', '==1.2.0')30 assert check_version('0.0.0', '==0.0.0')31 assert check_version('0.9', '==0.9')32 assert check_version('0.9.1', '==0.9.1')33 assert check_version('0.9.2', '==0.9.2')34 assert check_version('0.9.10', '==0.9.10')35 assert check_version('0.9.11', '==0.9.11')36 assert check_version('1.0', '==1.0')37 assert check_version('1.0.1', '==1.0.1')38 assert check_version('1.1', '==1.1')39 assert not check_version('2.0', '!=2.0')40 assert check_version('2.0.1', '==2.0.1')41 assert check_version('1.0a1', '==1.0a1')42 assert check_version('1.0a2', '==1.0a2')43 assert check_version('1.0b1', '==1.0b1')44 assert check_version('1.0rc1', '==1.0rc1')45 assert check_version('1.0.dev1', '==1.0.dev1')46 assert check_version('1.0.dev2', '==1.0.dev2')47 assert check_version('1.0.dev3', '==1.0.dev3')48 assert check_version('1.0.dev4', '==1.0.dev4')49 assert check_version('1.0b2.post345.dev456', '==1.0b2.post345.dev456')50 assert check_version('1.0b2.post345', '==1.0b2.post345')51 assert check_version('1.0rc1.dev456', '==1.0rc1.dev456')52 assert check_version('1.1.dev456', '>=1.0')53 assert check_version('1.dev0', '>=0')54 assert check_version('99.9.9.dev0', '>=20.1')55 assert not check_version('1.1.dev456', '>=1.0', False) # don't allow pre56 assert not check_version('1.dev0', '>=0', False) # don't allow pre57 assert not check_version('99.9.9.dev0', '>=20.1', False) # don't allow pre58 assert not check_version('1.0.dev456', '>=1.0')59 assert not check_version('1.1.dev456', '>=1.0', False)60 assert not check_version('1.0.dev456', '>=1.0', False)61 assert check_version('1.1.dev0', '>=1.0')62 assert not check_version('1.1.dev0', '>=1.0', False)63 assert check_version('1.1.dev0', '>=1.0.dev0')64 assert check_version('1.1.dev0', '>=1.0.dev0', False)65def test_specifiers():66 """Tests for a variety of specifier types."""67 assert not check_version('1.0rc1.dev456', '==1.0.1')68 assert not check_version('1.0rc1.dev456', '< 1.2, > 1.3') # no version69 assert not check_version('2.9.9', '< 1.2, > 1.3') # can match70 assert not check_version('1.2.5', '< 1.2, > 1.3')71 assert check_version('1.3.0', '> 1.2, < 3.3')72 assert check_version('2.5', '> 1.2, < 3.3')73 assert not check_version('4.9.9', '> 1.2, < 3.3')74 assert not check_version('1.1.0.1', '> 1.2, < 3.3')75 assert check_version('1.0.0.0', '>= 1.0, != 1.3.4.*, < 2.0')76 assert check_version('1.9.9', '>= 1.0, != 1.3.4.*, < 2.0')77 assert not check_version('1.3.4.99', '>= 1.0, != 1.3.4.*, < 2.0')78 assert not check_version('2.0.0.0', '>= 1.0, != 1.3.4.*, < 2.0')79 assert check_version('1.4.5.9', '~= 1.4.5.0')80 assert not check_version('1.4.6', '~= 1.4.5.0')81 assert check_version('1.0rc1.dev456', '>= 1.*')82 assert check_version('1.999.1', '>= 1.*')83 assert check_version('2.3', '~= 2.2')84 assert not check_version('2.1', '~= 2.2')85 assert not check_version('3.0', '~= 2.2')86 assert check_version('2.3', '>= 2.2, == 2.*')87 assert not check_version('2.1', '>= 2.2, == 2.*')88 assert not check_version('3.0', '>= 2.2, == 2.*')89 # version 3.1 or later, but not version 4.0 or later.90 assert check_version('3.2', '~=3.1')91 assert not check_version('4.0', '~=3.1')92 # version 3.1.2 or later, but not version 3.2.0 or later.93 assert check_version('3.1.2.99', '~= 3.1.2')94 assert not check_version('3.2.0.0', '~= 3.1.2')95 # version 3.1a1 or later, but not version 4.0 or later.96 assert check_version('3.1a2', '~= 3.1a1')97 assert not check_version('3.2a3', '~= 3.1a1')98 assert not check_version('4.0a1', '~= 3.1a1')99 # specifically version 3.1 (or 3.1.0), excludes all pre-releases, post100 # releases, developmental releases and any 3.1.x maintenance releases.101 assert check_version('3.1', '== 3.1')102 assert check_version('3.1.0', '== 3.1')103 assert not check_version('3.1.1', '== 3.1')104 # any version that starts with 3.1. Equivalent to the ~=3.1.0 compatible105 # release clause.106 assert not check_version('1.0rc1.dev456', '== 3.1.*')107 assert check_version('3.1.99.9999', '== 3.1.*')108 assert not check_version('3.2.99.9999', '== 3.1.*')109 # version 3.1.0 or later, but not version 3.1.3 and not version 3.2.0 or110 # later.111 assert check_version('3.1.0', '~=3.1.0, != 3.1.3')112 assert check_version('3.1.3.99', '~=3.1.0, != 3.1.3')...

Full Screen

Full Screen

test_version.py

Source:test_version.py Github

copy

Full Screen

1from julearn.utils.versions import check_version, _joblib_parallel_args2def test_major_true():3 assert check_version("3.5.1", lambda x: int(x) > 1)4def test_major_false():5 assert check_version("1.5.1", lambda x: int(x) > 1) is False6def test_minor_true():7 assert check_version("3.5.1", minor_check=lambda x: int(x) > 2)8def test_minor_false():9 assert check_version("3.1.1", minor_check=lambda x: int(x) >= 2) is False10def test_patch_true():11 assert check_version("3.1.5", patch_check=lambda x: int(x) > 2)12def test_patch_false():13 assert check_version("3.1.1", patch_check=lambda x: int(x) >= 2) is False14def test_multiple_true():15 assert check_version("3.2.1",16 major_check=lambda x: int(x) == 3,17 minor_check=lambda x: int(x) == 2,18 patch_check=lambda x: int(x) >= 1)19def test_multiple_false():20 assert check_version("3.2.1",21 major_check=lambda x: int(x) == 3,22 minor_check=lambda x: int(x) == 3,23 patch_check=lambda x: int(x) >= 2) is False24def test_joblib_args_higer_1(monkeypatch):25 with monkeypatch.context() as m:26 m.setattr("sklearn.__version__", "2.2.11")27 kwargs = _joblib_parallel_args(prefer="threads")28 assert kwargs["prefer"] == "threads"29def test_joblib_args_lower_1(monkeypatch):30 with monkeypatch.context() as m:31 import sklearn32 m.setattr("sklearn.__version__", "0.24.2")33 m.setattr(34 sklearn.utils.fixes, "_joblib_parallel_args",...

Full Screen

Full Screen

check_environment.py

Source:check_environment.py Github

copy

Full Screen

...11import pandas12import PIL13import seaborn14import tensorflow15def check_version(pkg, version):16 """17 check version function18 """19 actual = pkg.__version__.split(".")20 if len(actual) >= 2:21 actual_major = ".".join(actual)22 else:23 raise NotImplementedError(pkg.__name__ + "actual version :" + pkg.__version__)24 try:25 assert actual_major == version26 except Exception as ex:27 print("{} {}\t=> {}".format(pkg.__name__, version, pkg.__version__))28 raise ex29if __name__ == "__main__":30 print(executable)31 print(sysv)32 print(__file__)33 check_version(pip, "21.3.1")34 check_version(numpy, "1.19.5")35 check_version(matplotlib, "3.5.0")36 check_version(sklearn, "1.0.1")37 check_version(scipy, "1.7.3")38 check_version(pandas, "1.3.4")39 check_version(PIL, "8.4.0")40 check_version(seaborn, "0.11.2")41 check_version(tensorflow, "2.6.0")...

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 avocado 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