How to use get_version_info method in tox

Best Python code snippet using tox_python

set_version.py

Source:set_version.py Github

copy

Full Screen

...19 sys.exit('Failed (%s) to run %r' % (retcode, command))20 return data.strip()21def get_changeset():22 return read('git describe --tags --always --dirty --long')23def get_version_info(version):24 """25 >>> get_version_info('0.13.6')26 (0, 13, 6, 'final', 0)27 >>> get_version_info('1.1')28 (1, 1, 0, 'final', 0)29 >>> get_version_info('1')30 (1, 0, 0, 'final', 0)31 >>> get_version_info('1.0dev1')32 (1, 0, 0, 'dev', 1)33 >>> get_version_info('1.0a3')34 (1, 0, 0, 'alpha', 3)35 >>> get_version_info('1.0rc1')36 (1, 0, 0, 'candidate', 1)37 """38 repl = {'a': 'alpha',39 'b': 'beta',40 'rc': 'candidate',41 'dev': 'dev'}42 components = LooseVersion(version).version43 result = []44 for component in components:45 if isinstance(component, int):46 result.append(component)47 else:48 while len(result) < 3:49 result.append(0)50 component = repl[component]51 result.append(component)52 while len(result) < 3:53 result.append(0)54 if len(result) == 3:55 result.append('final')56 result.append(0)57 return tuple(result)58def modify_version(filename, new_version):59 # return (current_contents, modified_contents, is_match)60 original_data = open(filename).read()61 assert '__changeset__' not in original_data, 'Must revert the old update first'62 data = original_data63 if new_version:64 new_version_info = get_version_info(new_version)65 def repl_version_info(m):66 return 'version_info = %s' % (new_version_info, )67 data, count = version_info_re.subn(repl_version_info, data)68 if not count:69 raise AssertionError('version_info not found in %s' % filename)70 if count != 1:71 raise AssertionError('version_info found more than once in %s' % filename)72 def repl_version(m):73 result = m.group(0).replace(m.group(1), new_version or m.group(1))74 result += "\n__changeset__ = '%s'" % get_changeset()75 return result76 data, count = version_re.subn(repl_version, data)77 if not count:78 raise AssertionError('__version__ not found in %s' % filename)...

Full Screen

Full Screen

test_libdockerflow.py

Source:test_libdockerflow.py Github

copy

Full Screen

2# License, v. 2.0. If a copy of the MPL was not distributed with this3# file, You can obtain one at https://mozilla.org/MPL/2.0/.4from pathlib import Path5from antenna.libdockerflow import get_version_info, get_release_name6def test_get_version_info(tmpdir):7 fn = tmpdir.join("/version.json")8 fn.write_text(9 '{"commit": "d6ac5a5d2acf99751b91b2a3ca651d99af6b9db3"}', encoding="utf-8"10 )11 assert get_version_info(str(tmpdir)) == {12 "commit": "d6ac5a5d2acf99751b91b2a3ca651d99af6b9db3"13 }14def test_version_info_malformed(tmpdir):15 """Return {} if version.json is malformed"""16 version_info = "{abc"17 version_json = tmpdir / "version.json"18 version_json.write(version_info)19 # Test with str path20 tmpdir = str(tmpdir)21 assert get_version_info(tmpdir) == {}22 # Test with Path path23 tmpdir = Path(tmpdir)24 assert get_version_info(tmpdir) == {}25def test_get_version_info_no_file(tmpdir):26 """Return {} if there is no version.json"""27 # Test with str path28 tmpdir = str(tmpdir)29 assert get_version_info(tmpdir) == {}30 # Test with Path path31 tmpdir = Path(tmpdir)32 assert get_version_info(tmpdir) == {}33def test_get_release_name(tmpdir):34 fn = tmpdir.join("/version.json")35 fn.write_text(36 '{"commit": "d6ac5a5d2acf99751b91b2a3ca651d99af6b9db3", "version": "44.0"}',37 encoding="utf-8",38 )39 assert get_release_name(str(tmpdir)) == "44.0:d6ac5a5d"40def test_get_release_name_no_commit(tmpdir):41 fn = tmpdir.join("/version.json")42 fn.write_text('{"version": "44.0"}', encoding="utf-8")43 assert get_release_name(str(tmpdir)) == "44.0:unknown"44def test_get_release_name_no_version(tmpdir):45 fn = tmpdir.join("/version.json")46 fn.write_text(...

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