def test_in_out_leiauteNFe(): path = 'tests/nfe/v4_00/leiauteNFe' for filename in os.listdir(path): # primeiro filtramos a root tag e a possivel assinatura: subtree = nfe_sub.parsexml_('%s/%s' % (path, filename,)) inputfile = 'tests/input.xml' subtree.write(inputfile, encoding='utf-8') # agora vamos importar o XML da nota e transforma-lo em objeto Python: obj = nfe_sub.parse(inputfile)#'%s/%s' % (path, filename,)) # agora podemos trabalhar em cima do objeto e fazer operaçoes como: obj.infNFe.emit.CNPJ outputfile = 'tests/output.xml' with open(outputfile, 'w') as f: nfe_sub.export(obj, nfeProc=False, stream=f) diff = main.diff_files(inputfile, outputfile) print(diff) assert len(diff) == 0
def test_in_out(): path = 'tests/nfe/v4_00' for filename in os.listdir(path): subtree = parser.parsexml_('%s/%s' % ( path, filename, )) inputfile = 'tests/input.xml' subtree.write(inputfile, encoding='utf-8') # agora vamos importar o XML da nota e transforma-lo em objeto Python: nota = parser.parse(inputfile) #'%s/%s' % (path, filename,)) # agora podemos trabalhar em cima do objeto e fazer operaçoes como: nota.infNFe.emit.CNPJ filename = 'tests/output.xml' with open(filename, 'w') as f: parser.export(nota, nfeProc=False, stream=f) diff = main.diff_files('tests/input.xml', 'tests/output.xml') print(diff) assert len(diff) == 0