From 05d9749eaddc756d8bffde8e228535fed7d5bbbc Mon Sep 17 00:00:00 2001 From: agl29 Date: Wed, 23 Oct 2024 18:04:52 +0530 Subject: [PATCH] [Pytest] Generate HTML report for test results and disable warnings --- .github/workflows/commitflow-py3.yml | 9 ++++++++- .gitignore | 2 +- desktop/core/base_requirements.txt | 1 + pyproject.toml | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/commitflow-py3.yml b/.github/workflows/commitflow-py3.yml index a43fd333eb2..d17c0699a39 100644 --- a/.github/workflows/commitflow-py3.yml +++ b/.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: | diff --git a/.gitignore b/.gitignore index be5c4740e0a..e6f03dc7129 100644 --- a/.gitignore +++ b/.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 diff --git a/desktop/core/base_requirements.txt b/desktop/core/base_requirements.txt index ac61a3abccd..9c51144df5c 100644 --- a/desktop/core/base_requirements.txt +++ b/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 diff --git a/pyproject.toml b/pyproject.toml index 332923fbeda..d81a1d24ced 100644 --- a/pyproject.toml +++ b/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 = [