Skip to content

Commit 3342f9d

Browse files
committed
Add tests
Signed-off-by: Irene Bandera <[email protected]>
1 parent ba9430e commit 3342f9d

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

py_utils/test/py_utils/import/test_import.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import py_utils.debugging.debug_utils # noqa: F401
2020
import py_utils.logging.log_utils # noqa: F401
21+
import py_utils.system.system_utils # noqa: F401
2122
import py_utils.time.Timer # noqa: F401
2223
import py_utils.wait.WaitHandler # noqa: F401
2324
import py_utils.wait.BooleanWaitHandler # noqa: F401
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
Test system_utils methods.
17+
"""
18+
19+
import os
20+
from py_utils.system.system_utils import is_linux, is_windows
21+
22+
23+
def test_is_linux():
24+
# Test case 1: Running the script on a Linux system
25+
os.name = 'posix'
26+
assert (is_linux() is True)
27+
28+
# Test case 2: Running the script on a Windows system
29+
os.name = 'nt'
30+
assert (is_linux() is False)
31+
32+
# Test case 3: Running the script on a different operating system
33+
os.name = 'mac'
34+
assert (is_linux() is False)
35+
36+
37+
def test_is_windows():
38+
# Test case 1: Running the script on a Linux system
39+
os.name = 'posix'
40+
assert (is_windows() is False)
41+
42+
# Test case 2: Running the script on a Windows system
43+
os.name = 'nt'
44+
assert (is_windows() is True)
45+
46+
# Test case 3: Running the script on a different operating system
47+
os.name = 'mac'
48+
assert (is_windows() is False)
49+
50+
51+
# Run the tests
52+
test_is_linux()
53+
test_is_windows()

0 commit comments

Comments
 (0)