1 # Copyright (c) 2020 Deutsche Telekom.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 if sys.version_info[0] < 3:
15 from mock import patch, MagicMock
16 if sys.version_info[0] >= 3:
17 from unittest.mock import patch, MagicMock
19 from onaplogging.utils.system import is_above_python_2_7, is_above_python_3_2
22 class TestUtils(unittest.TestCase):
24 def test_is_above_python_3_2(self):
25 with patch("onaplogging.utils.system.sys.version_info", (3, 4, 7)):
26 assert is_above_python_3_2() is True
28 with patch("onaplogging.utils.system.sys.version_info", (2, 7, 5)):
29 assert is_above_python_3_2() is False
31 with patch("onaplogging.utils.system.sys.version_info", (3, 2, 0, "final", 0)):
32 assert is_above_python_3_2() is True
34 def test_is_above_python_2_7(self):
35 with patch("onaplogging.utils.system.sys.version_info", (3, 4, 7)):
36 assert is_above_python_2_7() is True
38 with patch("onaplogging.utils.system.sys.version_info", (2, 7, 5)):
39 assert is_above_python_2_7() is True
41 with patch("onaplogging.utils.system.sys.version_info", (2, 5, 6)):
42 assert is_above_python_2_7() is False
44 with patch("onaplogging.utils.system.sys.version_info", (2, 7, 0, "final", 0)):
45 assert is_above_python_2_7() is True