From e5cabc5a553f419d442d37771c8d218854f6bfe7 Mon Sep 17 00:00:00 2001 From: Zachary Newman Date: Fri, 30 Sep 2022 14:10:16 -0400 Subject: [PATCH] Double-check that GPG tests run where expected. The test suite passes even if GPG is not available, because GPG-dependent tests are skipped if GPG is not present. This change asserts the availability of GPG, so CI environments that expect GPG will notice if it goes away unexpectedly rather than silently skipping the GPG tests. Signed-off-by: Zachary Newman --- tests/check_gpg_available.py | 42 ++++++++++++++++++++++++++++++++++++ tox.ini | 2 ++ 2 files changed, 44 insertions(+) create mode 100644 tests/check_gpg_available.py diff --git a/tests/check_gpg_available.py b/tests/check_gpg_available.py new file mode 100644 index 00000000..325b4d39 --- /dev/null +++ b/tests/check_gpg_available.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +""" + + check_gpg_available.py + + + Zack Newman + + + September 30, 2022. + + + See LICENSE for licensing information. + + + The test suite passes even if GPG is not available, because GPG-dependent + tests are skipped if GPG is not present. + + This file asserts the availability of GPG, so CI environments that expect GPG + will notice if it goes away unexpectedly rather than silently skipping the GPG + tests. + + NOTE: the filename is purposefully check_ rather than test_ so that test + discovery doesn't find this unittest and the tests within are only run + when explicitly invoked. +""" + +import unittest + +import securesystemslib.gpg.constants + + +class TestGpgAvailable(unittest.TestCase): + """Test that securesystemslib finds some GPG executable in the environment.""" + + def test_gpg_available(self): + """Test that GPG is available.""" + self.assertTrue(securesystemslib.gpg.constants.HAVE_GPG) + +if __name__ == "__main__": + unittest.main(verbosity=1, buffer=True) diff --git a/tox.ini b/tox.ini index ac2e6e24..97606e91 100644 --- a/tox.ini +++ b/tox.ini @@ -16,6 +16,7 @@ deps = -r{toxinidir}/requirements-test.txt commands = + python -m tests.check_gpg_available coverage run tests/aggregate_tests.py coverage report -m --fail-under 97 @@ -23,6 +24,7 @@ commands = deps = commands = + python -m tests.check_gpg_available python -m tests.check_public_interfaces [testenv:py38-no-gpg]