From af0451d8ce8efcc788cb4a82f8a868c70314aeb9 Mon Sep 17 00:00:00 2001 From: Martin Vrachev Date: Tue, 16 Feb 2021 17:05:19 +0200 Subject: [PATCH] Skip test_signer on Python2.7 Signed-off-by: Martin Vrachev --- tests/test_signer.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/test_signer.py b/tests/test_signer.py index 3cb644bd..b52ad1cc 100644 --- a/tests/test_signer.py +++ b/tests/test_signer.py @@ -17,12 +17,27 @@ Test cases for 'signer.py'. """ +import sys +import unittest + import unittest import securesystemslib.formats import securesystemslib.keys as KEYS -from securesystemslib.signer import Signature, SSlibSigner from securesystemslib.exceptions import FormatError, UnsupportedAlgorithmError +# TODO: Remove case handling when fully dropping support for versions >= 3.6 +IS_PY_VERSION_SUPPORTED = sys.version_info >= (3, 6) + +# Use setUpModule to tell unittest runner to skip this test module gracefully. +def setUpModule(): + if not IS_PY_VERSION_SUPPORTED: + raise unittest.SkipTest('requires Python 3.6 or higher') + +# Since setUpModule is called after imports we need to import conditionally. +if IS_PY_VERSION_SUPPORTED: + from securesystemslib.signer import Signature, SSlibSigner + + class TestSSlibSigner(unittest.TestCase): @classmethod