X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=tests%2Ftest_pyderasn.py;h=f0071c3d50c37ecf53eb1ed8b761be95d634b98a;hb=8ca61728c3a6a351305d41b57038d0697217fc4f;hp=78448b86ca8eda107bf98829fab6f5db8031dc4d;hpb=bfce27caa529762d95ad2e4b02506d7eec7fe3bf;p=pyderasn.git diff --git a/tests/test_pyderasn.py b/tests/test_pyderasn.py index 78448b8..f0071c3 100644 --- a/tests/test_pyderasn.py +++ b/tests/test_pyderasn.py @@ -1,6 +1,6 @@ # coding: utf-8 # PyDERASN -- Python ASN.1 DER/CER/BER codec with abstract structures -# Copyright (C) 2017-2021 Sergey Matveev +# Copyright (C) 2017-2022 Sergey Matveev # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as @@ -32,6 +32,7 @@ from string import whitespace from time import mktime from time import time from unittest import TestCase +from unittest.mock import patch from dateutil.tz import UTC from hypothesis import assume @@ -678,7 +679,7 @@ class TestBoolean(CommonMixin, TestCase): repr(obj) list(obj.pps()) - @given(integers(min_value=2)) + @given(integers(min_value=2, max_value=10)) def test_invalid_len(self, l): with self.assertRaises(InvalidLength): Boolean().decode(b"".join(( @@ -5062,6 +5063,14 @@ class TestUTCTime(TimeMixin, CommonMixin, TestCase): with self.assertRaisesRegex(ValueError, "only naive"): UTCTime(datetime(2000, 1, 1, 1, tzinfo=UTC)) + def test_raises_if_no_dateutil(self): + with patch("pyderasn.tzUTC", new="missing"): + with self.assertRaisesRegex(NotImplementedError, "dateutil"): + UTCTime(datetime.now()).totzdatetime() + + def test_tzinfo_gives_datetime_with_tzutc_tzinfo(self): + self.assertEqual(UTCTime(datetime.now()).totzdatetime().tzinfo, UTC) + @composite def tlv_value_strategy(draw):