@@ -197,10 +197,12 @@ def test_download_data_from_zip_all_cases(
197197 result_dfs = data .download_data_from_zip ("zipname" , "http://example.com/" )
198198
199199 assert result_dfs == expected_dfs
200- mock_urlretrieve .assert_called_once_with ("http://example.com/zipname.zip" , "data/zipname.zip" )
201- mock_zipfile .assert_called_once_with ("data/zipname.zip" , "r" )
200+ mock_urlretrieve .assert_called_once_with (
201+ "http://example.com/zipname.zip" , os .path .join ("data" , "zipname.zip" )
202+ )
203+ mock_zipfile .assert_called_once_with (os .path .join ("data" , "zipname.zip" ), "r" )
202204 mock_makedirs .assert_called_once_with ("data/" , exist_ok = True )
203- mock_get_dataframes_in_folder .assert_called_once_with ("data/ zipname" , ".csv" )
205+ mock_get_dataframes_in_folder .assert_called_once_with (os . path . join ( "data" , " zipname") , ".csv" )
204206
205207 mock_urlretrieve .reset_mock ()
206208 mock_zipfile .reset_mock ()
@@ -212,7 +214,7 @@ def test_download_data_from_zip_all_cases(
212214 mock_urlretrieve .assert_not_called ()
213215 mock_zipfile .assert_not_called ()
214216 mock_makedirs .assert_called_once_with ("data/" , exist_ok = True )
215- mock_get_dataframes_in_folder .assert_called_with ("data/ zipname" , ".csv" )
217+ mock_get_dataframes_in_folder .assert_called_with (os . path . join ( "data" , " zipname") , ".csv" )
216218
217219
218220@patch ("os.walk" )
@@ -222,15 +224,15 @@ def test_get_dataframes_in_folder(mock_convert_tsf, mock_read_csv, mock_walk):
222224 mock_walk .return_value = [("/fakepath" , ("subfolder" ,), ("file.csv" ,))]
223225 result_csv = data .get_dataframes_in_folder ("/fakepath" , ".csv" )
224226 assert len (result_csv ) == 1
225- mock_read_csv .assert_called_once_with ("/ fakepath/ file.csv" )
227+ mock_read_csv .assert_called_once_with (os . path . join ( " fakepath" , " file.csv") )
226228 pd .testing .assert_frame_equal (result_csv [0 ], df_conductor )
227229
228230 mock_read_csv .reset_mock ()
229231 mock_convert_tsf .reset_mock ()
230232 mock_walk .return_value = [("/fakepath" , ("subfolder" ,), ("file.tsf" ,))]
231233 result_tsf = data .get_dataframes_in_folder ("/fakepath" , ".tsf" )
232234 assert len (result_tsf ) == 1
233- mock_convert_tsf .assert_called_once_with ("/ fakepath/ file.tsf" )
235+ mock_convert_tsf .assert_called_once_with (os . path . join ( " fakepath" , " file.tsf") )
234236 pd .testing .assert_frame_equal (result_tsf [0 ], df_beijing )
235237 mock_read_csv .assert_called ()
236238
@@ -330,8 +332,6 @@ def test_data_get_data(name_data: str, df: pd.DataFrame, mocker: MockerFixture)
330332 assert mock_read_dl .call_count == 1
331333 assert np .shape (df_result ) == (3 , 7 )
332334 elif name_data == "SNCF" :
333- print ("=" * 100 )
334- print (df_result )
335335 assert not df_result .empty
336336 assert df_result .index .name == "station"
337337 assert df_result ["val_in" ].sum () == df ["val_in" ].sum ()
0 commit comments