@@ -473,10 +473,10 @@ def test_read_noformat_arbitrary(self, registry, original, fmtcls1):
473473 "please provide a 'format' argument."
474474 )
475475
476- def test_read_noformat_arbitrary_file (self , tmpdir , registry , original ):
476+ def test_read_noformat_arbitrary_file (self , tmp_path , registry , original ):
477477 """Tests that all identifier functions can accept arbitrary files"""
478478 registry ._readers .update (original ["readers" ])
479- testfile = str ( tmpdir . join ( "foo.example" ))
479+ testfile = tmp_path / "foo.example"
480480 with open (testfile , "w" ) as f :
481481 f .write ("Hello world" )
482482
@@ -528,7 +528,7 @@ def test_read_format_noreader(self, registry, fmtcls1):
528528 f"No reader defined for format '{ fmt } ' and class '{ cls .__name__ } '"
529529 )
530530
531- def test_read_identifier (self , tmpdir , registry , fmtcls1 , fmtcls2 ):
531+ def test_read_identifier (self , tmp_path , registry , fmtcls1 , fmtcls2 ):
532532 fmt1 , cls = fmtcls1
533533 fmt2 , _ = fmtcls2
534534
@@ -543,15 +543,15 @@ def test_read_identifier(self, tmpdir, registry, fmtcls1, fmtcls2):
543543 # the reader. The registry.get_reader will fail but the error message
544544 # will tell us if the identifier worked.
545545
546- filename = tmpdir . join ( "testfile.a" ). strpath
546+ filename = tmp_path / "testfile.a"
547547 open (filename , "w" ).close ()
548548 with pytest .raises (IORegistryError ) as exc :
549549 cls .read (filename , registry = registry )
550550 assert str (exc .value ).startswith (
551551 f"No reader defined for format '{ fmt1 } ' and class '{ cls .__name__ } '"
552552 )
553553
554- filename = tmpdir . join ( "testfile.b" ). strpath
554+ filename = tmp_path / "testfile.b"
555555 open (filename , "w" ).close ()
556556 with pytest .raises (IORegistryError ) as exc :
557557 cls .read (filename , registry = registry )
@@ -571,7 +571,7 @@ def test_read_non_existing_unknown_ext(self, fmtcls1):
571571 with pytest .raises (OSError ):
572572 data = fmtcls1 [1 ].read ("non-existing-file-with-unknown.ext" )
573573
574- def test_read_directory (self , tmpdir , registry , fmtcls1 ):
574+ def test_read_directory (self , tmp_path , registry , fmtcls1 ):
575575 """
576576 Regression test for a bug that caused the I/O registry infrastructure to
577577 not work correctly for datasets that are represented by folders as
@@ -583,7 +583,7 @@ def test_read_directory(self, tmpdir, registry, fmtcls1):
583583 )
584584 registry .register_reader ("test_folder_format" , cls , empty_reader )
585585
586- filename = tmpdir . mkdir ( "folder_dataset" ).strpath
586+ ( filename := tmp_path / "folder_dataset" ).mkdir ()
587587
588588 # With the format explicitly specified
589589 dataset = cls .read (filename , format = "test_folder_format" , registry = registry )
@@ -839,10 +839,10 @@ def test_write_noformat_arbitrary(self, registry, original, fmtcls1):
839839 "please provide a 'format' argument."
840840 )
841841
842- def test_write_noformat_arbitrary_file (self , tmpdir , registry , original ):
842+ def test_write_noformat_arbitrary_file (self , tmp_path , registry , original ):
843843 """Tests that all identifier functions can accept arbitrary files"""
844844 registry ._writers .update (original ["writers" ])
845- testfile = str ( tmpdir . join ( "foo.example" ))
845+ testfile = tmp_path / "foo.example"
846846
847847 with pytest .raises (IORegistryError ) as exc :
848848 Table ().write (testfile , registry = registry )
@@ -1116,7 +1116,7 @@ class MyTable(Table):
11161116 mt .write (buffer , format = "ascii" )
11171117 assert buffer .getvalue () == os .linesep .join (["a b" , "1 2" , "" ])
11181118
1119- def test_read_table_subclass_with_columns_attributes (self , tmpdir ):
1119+ def test_read_table_subclass_with_columns_attributes (self , tmp_path ):
11201120 """Regression test for https://github.com/astropy/astropy/issues/7181"""
11211121
11221122 class MTable (Table ):
@@ -1127,7 +1127,7 @@ class MTable(Table):
11271127 mt ["a" ].format = ".4f"
11281128 mt ["a" ].description = "hello"
11291129
1130- testfile = str ( tmpdir . join ( "junk.fits" ))
1130+ testfile = tmp_path / "junk.fits"
11311131 mt .write (testfile , overwrite = True )
11321132
11331133 t = MTable .read (testfile )
0 commit comments