From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Cleber Rosa" <crosa@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"John Snow" <jsnow@redhat.com>, "Thomas Huth" <thuth@redhat.com>
Subject: [PATCH v2 2/4] python: replace avocado tests with pytest
Date: Wed, 25 Feb 2026 14:28:06 -0500 [thread overview]
Message-ID: <20260225192808.957477-3-jsnow@redhat.com> (raw)
In-Reply-To: <20260225192808.957477-1-jsnow@redhat.com>
Following suit with the rest of this repository, drop avocado and
replace it with the Python standard "pytest" package.
In this case, we do not truly need pytest as all we are using it for is
running other python processes formerly launched by shell scripts, but
this matches how the standalone python-qemu-qmp package does things,
which keeps things simple on my end.
(pytest version chosen based off of Debian 11's package version as queried by
repology; under the assumption that this is the likely the oldest
version we currently leverage in testing.)
Signed-off-by: John Snow <jsnow@redhat.com>
---
python/Makefile | 4 +-
python/setup.cfg | 1 +
python/tests/linters.py | 89 ++++++++++++++++++++++++++++++++++++++++
python/tests/minreqs.txt | 1 +
4 files changed, 93 insertions(+), 2 deletions(-)
create mode 100644 python/tests/linters.py
diff --git a/python/Makefile b/python/Makefile
index b6c9cd1bce2..42994d39618 100644
--- a/python/Makefile
+++ b/python/Makefile
@@ -105,7 +105,7 @@ develop:
.PHONY: check
check:
- @avocado --config avocado.cfg run tests/
+ @pytest -v tests/*.py
.PHONY: check-tox
check-tox:
@@ -113,7 +113,7 @@ check-tox:
.PHONY: check-coverage
check-coverage:
- @coverage run -m avocado --config avocado.cfg run tests/*.py
+ @coverage run -m pytest -v tests/*.py
@coverage combine
@coverage html
@coverage report
diff --git a/python/setup.cfg b/python/setup.cfg
index c46a95f8d41..03344526730 100644
--- a/python/setup.cfg
+++ b/python/setup.cfg
@@ -43,6 +43,7 @@ devel =
mypy >= 1.4.0
pylint >= 2.17.3
pylint != 3.2.4; python_version<"3.9"
+ pytest >= 6.0.2
tox >= 3.18.0
sphinx >= 3.4.3
diff --git a/python/tests/linters.py b/python/tests/linters.py
new file mode 100644
index 00000000000..28556c09910
--- /dev/null
+++ b/python/tests/linters.py
@@ -0,0 +1,89 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os
+import subprocess
+import sys
+
+
+def pyrun(*args):
+ subprocess.run((sys.executable, *args), check=True)
+
+
+class TestLinters:
+
+ def test_flake8_pkg(self):
+ pyrun("-m", "flake8", "qemu/")
+
+ def test_flake8_scripts(self):
+ pyrun("-m", "flake8", "scripts/")
+
+ def test_flake8_qapi(self):
+ pyrun("-m", "flake8",
+ "../scripts/qapi/",
+ "../docs/sphinx/qapidoc.py",
+ "../docs/sphinx/qapi_domain.py")
+
+ def test_isort_pkg(self):
+ pyrun("-m", "isort", "-c", "qemu/")
+
+ def test_isort_scripts(self):
+ pyrun("-m", "isort", "-c", "scripts/")
+
+ def test_isort_qapi(self):
+ pyrun("-m", "isort", "--sp", ".", "-c", "../scripts/qapi/")
+
+ def test_isort_qapi_sphinx(self):
+ # Force isort to recognize 'compat' as a local module and not
+ # third-party
+ pyrun("-m", "isort", "--sp", ".", "-c", "-p", "compat",
+ "../docs/sphinx/qapi_domain.py",
+ "../docs/sphinx/qapidoc.py")
+
+ def test_mypy_pkg(self):
+ pyrun("-m", "mypy", "-p", "qemu")
+
+ def test_mypy_scripts(self):
+ pyrun("-m", "mypy", "scripts/")
+
+ def test_mypy_qapi(self):
+ pyrun("-m", "mypy", "../scripts/qapi")
+
+ def test_mypy_iotests(self):
+ cwd = os.getcwd()
+ try:
+ os.chdir("../tests/qemu-iotests/")
+ pyrun("-m", "linters", "--mypy")
+ finally:
+ os.chdir(cwd)
+
+ # Setuptools v60 introduced the SETUPTOOLS_USE_DISTUTILS=stdlib
+ # workaround; stdlib distutils was fully removed in Python
+ # 3.12+. Once we are on >=3.12+ exclusively, this workaround can be
+ # dropped safely. Until then, it is needed for some versions on
+ # Fedora/Debian distributions which relied upon distro-patched
+ # setuptools present in CPython, but not within setuptools itself.
+
+ def test_pylint_pkg(self):
+ os.environ['SETUPTOOLS_USE_DISTUTILS'] = 'stdlib'
+ pyrun("-m", "pylint", "qemu/")
+
+ def test_pylint_scripts(self):
+ os.environ['SETUPTOOLS_USE_DISTUTILS'] = 'stdlib'
+ pyrun("-m", "pylint", "qemu/")
+
+ def test_pylint_qapi(self):
+ os.environ['SETUPTOOLS_USE_DISTUTILS'] = 'stdlib'
+ pyrun("-m", "pylint",
+ "--rcfile=../scripts/qapi/pylintrc",
+ "../scripts/qapi/",
+ "../docs/sphinx/qapidoc.py",
+ "../docs/sphinx/qapi_domain.py")
+
+ def test_pylint_iotests(self):
+ os.environ['SETUPTOOLS_USE_DISTUTILS'] = 'stdlib'
+ cwd = os.getcwd()
+ try:
+ os.chdir("../tests/qemu-iotests/")
+ pyrun("-m", "linters", "--pylint")
+ finally:
+ os.chdir(cwd)
diff --git a/python/tests/minreqs.txt b/python/tests/minreqs.txt
index 38b17d17e14..19912027076 100644
--- a/python/tests/minreqs.txt
+++ b/python/tests/minreqs.txt
@@ -32,6 +32,7 @@ fusepy==2.0.4
# Test-runners, utilities, etc.
avocado-framework==90.0
+pytest==6.0.2
# Linters
flake8==5.0.4
--
2.53.0
next prev parent reply other threads:[~2026-02-25 19:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 19:28 [PATCH v2 0/4] Python: drop avocado, formally support python3.14 John Snow
2026-02-25 19:28 ` [PATCH v2 1/4] python: pin 'wheel' version in minreqs test John Snow
2026-02-26 14:04 ` Daniel P. Berrangé
2026-02-25 19:28 ` John Snow [this message]
2026-02-26 14:26 ` [PATCH v2 2/4] python: replace avocado tests with pytest Daniel P. Berrangé
2026-02-26 17:51 ` John Snow
2026-02-27 11:29 ` Daniel P. Berrangé
2026-02-25 19:28 ` [PATCH v2 3/4] python: drop avocado John Snow
2026-02-26 14:18 ` Daniel P. Berrangé
2026-02-25 19:28 ` [PATCH v2 4/4] python: add formal python3.14 support and testing John Snow
2026-02-26 14:06 ` Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260225192808.957477-3-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=crosa@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.