Best Python code snippet using lemoncheesecake
test_fixtures.py
Source:test_fixtures.py  
...12    assert myfixture._lccfixtureinfo.scope == "test"13def test_fixture_decorator_invalid_scope():14    with pytest.raises(ValueError, match=r"Invalid fixture scope"):15        @lcc.fixture(scope="not_a_valid_scope")16        def myfixt():17            pass18def test_fixture_decorator_invalid_per_thread():19    with pytest.raises(AssertionError, match=r"can only be per_thread"):20        @lcc.fixture(scope="test", per_thread=True)21        def myfixt():22            pass23def test_load_from_func():24    @lcc.fixture()25    def myfixture():26        pass27    fixtures = load_fixtures_from_func(myfixture)28    assert len(fixtures) == 129    assert fixtures[0].name == "myfixture"30    assert fixtures[0].scope == "test"31    assert len(fixtures[0].params) == 032def test_load_from_func_with_multiple_fixture_names():33    @lcc.fixture(names=["foo", "bar"])34    def myfixture():35        pass...CSV_Reader.py
Source:CSV_Reader.py  
1# -*- coding: utf-8 -*-2"""CSV Reader3Contains Functions:4---ReadCSV(configLoc,myPart,myFixt,config)5---	Returns the provided config dictionary instance, filled with the parsed CSV data6"""7	8import gom9import DictBuilder10from collections import defaultdict11import csv 12def ReadCSV(configLoc,myPart,myFixt,config):13	"""Read CSV14	15	Keyword arguments:16	configLoc -- File location of the Config .CSV17	myPart -- string: 4 Digit Part #18	myFixt -- string: 3 Character Fixture ID19	config -- Object: instance of the config dictionary class20	21	Returns the provided config dictionary instance, filled with the parsed CSV data22	"""23	found = False24	25	with open(configLoc,'r') as csvfile:26		reader = csv.reader(csvfile,delimiter=',')27		for row in reader:28			if myPart in row[1] and myFixt in row[0]:                      29				found = True30				_fixturePoints = row[13].split(',')31				fixturePoints = []32				for f in _fixturePoints:33					fixturePoints.append(int(f))34				_numParts = row[3].split(',')	35				numParts = []36				for np in _numParts:37					numParts.append(np)38				_iTemplate = row[7].split(',')39				inspectionTemplate = []40				for it in _iTemplate:41					inspectionTemplate.append(row[6]+it)42				_xOffset = row[14].split(',')43				xOffset = []44				for x in _xOffset:45					xOffset.append(int(x))46				_yOffset = row[15].split(',')47				yOffset = []48				for y in _yOffset:49					yOffset.append(int(y))50				_zOffset = row[16].split(',')51				zOffset = []52				for z in _zOffset:53					zOffset.append(int(z))54				_zRotArray = row[17].split(',')55				zRotArray = []56				for zr in _zRotArray:57					zRotArray.append(int(zr))			58				lComp = int(row[18])59				wComp = int(row[19])60				hComp = int(row[20])61				directory = row[2]62				meshArea = int(row[21])63				_winSPCname = row[8].split(',')64				winSPCname = []65				partNR = []66				for name in _winSPCname:67					winSPCname.append(name)68					partNR.append(name[0:13])69				key_Location = row[5]70				_key_Material = row[9].split(',')71				key_Material = []72				for km in _key_Material:73					key_Material.append(km)74				_key_Print = row[10].split(',')75				key_Print = []76				for kp in _key_Print:77					key_Print.append(kp)78				_key_PartName = row[11].split(',')79				key_PartName = []80				for kpn in _key_PartName:81					key_PartName.append(kpn)82				key_System = str(row[12])83				_nestID = row[4].split(',')84				nestID = []85				for n in _nestID:86					splitter = n.split(';')87					nestID.append(splitter)88				nestID = [list(map(int, x)) for x in nestID]89				_manualDialogTitleArray = row[22].split(',')90				manualDialogTitleArray = []91				for title in _manualDialogTitleArray:92					manualDialogTitleArray.append(title)93				_manualDialogTextArray = row[23].split(',')94				manualDialogTextArray = []95				for text in _manualDialogTextArray:96					manualDialogTextArray.append(text)97				_manualDialogTypeArray = row[24].split(',')98				manualDialogTypeArray = []99				for type in _manualDialogTypeArray:100					manualDialogTypeArray.append(type)101				102		if found == False:103			print('$$$ DEBUG : CANNOT LOCATE TEMPLATE FOR VMR: '+myPart+myFixt)104			NOTMP=gom.script.sys.execute_user_defined_dialog (content='<dialog>' \105				' <title>Message</title>' \106				' <style></style>' \107				' <control id="OkCancel"/>' \108				' <position>automatic</position>' \109				' <embedding>always_toplevel</embedding>' \110				' <sizemode>automatic</sizemode>' \111				' <size height="184" width="322"/>' \112				' <content rows="2" columns="2">' \113				'  <widget row="0" column="0" columnspan="2" type="display::text" rowspan="1">' \114				'   <name>text</name>' \115				'   <tooltip></tooltip>' \116				'   <text><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">' \117				'<html><head><meta name="qrichtext" content="1" /><style type="text/css">' \118				'p, li { white-space: pre-wrap; }' \119				'</style></head><body style="    ">' \120				'<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">ERROR: NO CONFIGURATION TEMPLATE FOUND</span></p></body></html></text>' \121				'   <wordwrap>false</wordwrap>' \122				'  </widget>' \123				'  <widget row="1" column="0" columnspan="1" type="label" rowspan="1">' \124				'   <name>label</name>' \125				'   <tooltip></tooltip>' \126				'   <text>'+myPart+'</text>' \127				'   <word_wrap>false</word_wrap>' \128				'  </widget>' \129				'  <widget row="1" column="1" columnspan="1" type="label" rowspan="1">' \130				'   <name>label_1</name>' \131				'   <tooltip></tooltip>' \132				'   <text>'+myFixt+'</text>' \133				'   <word_wrap>false</word_wrap>' \134				'  </widget>' \135				' </content>' \136				'</dialog>')	137		138	globalArrayLists = [fixturePoints, numParts, inspectionTemplate, xOffset, yOffset, zOffset, zRotArray, winSPCname, key_Material, key_Print, key_PartName, nestID, partNR, manualDialogTitleArray, manualDialogTextArray, manualDialogTypeArray]139	globalArrayKeys = ['fixturePoints', 'numParts', 'inspectionTemplate', 'xOffset', 'yOffset', 'zOffset', 'zRotArray', 'winSPCname', 'key_Material', 'key_Print', 'key_PartName', 'nestID', 'partNR', 'manualDialogTitleArray', 'manualDialogTextArray', 'manualDialogTypeArray']140	141	arrayPosition = 0142	if len(globalArrayKeys) == len(globalArrayLists):143		for array in globalArrayLists:144			#print('Array Start: ',array)145			146			for item in array:147				#print('Subitem: ',item)148				#print('Array: ',array)149				config.add([(globalArrayKeys[arrayPosition],item)])150				151			#print (arrayPosition)152			arrayPosition+=1153	else:154		print('ERROR: Mismatch in Keys & Lists')155	globalVariableList = [lComp, wComp, hComp, directory, meshArea,key_Location, key_System]156	globalVariableKeys = ['lComp', 'wComp', 'hComp', 'directory', 'meshArea', 'key_Location', 'key_System']157	158	arrayPosition = 0159	if len(globalVariableKeys) == len(globalVariableList):160		for var in globalVariableList:161			#print('Var Start: ',var)162			config.add([(globalVariableKeys[arrayPosition],var)])163			arrayPosition+=1164		165	else:166		print('ERROR: Mismatch in Keys & Lists')167		168	return config169	...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!!
