-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoverage.py
More file actions
39 lines (33 loc) · 1.04 KB
/
Copy pathCoverage.py
File metadata and controls
39 lines (33 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from bs4 import BeautifulSoup
list_green = []
list_red = []
soup = BeautifulSoup(open('OemUI.html', 'rb+'), features='html.parser', )
# print(soup.span)
# for result in soup.children:
# print(result)
# print(soup.find_all("span", style="background-color:#fdd"))
# 所有绿色的行
green = soup.find_all("span", style="background-color:#dfd")
# 所有红色的行
red = soup.find_all("span", style="background-color:#fdd")
#
greenLen = len(green) #
redLen = len(red) # 红行的行数
dfdCount = 0 # 列表中包含dfd的元素个数
fddCount = 0 # 红行中包含fdd的元素个数
for i in range(greenLen):
dfdNum = str(green[i]).count('\n')
dfdNum += 1
dfdCount += dfdNum
for i in range(redLen):
fddNum = str(red[i]).count('\n')
fddNum += 1
fddCount += fddNum
# 覆盖率
coverage = dfdCount/(dfdCount + fddCount)
coverage = format(coverage, '.2f')
coverage = float(coverage) * 100
print('green line = ' + str(dfdCount))
print('red line = ' + str(fddCount))
print('Coverage = %d%%' % coverage)
# print(type(list[1]))