aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2024-03-03 19:22:32 -0500
committerSam James <sam@gentoo.org>2024-03-07 18:49:07 +0000
commit70ea88e3f1e5bdacd8aa6f1eaf30aa0efe2cc114 (patch)
tree5b698d630407c16408280dac42a2085e40c07a2c
parentdepends.py: rename DependPrinter to Printer (diff)
downloadgentoolkit-70ea88e3f1e5bdacd8aa6f1eaf30aa0efe2cc114.tar.gz
gentoolkit-70ea88e3f1e5bdacd8aa6f1eaf30aa0efe2cc114.tar.bz2
gentoolkit-70ea88e3f1e5bdacd8aa6f1eaf30aa0efe2cc114.zip
switch test framework to pytest
Pytest is a testing framework that is backwards compatible with "unittest" tests, but provides new styles of tests that are more ergonomic. Pytest tests do not require wrapping the test in a class, just a top level python function will be automatically picked up. Assertions use the regular python assert built-in and provide greatly enhanced debug output. These features reduce friction in writing new unit tests, and being backwards compatible allows preserving the existing gentoolkit unit tests. Changing the meson test command and installing the pytest package in CI are the only changes required to start using it! Signed-off-by: John Turner <jturner.usa@gmail.com> Closes: https://github.com/gentoo/gentoolkit/pull/45 Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--.github/workflows/ci.yml2
-rw-r--r--meson.build8
2 files changed, 3 insertions, 7 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index bcb2d59..803dfde 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -33,7 +33,7 @@ jobs:
python -m site
python -m pip install --upgrade pip
# setuptools needed for 3.12+ because of https://github.com/mesonbuild/meson/issues/7702.
- python -m pip install meson ninja setuptools
+ python -m pip install meson ninja setuptools pytest
- name: Install portage
run: |
mkdir portage
diff --git a/meson.build b/meson.build
index c771738..c3e83c5 100644
--- a/meson.build
+++ b/meson.build
@@ -39,12 +39,8 @@ endif
subdir('bin')
subdir('pym')
-test(
- 'python-unittest',
- py,
- args : ['-m', 'unittest', 'discover', meson.current_source_dir() / 'pym'],
- timeout : 0
-)
+pytest = find_program('pytest')
+test('pytest', pytest, args : ['-v', meson.current_source_dir() / 'pym'])
if get_option('code-only')
subdir_done()