瀏覽代碼

[Pytest] Generate HTML report for test results and disable warnings (#3874)

Ayush Goyal 1 年之前
父節點
當前提交
7b542177b6
共有 4 個文件被更改,包括 12 次插入3 次删除
  1. 8 1
      .github/workflows/commitflow-py3.yml
  2. 1 1
      .gitignore
  3. 1 0
      desktop/core/base_requirements.txt
  4. 2 1
      pyproject.toml

+ 8 - 1
.github/workflows/commitflow-py3.yml

@@ -61,7 +61,14 @@ jobs:
 
     - name: run tests
       run: |
-        PYTHONWARNINGS=always ./build/env/bin/pytest
+        mkdir -p test-reports  # Ensure the directory exists
+        PYTHONWARNINGS=always ./build/env/bin/pytest --html=test-reports/report_${{ matrix.python-version }}.html --self-contained-html
+ 
+    - name: upload pytest report
+      uses: actions/upload-artifact@v4
+      with:
+        name: test-reports-${{ matrix.python-version }}
+        path: test-reports
 
     - name: run python lints
       run: |

+ 1 - 1
.gitignore

@@ -98,7 +98,7 @@ desktop/desktop-test.db
 ext/hadoop/
 ext/hive/
 ext/oozie/
-nosetests.xml
+report.html
 oozie.sql
 tools/jenkins/ext/
 tools/jenkins/oozie.sql

+ 1 - 0
desktop/core/base_requirements.txt

@@ -48,6 +48,7 @@ py==1.11.0
 pyformance==0.3.2
 pytest==8.1.1
 pytest-django==4.8.0
+pytest-html==4.1.1
 python-dateutil==2.8.2
 python-daemon==2.2.4
 python-ldap==3.4.3

+ 2 - 1
pyproject.toml

@@ -1,6 +1,7 @@
 [tool.pytest.ini_options]
 DJANGO_SETTINGS_MODULE = "desktop.settings"
-addopts = "-v -m 'not integration' --strict-markers --durations=10"
+console_output_style = "count"
+addopts = "-v -m 'not integration' --strict-markers --disable-warnings --html=report.html --self-contained-html"
 norecursedirs = "desktop/core/ext-py3"
 python_files = "tests.py test_*.py *_tests.py tests_* *_test.py"
 markers = [