Skip to content

Commit 9189ac3

Browse files
Updating unit tests
1 parent 35daea9 commit 9189ac3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/unit/scripts/test_profiler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_parse_memory_file(mocker):
7171

7272
def test_parse_cpu_file(mocker):
7373
with pytest.raises(FileNotFoundError):
74-
parse_cpu_file("non_existent_file.txt", 1)
74+
parse_cpu_file("non_existent_file.txt", 2)
7575

7676
# Mock the 'open' function call to return a file object.
7777
mock_file = mocker.mock_open(read_data="usage_usec 1000000")
@@ -83,7 +83,7 @@ def test_parse_cpu_file(mocker):
8383

8484
mock_file = mocker.mock_open(read_data="1000000")
8585
mocker.patch("builtins.open", mock_file)
86-
assert parse_cpu_file("mocked_file.txt", 2) == 1
86+
assert parse_cpu_file("mocked_file.txt", 1) == 1
8787
mock_file.assert_called_once_with("mocked_file.txt", "r")
8888

8989

@@ -114,11 +114,11 @@ def test_get_cgroup_version(mocker):
114114
# Mock the Path.exists function call to return True
115115
mocker.patch("pathlib.Path.exists", return_value=True)
116116
assert get_cgroup_version('stuff/in/place',
117-
'more_stuff') == 1
117+
'more_stuff') == 2
118118

119119
with mock.patch('pathlib.Path.exists', side_effect=[False, True]):
120120
assert get_cgroup_version('stuff/in/place',
121-
'more_stuff') == 2
121+
'more_stuff') == 1
122122

123123
# Mock the Path.exists function call to return False
124124
mocker.patch("pathlib.Path.exists", return_value=False)
@@ -129,12 +129,12 @@ def test_get_cgroup_version(mocker):
129129

130130
def test_get_cgroup_paths():
131131

132-
process = get_cgroup_paths(1, "test_location/",
132+
process = get_cgroup_paths(2, "test_location/",
133133
"test_name")
134134
assert process.cgroup_memory_path == "test_location/test_name/memory.peak"
135135
assert process.cgroup_cpu_path == "test_location/test_name/cpu.stat"
136136

137-
process = get_cgroup_paths(2, "test_location",
137+
process = get_cgroup_paths(1, "test_location",
138138
"/test_name")
139139
assert (process.cgroup_memory_path ==
140140
"test_location/memory/test_name/memory.max_usage_in_bytes")

0 commit comments

Comments
 (0)