How to use parsexml_ method in autotest

Best Python code snippet using autotest_python

requestsetrelaystate_sub.py

Source:requestsetrelaystate_sub.py Github

copy

Full Screen

...17# becos.Oneiroi.Client_Python18#19import sys20from lxml import etree as etree_21def parsexml_(infile, parser=None, **kwargs):22 if parser is None:23 # Use the lxml ElementTree compatible parser so that, e.g.,24 # we ignore comments.25 parser = etree_.ETCompatXMLParser()26 doc = etree_.parse(infile, parser=parser, **kwargs)27 return doc28#29# Globals30#31ExternalEncoding = 'utf-8'32#33# Data representation classes34#35class requestsetrelaystateSub(supermod.requestsetrelaystate):36 def __init__(self, name=None, sendFrom=None, sendTo=None, sourceClient=None, hide=None, targetClient=None, newrelaystate=None):37 super(requestsetrelaystateSub, self).__init__(name, sendFrom, sendTo, sourceClient, hide, targetClient, newrelaystate, )38supermod.requestsetrelaystate.subclass = requestsetrelaystateSub39# end class requestsetrelaystateSub40def get_root_tag(node):41 tag = supermod.Tag_pattern_.match(node.tag).groups()[-1]42 rootClass = None43 rootClass = supermod.GDSClassesMapping.get(tag)44 if rootClass is None and hasattr(supermod, tag):45 rootClass = getattr(supermod, tag)46 return tag, rootClass47def parse(inFilename, silence=False):48 parser = None49 doc = parsexml_(inFilename, parser)50 rootNode = doc.getroot()51 rootTag, rootClass = get_root_tag(rootNode)52 if rootClass is None:53 rootTag = 'requestsetrelaystate'54 rootClass = supermod.requestsetrelaystate55 rootObj = rootClass.factory()56 rootObj.build(rootNode)57 # Enable Python to collect the space used by the DOM.58 doc = None59 if not silence:60 sys.stdout.write('<?xml version="1.0" ?>\n')61 rootObj.export(62 sys.stdout, 0, name_=rootTag,63 namespacedef_='',64 pretty_print=True)65 return rootObj66def parseEtree(inFilename, silence=False):67 parser = None68 doc = parsexml_(inFilename, parser)69 rootNode = doc.getroot()70 rootTag, rootClass = get_root_tag(rootNode)71 if rootClass is None:72 rootTag = 'requestsetrelaystate'73 rootClass = supermod.requestsetrelaystate74 rootObj = rootClass.factory()75 rootObj.build(rootNode)76 # Enable Python to collect the space used by the DOM.77 doc = None78 mapping = {}79 rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping)80 reverse_mapping = rootObj.gds_reverse_node_mapping(mapping)81 if not silence:82 content = etree_.tostring(83 rootElement, pretty_print=True,84 xml_declaration=True, encoding="utf-8")85 sys.stdout.write(content)86 sys.stdout.write('\n')87 return rootObj, rootElement, mapping, reverse_mapping88def parseString(inString, silence=False):89 if sys.version_info.major == 2:90 from StringIO import StringIO91 else:92 from io import BytesIO as StringIO93 parser = None94 doc = parsexml_(StringIO(inString), parser)95 rootNode = doc.getroot()96 rootTag, rootClass = get_root_tag(rootNode)97 if rootClass is None:98 rootTag = 'requestsetrelaystate'99 rootClass = supermod.requestsetrelaystate100 rootObj = rootClass.factory()101 rootObj.build(rootNode)102 # Enable Python to collect the space used by the DOM.103 doc = None104 if not silence:105 sys.stdout.write('<?xml version="1.0" ?>\n')106 rootObj.export(107 sys.stdout, 0, name_=rootTag,108 namespacedef_='')109 return rootObj110def parseLiteral(inFilename, silence=False):111 parser = None112 doc = parsexml_(inFilename, parser)113 rootNode = doc.getroot()114 rootTag, rootClass = get_root_tag(rootNode)115 if rootClass is None:116 rootTag = 'requestsetrelaystate'117 rootClass = supermod.requestsetrelaystate118 rootObj = rootClass.factory()119 rootObj.build(rootNode)120 # Enable Python to collect the space used by the DOM.121 doc = None122 if not silence:123 sys.stdout.write('#from ??? import *\n\n')124 sys.stdout.write('import ??? as model_\n\n')125 sys.stdout.write('rootObj = model_.rootClass(\n')126 rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...22 if rootClass is None and hasattr(supermod, tag):23 rootClass = getattr(supermod, tag)24 return tag, rootClass25def parse(inFileName, silence=False):26 doc = supermod.parsexml_(inFileName)27 rootNode = doc.getroot()28 rootTag, rootClass = get_root_tag(rootNode)29 if rootClass is None:30 rootTag = 'Element'31 rootClass = supermod.Element32 rootObj = rootClass.factory()33 rootObj.build(rootNode)34 # Enable Python to collect the space used by the DOM.35 doc = None36 if not silence:37 sys.stdout.write('<?xml version="1.0" ?>\n')38 rootObj.export(39 sys.stdout, 0, name_=rootTag,40 namespacedef_='',41 pretty_print=True)42 return rootObj43def parseEtree(inFilename, silence=False):44 doc = supermod.parsexml_(inFilename)45 rootNode = doc.getroot()46 rootTag, rootClass = get_root_tag(rootNode)47 if rootClass is None:48 rootTag = 'Element'49 rootClass = supermod.Element50 rootObj = rootClass.factory()51 rootObj.build(rootNode)52 # Enable Python to collect the space used by the DOM.53 doc = None54 mapping = {}55 rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping)56 reverse_mapping = rootObj.gds_reverse_node_mapping(mapping)57 if not silence:58 content = etree_.tostring(59 rootElement, pretty_print=True,60 xml_declaration=True, encoding="utf-8")61 sys.stdout.write(content)62 sys.stdout.write('\n')63 return rootObj, rootElement, mapping, reverse_mapping64def parseString(inString, silence=False):65 from StringIO import StringIO66 doc = supermod.parsexml_(StringIO(inString))67 rootNode = doc.getroot()68 rootTag, rootClass = get_root_tag(rootNode)69 if rootClass is None:70 rootTag = 'Element'71 rootClass = supermod.Element72 rootObj = rootClass.factory()73 rootObj.build(rootNode)74 # Enable Python to collect the space used by the DOM.75 doc = None76 if not silence:77 sys.stdout.write('<?xml version="1.0" ?>\n')78 rootObj.export(79 sys.stdout, 0, name_=rootTag,80 namespacedef_='')81 return rootObj82def parseLiteral(inFilename, silence=False):83 doc = supermod.parsexml_(inFilename)84 rootNode = doc.getroot()85 rootTag, rootClass = get_root_tag(rootNode)86 if rootClass is None:87 rootTag = 'Element'88 rootClass = supermod.Element89 rootObj = rootClass.factory()90 rootObj.build(rootNode)91 # Enable Python to collect the space used by the DOM.92 doc = None93 if not silence:94 sys.stdout.write('#from ??? import *\n\n')95 sys.stdout.write('import ??? as model_\n\n')96 sys.stdout.write('rootObj = model_.rootClass(\n')97 rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)...

Full Screen

Full Screen

test_nfselib_issnet.py

Source:test_nfselib_issnet.py Github

copy

Full Screen

...9from nfselib.issnet.v1_00 import (10 servico_enviar_lote_rps_envio,11 servico_consultar_nfse_rps_envio,12)13def parsexml_(infile, parser=None, keep_signature=False, **kwargs):14 if parser is None:15 # Use the lxml ElementTree compatible parser so that, e.g.,16 # we ignore comments.17 parser = etree_.ETCompatXMLParser()18 doc = etree_.parse(infile, parser=parser, **kwargs)19 root = doc.getroot()20 # remove Signature element before XML comparison21 if not keep_signature:22 for child in root:23 if child.tag in ["{http://www.w3.org/2000/09/xmldsig#}Signature",24 "{http://www.w3.org/2000/09/xmldsig#}\25 ds:Signature"]:26 root.remove(child)27 subtree = etree_.ElementTree(root)28 return subtree29def parse(inFilename, supermod):30 parser = None31 doc = parsexml_(inFilename, parser)32 rootNode = doc.getroot()33 rootTag, rootClass = supermod.get_root_tag(rootNode)34 rootObj = rootClass.factory()35 rootObj.build(rootNode)36 # Enable Python to collect the space used by the DOM.37 doc = None38 return rootObj39def execute_test(path, servico):40 for filename in os.listdir(path):41 subtree = parsexml_('%s/%s' % (path, filename,))42 inputfile = 'input.xml'43 subtree.write(inputfile, encoding='utf-8')44 obj = parse(inputfile, servico)45 outputfile = 'output.xml'46 with open(outputfile, 'w') as f:47 obj.export(f, 0, namespaceprefix_='')48 diff = main.diff_files(inputfile, outputfile)49 print(diff)50 assert len(diff) == 051def test_enviar_lote_rps_envio():52 xml_path = 'tests/nfse/issnet/enviar_lote_rps_envio'53 execute_test(xml_path, servico_enviar_lote_rps_envio)54def test_consultar_nfse_rps_envio():55 xml_path = 'tests/nfse/issnet/consultar_nfse_rps_envio'...

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