toaster.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 1/7] Toaster: Update toaster-requirements.txt and Added pytest.ini
@ 2023-11-09 17:15 Alassane Yattara
  2023-11-09 17:15 ` [PATCH v4 2/7] Toaster: Update orm.models to catch error ProcessLookupError Alassane Yattara
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Alassane Yattara @ 2023-11-09 17:15 UTC (permalink / raw)
  To: toaster; +Cc: Alassane Yattara

*** Update toaster-requirements.txt ***
Add pytest and some plugin's
- Pytest-html is a plugin for pytest that generates a HTML report for test results.
- Pytest-django allows us to test Django project/applications with the pytest testing tool.
- Pytest-env is a pytest plugin that enables us to set environment variables in a pytest.ini or pyproject.toml file
- Pytest-metadata is a plugin for pytest that provides access to test session metadata, required by pytest-html plugin
to provides metadata information in the HTML report like below:

Python 3.10.12
Platform Linux-6.2.0-35-generic-x86_64-with-glibc2.35
Packages:
    - pytest: 7.4.2
    - pluggy: 1.3.0
Plugins	:
    - django: 4.5.2
    - metadata: 3.0.0
    - order: 1.1.0
    - html: 4.0.2
    - env: 1.1.0

*** Added pytest.ini file ***
The main reason for using pytest is to be able to generate a positive test report
using the pytest-html plugin.

Integrating Pytest with Tox is a straightforward process, this can be
done using tox.ini instead of pytest.ini used to configure pytest, that
is another reason for using pytest. Tox is a tool that automates testing
across different virtual environments, it can help ensure application
will be tested against multiple Python versions and environments.
https://github.com/pytest-dev/pytest/blob/main/tox.ini

Generated reports create a historical record of test results over time.
This can help track the progress of the application's stability and quality

Documentation and Transparency: Test reports provide us a clear and detailed
documentation of the test results. They show what tests were executed,
which ones passed, and which ones failed. This transparency is critical
for understanding the current state of the application and its test coverage.

Communication: Test reports are an effective means of communication among community
to understand the testing progress and results.

Debugging, Troubleshooting Historical Tracking and Regression Testing:
In case of test failures, a detailed test report can be invaluable for debugging.
It provides information about the specific test case that failed,
the input data used, and any error messages.

Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
---
 lib/toaster/pytest.ini   | 19 +++++++++++++++++++
 toaster-requirements.txt |  5 +++++
 2 files changed, 24 insertions(+)
 create mode 100644 lib/toaster/pytest.ini

diff --git a/lib/toaster/pytest.ini b/lib/toaster/pytest.ini
new file mode 100644
index 00000000..f07076b7
--- /dev/null
+++ b/lib/toaster/pytest.ini
@@ -0,0 +1,19 @@
+# -- FILE: pytest.ini (or tox.ini)
+[pytest]
+DJANGO_SETTINGS_MODULE = toastermain.settings_test
+
+python_files = db/test_*.py commands/test_*.py views/test_*.py browser/test_*.py functional/test_*.py
+
+# --create-db - force re creation of the test database
+# https://pytest-django.readthedocs.io/en/latest/database.html#create-db-force-re-creation-of-the-test-database
+
+# --html=report.html --self-contained-html
+# https://docs.pytest.org/en/latest/usage.html#creating-html-reports
+# https://pytest-html.readthedocs.io/en/latest/user_guide.html#creating-a-self-contained-report
+addopts = --create-db --html="Toaster Tests Report.html" --self-contained-html 
+
+# Define environment variables using pytest-env
+# A pytest plugin that enables you to set environment variables in the pytest.ini file.
+# https://pypi.org/project/pytest-env/
+env =
+    TOASTER_BUILDSERVER=1
diff --git a/toaster-requirements.txt b/toaster-requirements.txt
index d8e48b7f..19bf6fd2 100644
--- a/toaster-requirements.txt
+++ b/toaster-requirements.txt
@@ -2,3 +2,8 @@ Django>4.2,<4.3
 beautifulsoup4>=4.4.0
 pytz
 django-log-viewer==1.1.7
+pytest==7.4.2
+pytest-django==4.5.2
+pytest-env==1.1.0
+pytest-html==4.0.2
+pytest-metadata==3.0.0
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-11-09 17:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-09 17:15 [PATCH v4 1/7] Toaster: Update toaster-requirements.txt and Added pytest.ini Alassane Yattara
2023-11-09 17:15 ` [PATCH v4 2/7] Toaster: Update orm.models to catch error ProcessLookupError Alassane Yattara
2023-11-09 17:15 ` [PATCH v4 3/7] Toaster: Bug-fix pytest and Failed: Database access not allowed Alassane Yattara
2023-11-09 17:15 ` [PATCH v4 4/7] Toaster: fixed pytest error: Database access not allowed, use the "django_db" Alassane Yattara
2023-11-09 17:15 ` [PATCH v4 5/7] Toaster: Bug-fix django.db.utils.IntegrityError: Problem installing fixture Alassane Yattara
2023-11-09 17:15 ` [PATCH v4 6/7] Toaster: Move toaster tests requirements in bitbake/lib/toaster/toaster-tests-requirements Alassane Yattara
2023-11-09 17:15 ` [PATCH v4 7/7] Toaster: fixed: Tests fail when executed one after the other out of sequence Alassane Yattara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).