@@ -104,7 +104,7 @@ def _get_dig_montage_pos(montage):
104104 return np .array ([d ['r' ] for d in _get_dig_eeg (montage .dig )])
105105
106106
107- def test_dig_montage_trans (tmpdir ):
107+ def test_dig_montage_trans (tmp_path ):
108108 """Test getting a trans from and applying a trans to a montage."""
109109 nasion , lpa , rpa , * ch_pos = np .random .RandomState (0 ).randn (10 , 3 )
110110 ch_pos = {f'EEG{ ii :3d} ' : pos for ii , pos in enumerate (ch_pos , 1 )}
@@ -113,7 +113,7 @@ def test_dig_montage_trans(tmpdir):
113113 trans = compute_native_head_t (montage )
114114 _ensure_trans (trans )
115115 # ensure that we can save and load it, too
116- fname = tmpdir . join ( 'temp-mon.fif' )
116+ fname = tmp_path / 'temp-mon.fif'
117117 _check_roundtrip (montage , fname , 'mri' )
118118 # test applying a trans
119119 position1 = montage .get_positions ()
@@ -436,10 +436,10 @@ def test_documented():
436436 id = 'brainvision' ),
437437])
438438def test_montage_readers (
439- reader , file_content , expected_dig , ext , warning , tmpdir
439+ reader , file_content , expected_dig , ext , warning , tmp_path
440440):
441441 """Test that we have an equivalent of read_montage for all file formats."""
442- fname = op .join (str (tmpdir ), 'test.{ext}' .format (ext = ext ))
442+ fname = op .join (str (tmp_path ), 'test.{ext}' .format (ext = ext ))
443443 with open (fname , 'w' ) as fid :
444444 fid .write (file_content )
445445
@@ -485,7 +485,7 @@ def test_read_locs():
485485 )
486486
487487
488- def test_read_dig_dat (tmpdir ):
488+ def test_read_dig_dat (tmp_path ):
489489 """Test reading *.dat electrode locations."""
490490 rows = [
491491 ['Nasion' , 78 , 0.00 , 1.00 , 0.00 ],
@@ -496,7 +496,7 @@ def test_read_dig_dat(tmpdir):
496496 ['Centroid' , 67 , 0.00 , 0.00 , 0.00 ],
497497 ]
498498 # write mock test.dat file
499- temp_dir = str (tmpdir )
499+ temp_dir = str (tmp_path )
500500 fname_temp = op .join (temp_dir , 'test.dat' )
501501 with open (fname_temp , 'w' ) as fid :
502502 for row in rows :
@@ -574,12 +574,12 @@ def test_read_dig_montage_using_polhemus_fastscan():
574574 assert_allclose (val , EXPECTED_FID_IN_POLHEMUS [kk ])
575575
576576
577- def test_read_dig_montage_using_polhemus_fastscan_error_handling (tmpdir ):
577+ def test_read_dig_montage_using_polhemus_fastscan_error_handling (tmp_path ):
578578 """Test reading Polhemus FastSCAN errors."""
579579 with open (op .join (kit_dir , 'test_elp.txt' )) as fid :
580580 content = fid .read ().replace ('FastSCAN' , 'XxxxXXXX' )
581581
582- fname = str ( tmpdir . join ( 'faulty_FastSCAN.txt' ))
582+ fname = tmp_path / 'faulty_FastSCAN.txt'
583583 with open (fname , 'w' ) as fid :
584584 fid .write (content )
585585
@@ -588,7 +588,7 @@ def test_read_dig_montage_using_polhemus_fastscan_error_handling(tmpdir):
588588
589589 EXPECTED_ERR_MSG = "allowed value is '.txt', but got '.bar' instead"
590590 with pytest .raises (ValueError , match = EXPECTED_ERR_MSG ):
591- _ = read_polhemus_fastscan (fname = tmpdir . join ( 'foo.bar' ) )
591+ _ = read_polhemus_fastscan (fname = tmp_path / 'foo.bar' )
592592
593593
594594def test_read_dig_polhemus_isotrak_hsp ():
@@ -633,13 +633,13 @@ def test_read_dig_polhemus_isotrak_elp():
633633
634634
635635@pytest .fixture (scope = 'module' )
636- def isotrak_eeg (tmpdir_factory ):
636+ def isotrak_eeg (tmp_path_factory ):
637637 """Mock isotrak file with EEG positions."""
638638 _SEED = 42
639639 N_ROWS , N_COLS = 5 , 3
640640 content = np .random .RandomState (_SEED ).randn (N_ROWS , N_COLS )
641641
642- fname = tmpdir_factory .mktemp ('data' ). join ( 'test.eeg' )
642+ fname = tmp_path_factory .mktemp ('data' ) / 'test.eeg'
643643 with open (str (fname ), 'w' ) as fid :
644644 fid .write ((
645645 '3 200\n '
@@ -695,7 +695,7 @@ def test_read_dig_polhemus_isotrak_eeg(isotrak_eeg):
695695 assert dig_point ['coord_frame' ] == FIFF .FIFFV_COORD_UNKNOWN
696696
697697
698- def test_read_dig_polhemus_isotrak_error_handling (isotrak_eeg , tmpdir ):
698+ def test_read_dig_polhemus_isotrak_error_handling (isotrak_eeg , tmp_path ):
699699 """Test errors in reading Polhemus IsoTrak files.
700700
701701 1 - matching ch_names and number of points in isotrak file.
@@ -711,7 +711,7 @@ def test_read_dig_polhemus_isotrak_error_handling(isotrak_eeg, tmpdir):
711711 )
712712
713713 # Check fname extensions
714- fname = op .join (tmpdir , 'foo.bar' )
714+ fname = op .join (tmp_path , 'foo.bar' )
715715 with pytest .raises (
716716 ValueError ,
717717 match = "Allowed val.*'.hsp', '.elp', and '.eeg', but got '.bar' instead"
@@ -857,12 +857,12 @@ def test_set_dig_montage():
857857
858858
859859@testing .requires_testing_data
860- def test_fif_dig_montage (tmpdir ):
860+ def test_fif_dig_montage (tmp_path ):
861861 """Test FIF dig montage support."""
862862 dig_montage = read_dig_fif (fif_dig_montage_fname )
863863
864864 # test round-trip IO
865- temp_dir = str (tmpdir )
865+ temp_dir = str (tmp_path )
866866 fname_temp = op .join (temp_dir , 'test.fif' )
867867 _check_roundtrip (dig_montage , fname_temp )
868868
@@ -919,7 +919,7 @@ def test_fif_dig_montage(tmpdir):
919919
920920
921921@testing .requires_testing_data
922- def test_egi_dig_montage (tmpdir ):
922+ def test_egi_dig_montage (tmp_path ):
923923 """Test EGI MFF XML dig montage support."""
924924 dig_montage = read_dig_egi (egi_dig_montage_fname )
925925 fid , coord = _get_fid_coords (dig_montage .dig )
@@ -957,7 +957,7 @@ def test_egi_dig_montage(tmpdir):
957957 )
958958
959959 # test round-trip IO
960- fname_temp = tmpdir . join ( 'egi_test.fif' )
960+ fname_temp = tmp_path / 'egi_test.fif'
961961 _check_roundtrip (dig_montage , fname_temp , 'unknown' )
962962 _check_roundtrip (dig_montage_in_head , fname_temp )
963963
@@ -974,7 +974,7 @@ def _pop_montage(dig_montage, ch_name):
974974
975975
976976@testing .requires_testing_data
977- def test_read_dig_captrak (tmpdir ):
977+ def test_read_dig_captrak (tmp_path ):
978978 """Test reading a captrak montage file."""
979979 EXPECTED_CH_NAMES_OLD = [
980980 'AF3' , 'AF4' , 'AF7' , 'AF8' , 'C1' , 'C2' , 'C3' , 'C4' , 'C5' , 'C6' , 'CP1' ,
@@ -1006,7 +1006,8 @@ def test_read_dig_captrak(tmpdir):
10061006 )
10071007
10081008 montage = transform_to_head (montage ) # transform_to_head has to be tested
1009- _check_roundtrip (montage = montage , fname = str (tmpdir .join ('bvct_test.fif' )))
1009+ _check_roundtrip (montage = montage ,
1010+ fname = str (tmp_path / 'bvct_test.fif' ))
10101011
10111012 fid , _ = _get_fid_coords (montage .dig )
10121013 assert_allclose (
@@ -1607,7 +1608,7 @@ def test_montage_add_fiducials():
16071608 assert all ([d ['kind' ] != FIFF .FIFFV_POINT_CARDINAL for d in montage .dig ])
16081609
16091610
1610- def test_read_dig_localite (tmpdir ):
1611+ def test_read_dig_localite (tmp_path ):
16111612 """Test reading Localite .csv file."""
16121613 contents = """#,id,x,y,z
16131614 1,Nasion,-2.016253511,6.243001715,34.63167712
@@ -1629,7 +1630,7 @@ def test_read_dig_localite(tmpdir):
16291630 17,ch14,-61.16539571,-61.86866187,26.23986153
16301631 18,ch15,-55.82855386,-34.77319103,25.8083942"""
16311632
1632- fname = tmpdir / 'localite.csv'
1633+ fname = tmp_path / 'localite.csv'
16331634 with open (fname , 'w' ) as f :
16341635 for row in contents .split ('\n ' ):
16351636 f .write (f'{ row .lstrip ()} \n ' )
0 commit comments