How to use find_version method in elementium

Best Python code snippet using elementium_python

descriptor_.py

Source:descriptor_.py Github

copy

Full Screen

...105 @classmethod106 def get_version(cls):107 return cls.version108 @staticmethod109 def find_version():110 return PythonSite.version111# 类方法 @classmethod装饰器112# 类方法使用@classmethod 装饰器定义,113# 经过该装饰器的方法是一个描述器114# 类和实例都可以调用类方法115ps = PythonSite('ghost')116print ps.get_version117# <bound method type.get_version of <class '__main__.PythonSite'>>118print ps.get_version()119# 0.01120print PythonSite.get_version121# <bound method type.get_version of <class '__main__.PythonSite'>>122print PythonSite.get_version()123# 0.01124# get_version 是一个bound 方法。125# ps.get_version 这个调用会先查找它的__dict__ 是否有get_version 这个属性126# 如果没有,则查找它的类127print vars(ps)128# {'site': 'ghost'}129print type(ps).__dict__['get_version']130# <classmethod object at 0x101c3cc58>131print type(ps).__dict__['get_version'].__get__(ps, type(ps))132# <bound method type.get_version of <class '__main__.PythonSite'>>133print type(ps).__dict__['get_version'].__get__(ps, type(ps)) == ps.get_version134# True # !!!135# 并且vars(ps)中,__dict__并没有get_version这个属性,136# 依据描述器协议,将会调用type(ps).__dict__['get_version']描述器的__get__方法,137# 因为ps是实例,因此object.__getattribute__()会这样调用__get__(obj, type(obj))。138print PythonSite.__dict__['get_version']139# <classmethod object at 0x1094e2c58>140print PythonSite.__dict__['get_version'].__get__(None, PythonSite)141# <bound method type.get_version of <class '__main__.PythonSite'>>142print PythonSite.__dict__['get_version'].__get__(None, PythonSite) == PythonSite.get_version143# True144# 静态方法 @staticmethod145# 实例和类也可以调用静态方法146print ps.find_version147# <function find_version at 0x1021979b0>148print ps.find_version()149# 0.01150print vars(ps)151# {'site': 'ghost'}152print type(ps).__dict__['find_version']153# <staticmethod object at 0x102199cc8>154print type(ps).__dict__['find_version'].__get__(ps, type(ps))155# <function find_version at 0x108cbf9b0>156print type(ps).__dict__['find_version'].__get__(ps, type(ps)) == ps.find_version157# True158print PythonSite.find_version()159# 0.01160print PythonSite.find_version161# <function find_version at 0x108cbf9b0>162print type(ps).__dict__['find_version'].__get__(None, type(ps))163# <function find_version at 0x108cbf9b0>164print type(ps).__dict__['find_version'].__get__(None, type(ps)) == PythonSite.find_version165# True166# 实例方法167print ps.get_site168# <bound method PythonSite.get_site of <__main__.PythonSite object at 0x1089784d0>>169print ps.get_site()170# ghost171print type(ps).__dict__['get_site']172# <function get_site at 0x10896f8c0>...

Full Screen

Full Screen

os-x-minimum-system-version

Source:os-x-minimum-system-version Github

copy

Full Screen

1#!/usr/bin/env python2import sys3import subprocess4def find_version(version, should_generalize=True):5 """Returns a normalized OS X version string.6 7 >>> find_version("10.8")8 '10.8.0'9 >>> find_version("10.8.2")10 '10.8.0'11 >>> find_version("10.3.9", False)12 '10.3.9'13 """14 parts = version.split(".")15 major = parts[0]16 minor = parts[1]17 bug = "0"18 if not should_generalize and len(parts) == 3:19 bug = parts[2]20 return ".".join([major, minor, bug])21if __name__ == '__main__':22 if len(sys.argv) == 2:23 print find_version(sys.argv[1], False)24 else:...

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