Best Python code snippet using tox_python
test_cfgobj.py
Source:test_cfgobj.py
1"""This was pytools/utils/cfgobj in pandokia."""2import io as StringIO3import os4import pprint5from .. import teal, vtor_checks6def test_teal_vtor(tmpdir):7 data_dir = os.path.dirname(__file__)8 co = teal.load(os.path.join(data_dir, 'rt_sample.cfg'))9 f = tmpdir.join('output.txt')10 # TEST OBJ LOADING11 f.write("THE CONFIG-OBJ:\n")12 pprint.pprint(co.dict(), stream=f, indent=3, width=999)13 # TEST UNDERSTANDING OF .cfgspc14 cs = co.configspec15 f.write("\nTHE CONFIG-SPEC:\n")16 pprint.pprint(cs.dict(), stream=f, indent=3, width=999)17 # TEST sigStrToKwArgsDict18 f.write("\nsigStrToKwArgsDict:\n")19 for item in sorted(cs.keys()):20 sig = cs[item]21 if isinstance(sig, str):22 f.write("SIGN: " + sig + "\n")23 ddd = vtor_checks.sigStrToKwArgsDict(sig)24 sss = StringIO.StringIO()25 # use pprint (and StringIO) so as to print it sorted26 pprint.pprint(ddd, sss, width=999)27 f.write("DICT: " + sss.getvalue()) # sss has newline28 sss.close()29 # TEST getPosArgs and getKwdArgs30 f.write("\nTHE POS ARGS:\n")31 f.write(str(co.getPosArgs()) + "\n")32 f.write("\nTHE KWD ARGS:\n")33 pprint.pprint(co.getKwdArgs(), stream=f, indent=3, width=999)34 lines = f.readlines()35 stripped = [l.replace(' ', ' ').replace(' ', ' ').replace('{ ', '{').replace(' }', '}').strip() for l in lines]36 lines = [l for l in stripped if len(l) > 0]37 with open(os.path.join(data_dir, 'cfgobj_output.ref')) as fref:38 ans = fref.readlines()39 bad_lines = []40 for x, y in zip(lines, ans):41 if x != y:42 bad_lines.append('{} : {}'.format(x, y))43 if len(bad_lines) > 0:...
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!!