From 2b017f7302de6f685af13692d8db277ef5bc055c Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 9 Jun 2023 10:56:10 +0200 Subject: [PATCH] Add tests Signed-off-by: Irene Bandera --- py_utils/test/py_utils/import/test_import.py | 1 + .../py_utils/unittest/system/test_System.py | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 py_utils/test/py_utils/unittest/system/test_System.py diff --git a/py_utils/test/py_utils/import/test_import.py b/py_utils/test/py_utils/import/test_import.py index 3408537d..ed689976 100644 --- a/py_utils/test/py_utils/import/test_import.py +++ b/py_utils/test/py_utils/import/test_import.py @@ -18,6 +18,7 @@ import py_utils.debugging.debug_utils # noqa: F401 import py_utils.logging.log_utils # noqa: F401 +import py_utils.system.system_utils # noqa: F401 import py_utils.time.Timer # noqa: F401 import py_utils.wait.WaitHandler # noqa: F401 import py_utils.wait.BooleanWaitHandler # noqa: F401 diff --git a/py_utils/test/py_utils/unittest/system/test_System.py b/py_utils/test/py_utils/unittest/system/test_System.py new file mode 100644 index 00000000..e0499f77 --- /dev/null +++ b/py_utils/test/py_utils/unittest/system/test_System.py @@ -0,0 +1,52 @@ +# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Test system_utils methods. +""" + +import os +from py_utils.system.system_utils import is_linux, is_windows + + +def test_is_linux(): + # Test case 1: Running the script on a Linux system + os.name = 'posix' + assert is_linux() == True + + # Test case 2: Running the script on a Windows system + os.name = 'nt' + assert is_linux() == False + + # Test case 3: Running the script on a different operating system + os.name = 'mac' + assert is_linux() == False + + +def test_is_windows(): + # Test case 1: Running the script on a Linux system + os.name = 'posix' + assert is_windows() == False + + # Test case 2: Running the script on a Windows system + os.name = 'nt' + assert is_windows() == True + + # Test case 3: Running the script on a different operating system + os.name = 'mac' + assert is_windows() == False + +# Run the tests +test_is_linux() +test_is_windows()