Skip to content

Commit

Permalink
Double-check that GPG tests run where expected.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
znewman01 committed Sep 30, 2022
1 parent 6f0d9f3 commit e5cabc5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/check_gpg_available.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python

"""
<Program Name>
check_gpg_available.py
<Author>
Zack Newman <[email protected]>
<Started>
September 30, 2022.
<Copyright>
See LICENSE for licensing information.
<Purpose>
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)
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ 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

[testenv:purepy38]
deps =

commands =
python -m tests.check_gpg_available
python -m tests.check_public_interfaces

[testenv:py38-no-gpg]
Expand Down

0 comments on commit e5cabc5

Please sign in to comment.