How to use floatstr method in autotest

Best Python code snippet using autotest_python

parser_state.py

Source:parser_state.py Github

copy

Full Screen

1from enum import IntEnum, unique2from typing import List, Set, Tuple, Union, Optional3import bpy4import arm5from arm.material.shader import Shader, ShaderContext, vec3str, floatstr6if arm.is_reload(__name__):7 arm.material.shader = arm.reload_module(arm.material.shader)8 from arm.material.shader import Shader, ShaderContext, vec3str, floatstr9else:10 arm.enable_reload(__name__)11 @unique12 class ParserContext(IntEnum):13 """Describes which kind of node tree is parsed."""14 OBJECT = 015 # Texture node trees are not supported yet16 # TEXTURE = 117 WORLD = 218class ParserState:19 """Dataclass to keep track of the current state while parsing a shader tree."""20 def __init__(self, context: ParserContext, world: Optional[bpy.types.World] = None):21 self.context = context22 # The current world, if parsing a world node tree23 self.world = world24 # Active shader - frag for surface / tese for displacement25 self.curshader: Shader = None26 self.con: ShaderContext = None27 self.vert: Shader = None28 self.frag: Shader = None29 self.geom: Shader = None30 self.tesc: Shader = None31 self.tese: Shader = None32 # Group stack (last in the list = innermost group)33 self.parents: List[bpy.types.Node] = []34 # Cache for computing nodes only once35 self.parsed: Set[str] = set()36 # What to parse from the node tree37 self.parse_surface = True38 self.parse_opacity = True39 self.parse_displacement = True40 self.basecol_only = False41 self.emission_found = False42 self.procedurals_written = False43 # Already exported radiance/irradiance (currently we can only convert44 # an already existing texture as radiance/irradiance)45 self.radiance_written = False46 # TODO: document those attributes47 self.sample_bump = False48 self.sample_bump_res = ''49 self.normal_parsed = False50 # Shader output values51 self.out_basecol: vec3str = 'vec3(0.8)'52 self.out_roughness: floatstr = '0.0'53 self.out_metallic: floatstr = '0.0'54 self.out_occlusion: floatstr = '1.0'55 self.out_specular: floatstr = '1.0'56 self.out_opacity: floatstr = '1.0'57 self.out_emission: floatstr = '0.0'58 def reset_outs(self):59 """Reset the shader output values to their default values."""60 self.out_basecol = 'vec3(0.8)'61 self.out_roughness = '0.0'62 self.out_metallic = '0.0'63 self.out_occlusion = '1.0'64 self.out_specular = '1.0'65 self.out_opacity = '1.0'66 self.out_emission = '0.0'67 def get_outs(self) -> Tuple[vec3str, floatstr, floatstr, floatstr, floatstr, floatstr, floatstr]:68 """Return the shader output values as a tuple."""69 return (self.out_basecol, self.out_roughness, self.out_metallic, self.out_occlusion, self.out_specular,...

Full Screen

Full Screen

test_all1.py

Source:test_all1.py Github

copy

Full Screen

1#!/usr/bin/env python2#coding=utf-83import allure4import yaml5import pytest6from python.calculator import Calculator7def get_adds(path,intstr,floatstr):8 with open(path, 'r') as f:9 data = yaml.safe_load(f)10 # print(f'data={data}')11 add_int = data['datas'][intstr]12 add_float=data['datas'][floatstr]13 add_int_ids=data['ids']['add_int_ids']14 add_float_ids=data['ids']['add_float_ids']15 # print(add_datas)16 return [add_int,add_float,add_int_ids,add_float_ids]17path='../datas/cal.yml'18@allure.feature("加法测试")19class TestAdd:20 intstr = 'add_int'21 floatstr = 'add_float'22 @pytest.mark.parametrize('a,b,expect',get_adds(path,intstr,floatstr)[0],ids=get_adds(path,intstr,floatstr)[2])23 def test_add_int(self,a,b,expect,start_end):24 result=start_end.add(a,b)25 assert result==expect26 @pytest.mark.parametrize('a,b,expect', get_adds(path,intstr,floatstr)[1],ids=get_adds(path,intstr,floatstr)[3])27 def test_add_float(self, a, b, expect,start_end):28 result = start_end.add(a, b)29 assert result == expect30@allure.feature("乘法测试")31class TestMul:32 intstr = 'mul_int'33 floatstr = 'mul_float'34 @pytest.mark.parametrize('a,b,expect',get_adds(path,intstr,floatstr)[0])35 def test_mul_int(self,a,b,expect,start_end):36 result = start_end.mul(a,b)37 assert result == expect38 @pytest.mark.parametrize('a,b,expect', get_adds(path, intstr, floatstr)[1])39 def test_mul_float(self, a, b, expect, start_end):40 result = start_end.mul(a, b)41 assert result == expect42@allure.feature("减法测试")43class TestSub:44 intstr = 'sub_int'45 floatstr = 'sub_float'46 @pytest.mark.parametrize('a,b,expect', get_adds(path, intstr, floatstr)[0])47 def test_sub_int(self,a,b,expect, start_end):48 result = start_end.sub(a,b)49 assert round(result,2)==expect50 @pytest.mark.parametrize('a,b,expect', get_adds(path, intstr, floatstr)[1])51 def test_sub_float(self,a,b,expect, start_end):52 result = start_end.sub(a,b)53 assert round(result,2)==expect54@allure.feature("除法测试")55class TestDiv:56 intstr = 'div_int'57 floatstr = 'div_float'58 @pytest.mark.parametrize('a,b,expect', get_adds(path, intstr, floatstr)[0])59 def test_div_int(self, a, b, expect,start_end):60 result = start_end.div(a, b)61 assert round(result,2) == expect62 @pytest.mark.parametrize('a,b,expect', get_adds(path, intstr, floatstr)[1])63 def test_div_float(self, a, b, expect,start_end):64 result = start_end.div(a, b)65 assert round(result,2) == expect66 @pytest.mark.parametrize('a,b,expect',[[1,0,1],[-1,0,-1]])67 def test_div_except(self,a, b, expect,start_end):68 with pytest.raises(ZeroDivisionError):...

Full Screen

Full Screen

encode.py

Source:encode.py Github

copy

Full Screen

1import base64 2def encode(b64_string):3 try:4 return base64.b64decode(b64_string).decode('ascii')5 except Exception as e:6 # print(e)7 b64_string += "=" * ((4 - len(b64_string) % 4) % 4)8 return base64.b64decode(b64_string).decode('ascii')9def floatStr(s):10 try:11 return float(s)12 except:13 return 014def encodeQuery(data):15 res = {}16 res['version'] = encode(data[0])17 res['uptime'] = floatStr(encode(data[1]))18 res['sessions'] = encode(data[2])19 res['processes'] = encode(data[3])20 res['processes_array'] = encode(data[4])21 res['file_handles'] = encode(data[5])22 res['file_handles_limit'] = encode(data[6])23 res['os_kernel'] = encode(data[7])24 res['os_name'] = encode(data[8])25 res['os_arch'] = encode(data[9])26 res['cpu_name'] = encode(data[10])27 res['cpu_cores'] = encode(data[11])28 res['cpu_freq'] = encode(data[12])29 res['ram_total'] = floatStr(encode(data[13]))30 res['ram_usage'] = floatStr(encode(data[14]))31 res['swap_total'] = floatStr(encode(data[15]))32 res['swap_usage'] = floatStr(encode(data[16]))33 res['disk_array'] = encode(data[17])34 res['disk_total'] = floatStr(encode(data[18]))35 res['disk_usage'] = floatStr(encode(data[19]))36 res['connections'] = encode(data[20])37 res['nic'] = encode(data[21])38 res['ipv_4'] = encode(data[22])39 res['ipv_6'] = encode(data[23])40 res['rx'] = floatStr(encode(data[24]))41 res['tx'] = floatStr(encode(data[25]))42 res['rx_gap'] = floatStr(encode(data[26]))43 res['tx_gap'] = floatStr(encode(data[27]))44 res['loads'] = encode(data[28])45 res['load_system'] = round(floatStr(res['loads'].split(" ")[1])*100, 2)46 res['load_cpu'] = floatStr(encode(data[29]))47 res['load_io'] = floatStr(encode(data[30]))48 res['ping_eu'] = floatStr(encode(data[31]))49 res['ping_us'] = floatStr(encode(data[32]))50 res['ping_as'] = floatStr(encode(data[33]))...

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