How to use _final_version method in robotframework-androidlibrary

Best Python code snippet using robotframework-androidlibrary_python

base.py

Source:base.py Github

copy

Full Screen

...12#13##############################################################################14from pkg_resources import parse_version, Requirement15from setuptools import package_index16def _final_version(parsed_version):17 """Function copied from zc.buildout.easy_install._final_version."""18 return not parsed_version.is_prerelease19class Checker(object):20 """Base class for version checkers21 attributes:22 index_url: url of an alternative package index23 verbose: display every version, not only new ones,24 and display the previous version as a comment25 blacklist: filename of the blacklist26 incremental: suggest only one package upgrade27 """28 __custom_url = False29 def __init__(self,30 index_url=None,31 verbose=False,32 blacklist=None,33 incremental=False):34 self.verbose = verbose35 self.incremental = incremental36 if blacklist:37 # create a set of tuples with bad versions38 with open(blacklist) as b:39 self.blacklist = set([40 tuple(map(lambda x: x.strip(), line.split('=')))41 for line in b.readlines()42 if '=' in line43 ])44 else:45 self.blacklist = set()46 self.pi = package_index.PackageIndex(search_path=())47 self._set_index_url(index_url)48 if index_url is not None:49 self.__custom_url = True50 def _set_index_url(self, url):51 """Set the index URL."""52 if url is not None:53 self.pi.index_url = url54 if not self.pi.index_url.endswith('/'):55 self.pi.index_url += '/'56 def check(self, level=0):57 """Search new versions in a version list58 versions must be a dict {'name': 'version'}59 The new version is limited to the given level:60 Example with version x.y.z61 level = 0: checks new version x62 level = 1: checks new version y63 level = 2: checks new version z64 By default, the highest version is found.65 """66 versions = self.get_versions()67 for name, version in sorted(versions.items()):68 if self.incremental == 'stop':69 # skip subsequent scans70 print("%s=%s" % (name, version))71 continue72 parsed_version = parse_version(version)73 req = Requirement.parse(name)74 self.pi.find_packages(req)75 new_dist = None76 # loop all index versions until we find the 1st newer version77 # that keeps the major versions (below level)78 # and is a final version79 # and is not in the blacklist80 for dist in self.pi[req.key]:81 if self.incremental == 'stop':82 continue83 if (dist.project_name, dist.version) in self.blacklist:84 continue85 if (_final_version(parsed_version)86 and not _final_version(dist.parsed_version)):87 # only skip non-final releases if the current release is88 # a final one89 continue90 # trunk the version tuple to the first `level` elements91 trunked_current = (92 parsed_version.base_version.split('.')[:level])93 trunked_candidate = (94 dist.parsed_version.base_version.split('.')[:level])95 while len(trunked_candidate) < level:96 trunked_candidate.append('00000000')97 while len(trunked_current) < level:98 trunked_current.append('00000000')99 # ok now we can compare: -> skip if we're still higher.100 if trunked_candidate > trunked_current:...

Full Screen

Full Screen

pip.py

Source:pip.py Github

copy

Full Screen

1import os2import logging3import subprocess4from .base import UpdaterDomainBase5class PipDomain(UpdaterDomainBase):6 def __init__(self, **kwargs):7 self._env = kwargs.pop('env')8 self._packages = [x.strip() for x in kwargs.pop('packages').strip().split('\n')]9 super(PipDomain, self).__init__(**kwargs)10 for package in self.packages:11 self._register_package_name(package)12 @property13 def env(self):14 return self._env15 @property16 def packages(self):17 return self._packages18 @property19 def pip_path(self):20 if self.env:21 return os.path.join(self.env, 'bin', 'pip')22 else:23 return 'pip'24 def _execute(self, args):25 cmd = [self.pip_path]26 cmd.extend(args)27 result = subprocess.run(cmd, capture_output=True)28 return result.stdout29 def _get_package_information(self, package):30 result = self._execute(['show', package])31 lines = result.splitlines()32 rv = {}33 for line in lines:34 key, value = line.decode().split(':', 1)35 rv[key.strip()] = value.strip()36 return rv37 def _get_current_version(self, package):38 return self._get_package_information(package)['Version']39 def _get_target_version(self, package):40 return getattr(self._config, package).get('version', 'latest')41 def _update_package(self, package):42 _exclusions = ()43 if package in _exclusions:44 logging.info("Skipping '{}' package '{}' for update check."45 "".format(self._name, package))46 return47 logging.debug("Checking '{}' package '{}' for updates"48 "".format(self._name, package))49 _starting_version = self._get_current_version(package)50 logging.debug("Current version for '{}' : {}"51 "".format(package, _starting_version))52 logging.debug("Target version for '{}' : {}"53 "".format(package, self._get_target_version(package)))54 if self._get_target_version(package) == 'latest':55 self._execute(['install', '--upgrade', package])56 _final_version = self._get_current_version(package)57 logging.info("'{}' : {}".format(package, _final_version))58 if _final_version != _starting_version:59 logging.info("Upgraded package '{}' from '{}' to '{}'"60 "".format(package, _starting_version, _final_version))61 def _update(self):62 for package in self._packages:63 self._update_package(package)64def install(manager):...

Full Screen

Full Screen

test_installer_unit.py

Source:test_installer_unit.py Github

copy

Full Screen

1import pytest2import pkg_resources3from zc.buildout.easy_install import _final_version4from pkglib.setuptools.buildout import Installer5pytest_plugins = ['pkglib_testing.pytest']6class Dist(object):7 def __init__(self, version, identifier=None):8 self.version = version9 self.identifier = identifier # used to differentiate dists with the10 # same version11 self.parsed_version = pkg_resources.parse_version(version)12 def __repr__(self):13 if self.identifier:14 return self.version + "-" + self.identifier15 return self.version16@pytest.mark.parametrize(("d1", "d2", "prefer_final", "expected"), [17 (Dist("2.0.dev1"), Dist("1.0.dev1"), True, "2.0.dev1"),18 (Dist("2.0.dev1"), Dist("1.0.dev1"), False, "2.0.dev1"),19 (Dist("2.0.dev1"), Dist("1.0"), True, "1.0"),20 (Dist("2.0.dev1"), Dist("1.0"), False, "2.0.dev1"),21 (Dist("2.0"), Dist("1.0.dev1"), True, "2.0"),22 (Dist("2.0"), Dist("1.0.dev1"), False, "1.0.dev1"),23 (Dist("2.0"), Dist("1.0"), True, "2.0"),24 (Dist("2.0"), Dist("1.0"), False, "2.0"),25])26def test_choose_between_different_versions(d1, d2, prefer_final, expected):27 """ Tests choosing between two different versions of a28 package in the installer29 """30 installer = Installer()31 if prefer_final:32 comparitor = _final_version33 else:34 comparitor = installer.is_dev_version35 choice = installer.choose_between(d1, d2, comparitor)36 assert repr(choice) == expected37 # Ordering shouldn't matter38 choice = installer.choose_between(d2, d1, comparitor)39 assert repr(choice) == expected40@pytest.mark.parametrize(("d1", "d2", "prefer_final", "expected"), [41 (Dist("2.0.dev1", 'a'), Dist("2.0.dev1", 'b'), True, "2.0.dev1-a"),42 (Dist("2.0.dev1", 'a'), Dist("2.0.dev1", 'b'), False, "2.0.dev1-a"),43 (Dist("2.0", 'a'), Dist("2.0", 'b'), True, "2.0-a"),44 (Dist("2.0", 'a'), Dist("2.0", 'b'), False, "2.0-a"),45])46def test_choose_between_same_versions(d1, d2, prefer_final, expected):47 """ Tests choosing between two distributions with the same48 version in the installer.49 """50 installer = Installer()51 if prefer_final:52 comparitor = _final_version53 else:54 comparitor = installer.is_dev_version55 # Ordering is important here - it should choose the first one56 choice = installer.choose_between(d1, d2, comparitor)...

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 robotframework-androidlibrary 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