Skip to content

Commit d91d4e6

Browse files
committed
use os.path.realpath() to normalise paths within test_run.py
1 parent 00e25d8 commit d91d4e6

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

tests/test_CodeEntropy/test_run.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ def test_create_job_folder_empty_directory(self, mock_listdir, mock_makedirs):
6464
mock_listdir.return_value = []
6565
new_folder_path = RunManager.create_job_folder()
6666
expected_path = os.path.join(self.test_dir, "job001")
67-
self.assertEqual(new_folder_path, expected_path)
68-
mock_makedirs.assert_called_once_with(expected_path, exist_ok=True)
67+
self.assertEqual(
68+
os.path.realpath(new_folder_path), os.path.realpath(expected_path)
69+
)
6970

7071
@patch("os.makedirs")
7172
@patch("os.listdir")
@@ -77,8 +78,12 @@ def test_create_job_folder_with_existing_folders(self, mock_listdir, mock_makedi
7778
mock_listdir.return_value = ["job001", "job002", "job003"]
7879
new_folder_path = RunManager.create_job_folder()
7980
expected_path = os.path.join(self.test_dir, "job004")
80-
self.assertEqual(new_folder_path, expected_path)
81-
mock_makedirs.assert_called_once_with(expected_path, exist_ok=True)
81+
self.assertEqual(
82+
os.path.realpath(new_folder_path), os.path.realpath(expected_path)
83+
)
84+
mock_makedirs.assert_called_once_with(
85+
os.path.realpath(expected_path), exist_ok=True
86+
)
8287

8388
@patch("os.makedirs")
8489
@patch("os.listdir")
@@ -92,8 +97,12 @@ def test_create_job_folder_with_non_matching_folders(
9297
mock_listdir.return_value = ["folderA", "another_one"]
9398
new_folder_path = RunManager.create_job_folder()
9499
expected_path = os.path.join(self.test_dir, "job001")
95-
self.assertEqual(new_folder_path, expected_path)
96-
mock_makedirs.assert_called_once_with(expected_path, exist_ok=True)
100+
self.assertEqual(
101+
os.path.realpath(new_folder_path), os.path.realpath(expected_path)
102+
)
103+
mock_makedirs.assert_called_once_with(
104+
os.path.realpath(expected_path), exist_ok=True
105+
)
97106

98107
@patch("os.makedirs")
99108
@patch("os.listdir")
@@ -105,8 +114,12 @@ def test_create_job_folder_mixed_folder_names(self, mock_listdir, mock_makedirs)
105114
mock_listdir.return_value = ["job001", "abc", "job002", "random"]
106115
new_folder_path = RunManager.create_job_folder()
107116
expected_path = os.path.join(self.test_dir, "job003")
108-
self.assertEqual(new_folder_path, expected_path)
109-
mock_makedirs.assert_called_once_with(expected_path, exist_ok=True)
117+
self.assertEqual(
118+
os.path.realpath(new_folder_path), os.path.realpath(expected_path)
119+
)
120+
mock_makedirs.assert_called_once_with(
121+
os.path.realpath(expected_path), exist_ok=True
122+
)
110123

111124
@patch("os.makedirs")
112125
@patch("os.listdir")
@@ -123,8 +136,12 @@ def test_create_job_folder_with_invalid_job_suffix(
123136
new_folder_path = RunManager.create_job_folder()
124137
expected_path = os.path.join(self.test_dir, "job003")
125138

126-
self.assertEqual(new_folder_path, expected_path)
127-
mock_makedirs.assert_called_once_with(expected_path, exist_ok=True)
139+
self.assertEqual(
140+
os.path.realpath(new_folder_path), os.path.realpath(expected_path)
141+
)
142+
mock_makedirs.assert_called_once_with(
143+
os.path.realpath(expected_path), exist_ok=True
144+
)
128145

129146
@patch("requests.get")
130147
def test_load_citation_data_success(self, mock_get):

0 commit comments

Comments
 (0)