get_coverage.py 612 Bytes
Newer Older
drunkpig's avatar
drunkpig committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""
get cov
"""
from bs4 import BeautifulSoup

def get_covrage():
    """get covrage"""
    # 发送请求获取网页内容
    html_content = open("htmlcov/index.html", "r", encoding="utf-8").read()
    soup = BeautifulSoup(html_content, 'html.parser')

    # 查找包含"pc_cov"的span标签
    pc_cov_span = soup.find('span', class_='pc_cov')

    # 提取百分比值
    percentage_value = pc_cov_span.text.strip()
    percentage_float = float(percentage_value.rstrip('%'))
    print ("percentage_float:", percentage_float)
    assert percentage_float >= 0.2

if __name__ == '__main__':
    get_covrage()