diff --git a/Makefile b/Makefile index 5d86d171..d739fcde 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PYTHON ?= python3 +PYTHON ?= py -3 BASE_URL ?= http://localhost:8080 CA_FILE ?= ACTION_SCRIPT ?= diff --git a/tests/client.py b/tests/client.py index da141ba1..4c6565ce 100644 --- a/tests/client.py +++ b/tests/client.py @@ -29,8 +29,21 @@ def timestamp(value): 'timestamp must be UTC ending in Z' ) try: - return dt.datetime.fromisoformat(value[:-1] + '+00:00') - except ValueError as exc: + normalized = value[:-1] + '+00:00' + + if '.' in normalized: + prefix, fraction = normalized.split('.', 1) + digits, timezone = fraction.split('+', 1) + + if not digits.isdigit() or len(digits) > 9: + raise ValueError('invalid fractional seconds') + + digits = digits[:6].ljust(6, '0') + normalized = f'{prefix}.{digits}+{timezone}' + + return dt.datetime.fromisoformat(normalized) + + except (ValueError, TypeError) as exc: raise Failure(f'invalid RFC3339 timestamp: {value!r}') from exc def validate(value, schema, where='response'):