Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import re
- import xml.etree.ElementTree as ET
- ''' Script that parses the html page of a Requirement Based report and returns a list of reqs not in the test plan '''
- allreqs = open(sys.argv[1]) # Export xml of all requirements in TestLink
- reqreport = open(sys.argv[2]) # html source of Requirement based report for ASIC testplan
- class Requirement:
- reqtag = ""
- reqtitle = ""
- def __init__(self, tag, title):
- self.reqtag = tag
- self.reqtitle = title
- tl_reqlist = []
- all_reqlist = []
- counter = 0
- print "####### ASIC Test Plan Requirements #######"
- for line in reqreport:
- match = re.findall("(?:Requirement)[^!]*a>\s([^!]*)", line)
- if match is not None:
- for p in match:
- counter = counter + 1
- req = p.rstrip('","<').split(":")
- print str(counter) + ". " + p.rstrip('","<')
- plan_req = Requirement(req[0].rstrip(), p.rstrip('","<'))
- tl_reqlist.append(plan_req)
- reqreport.close()
- print "####### All Requirements #######"
- tree = ET.parse(allreqs)
- root = tree.getroot()
- count2 = 0
- for child in root:
- if child.tag == "req_spec":
- for subchild in child.findall('requirement'):
- #print "ding"
- if subchild.find('status').text != "O" and subchild.find('status').text != "N":
- count2 = count2 + 1
- req = subchild.find('docid').text# + " : " + subchild.find('title').text
- print str(count2) + ". " + subchild.find('docid').text + " : " + subchild.find('title').text
- all_req = Requirement(req, subchild.find('title').text)
- all_reqlist.append(all_req)
- tl_reqlist.sort()
- all_reqlist.sort()
- rest = [elem for elem in all_reqlist if elem not in tl_reqlist ]
- rest = list(all_reqlist)
- for req in all_reqlist:
- for tp_req in tl_reqlist:
- if req.reqtag == tp_req.reqtag:
- rest.remove(req)
- rest.sort()
- print "####### Delta Requirements (not in the test plan) #######"
- restcounter = 0
- for item in rest:
- restcounter = restcounter + 1
- print str(restcounter) + ". " + item.reqtag + " : " + item.reqtitle
- print "Total # of reqs is " + str(count2) +" where "+ str(counter) + " are in the Test Plan and "+ str(restcounter) + " are not"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement