]> git.ipfire.org Git - thirdparty/systemd.git/commit
test_ukify: rework how --flakes argument is appended
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 22 Apr 2023 11:10:28 +0000 (13:10 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 5 May 2023 16:42:37 +0000 (18:42 +0200)
commit55be961f48cfb5116776bf43956eb3b9600a3f0d
tree9ea94d5a14240259a04890ac68f60a1c9c81c44f
parent041f536f9a9dfbf8023db680f536f0080ad054c1
test_ukify: rework how --flakes argument is appended

The usual approach is to put 'addopts = --flakes' in setup.cfg. Unfortunately
this fails badly when pytest-flakes is not installed:
  ERROR: usage: test_ukify.py [options] [file_or_dir] [file_or_dir] [...]
  test_ukify.py: error: unrecognized arguments: --flakes

pytest-flakes is not packaged everywhere, and this test is not very important,
so let's just do it only if pytest-flakes is available. We now detect if
pytest-flakes is available and only add '--flakes' conditionally. This
unfortunately means that when invoked via 'pytest' or directly as
'src/ukify/test/test_ukify.py', '--flakes' will not be appended automatically.
But I don't see a nice way to achieve previous automatic behaviour.

(I first considered making 'setup.cfg' templated. But then it is created
in the build directory, but we would need it in the source directory for
pytest to load it automatically. So to load the file, we'd need to give an
argument to pytest anyway, so we don't gain anything with this more complex
approach.)
src/ukify/test/meson.build
src/ukify/test/setup.cfg [deleted file]
src/ukify/test/test_ukify.py