Skip api tests on Python < 3.6

The new metadata module uses constructs that are only available
on Python >= 3.6 (typing, f-format strings, etc.).

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
This commit is contained in:
Lukas Puehringer 2020-08-18 15:55:43 +02:00
parent 17f08ad200
commit b1dd3d6787

View file

@ -3,7 +3,10 @@
# Copyright 2020, New York University and the TUF contributors
# SPDX-License-Identifier: MIT OR Apache-2.0
""" Unit tests for api/metdata.py
"""
import sys
import logging
import os
import shutil
@ -13,10 +16,21 @@
from datetime import timedelta
from dateutil.relativedelta import relativedelta
from tuf.api.metadata import (
Snapshot,
Timestamp,
)
# 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 tuf.api.metadata import (
Snapshot,
Timestamp,
)
logger = logging.getLogger(__name__)