get_coverage.py 612 B

12345678910111213141516171819202122
  1. """
  2. get cov
  3. """
  4. from bs4 import BeautifulSoup
  5. def get_covrage():
  6. """get covrage"""
  7. # 发送请求获取网页内容
  8. html_content = open("htmlcov/index.html", "r", encoding="utf-8").read()
  9. soup = BeautifulSoup(html_content, 'html.parser')
  10. # 查找包含"pc_cov"的span标签
  11. pc_cov_span = soup.find('span', class_='pc_cov')
  12. # 提取百分比值
  13. percentage_value = pc_cov_span.text.strip()
  14. percentage_float = float(percentage_value.rstrip('%'))
  15. print ("percentage_float:", percentage_float)
  16. assert percentage_float >= 0.2
  17. if __name__ == '__main__':
  18. get_covrage()