Best Python code snippet using tox_python
python_info.py
Source:python_info.py
...27 return 'python{}+{}{}+{}'.format('%d.%d' % _get_python_version()[:2],28 _get_python_impl_name(),29 '%d.%d' % _get_python_impl_version()[:2],30 _get_python_impl_target_platform())31def get_python_info():32 return {33 'python': {34 'version': _get_python_version(),35 'implementation': {36 'name': _get_python_impl_name(),37 'version': _get_python_impl_version(),38 'platform': _get_python_impl_target_platform()39 },40 'package_namespace': _get_python_package_namespace()41 }42 }43if __name__ == '__main__':...
test_py.py
Source:test_py.py
...11 assert PythonImplement.CPYTHON != None12 assert str(PythonImplement.CPYTHON) == 'CPython'13 assert repr(PythonImplement.CPYTHON) == '<PythonImplement CPython>'14 def test_python_info_actual(self):15 python = Python(get_python_info())16 assert python.version == platform.python_version()17 assert python.version == python.version18 assert python.version != 219 assert python.version != None20 assert python.implement == platform.python_implementation()21 assert python.implement == python.implement22 assert python.implement != 223 assert python.implement != None24 assert isinstance(python.pip, Pip)25 def test_cpython_3_7_12(self, cpython_3_7_12):26 python = Python(get_python_info())27 assert python.version == '3.7.12'28 assert python.implement == 'cpython'29 assert str(python) == 'CPython 3.7.12'30 assert repr(python) == '<Python, version: 3.7.12, implement: CPython>'31 def test_pypy_3_9_2(self, pypy_3_9_2):32 python = Python(get_python_info())33 assert python.version == '3.9.2'34 assert python.implement == 'pypy'35 assert str(python) == 'PyPy 3.9.2'...
env_info.py
Source:env_info.py
...18 'name': str(os.name),19 'system': str(platform.system()),20 'release': str(platform.release())21 }22def get_python_info():23 dists = [str(d).replace(" ","==") for d in pkg_resources.working_set]24 return {25 'version': sys.version,26 'packages': dists27 }28def is_connected(hostname):29 try:30 # see if we can resolve the host name -- tells us if there is31 # a DNS listening32 host = socket.gethostbyname(hostname)33 # connect to the host -- tells us if the host is actually34 # reachable35 s = socket.create_connection((host, 80), 2)36 s.close()37 return True38 except:39 pass40 return False41def main():42 # Generate resulting json in specific order.43 environment_data = OrderedDict()44 environment_data['os_info'] = get_os_version()45 environment_data['python_info'] = get_python_info()46 environment_data['is_pypi_reachable'] = is_connected(REMOTE_SERVER)47 print(json.dumps(environment_data, indent=2))48 49if __name__ == '__main__':...
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!!