Skip to content

Commit

Permalink
switch test framework to pytest
Browse files Browse the repository at this point in the history
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 <[email protected]>
Closes: #45
Signed-off-by: Sam James <[email protected]>
  • Loading branch information
Jturnerusa authored and thesamesam committed Mar 7, 2024
1 parent b9294a0 commit 70ea88e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 70ea88e

Please sign in to comment.