@@ -807,12 +807,7 @@ def test_closefd_attr(self):
807807 def test_garbage_collection (self ):
808808 # FileIO objects are collected, and collecting them flushes
809809 # all data to disk.
810- #
811- # Note that using warnings_helper.check_warnings() will keep the
812- # file alive due to the `source` argument to warn(). So, use
813- # catch_warnings() instead.
814- with warnings .catch_warnings ():
815- warnings .simplefilter ("ignore" , ResourceWarning )
810+ with warnings_helper .check_warnings (('' , ResourceWarning )):
816811 f = self .FileIO (os_helper .TESTFN , "wb" )
817812 f .write (b"abcxxx" )
818813 f .f = f
@@ -1813,11 +1808,7 @@ def test_garbage_collection(self):
18131808 # C BufferedReader objects are collected.
18141809 # The Python version has __del__, so it ends into gc.garbage instead
18151810 self .addCleanup (os_helper .unlink , os_helper .TESTFN )
1816- # Note that using warnings_helper.check_warnings() will keep the
1817- # file alive due to the `source` argument to warn(). So, use
1818- # catch_warnings() instead.
1819- with warnings .catch_warnings ():
1820- warnings .simplefilter ("ignore" , ResourceWarning )
1811+ with warnings_helper .check_warnings (('' , ResourceWarning )):
18211812 rawio = self .FileIO (os_helper .TESTFN , "w+b" )
18221813 f = self .tp (rawio )
18231814 f .f = f
@@ -2166,11 +2157,7 @@ def test_garbage_collection(self):
21662157 # all data to disk.
21672158 # The Python version has __del__, so it ends into gc.garbage instead
21682159 self .addCleanup (os_helper .unlink , os_helper .TESTFN )
2169- # Note that using warnings_helper.check_warnings() will keep the
2170- # file alive due to the `source` argument to warn(). So, use
2171- # catch_warnings() instead.
2172- with warnings .catch_warnings ():
2173- warnings .simplefilter ("ignore" , ResourceWarning )
2160+ with warnings_helper .check_warnings (('' , ResourceWarning )):
21742161 rawio = self .FileIO (os_helper .TESTFN , "w+b" )
21752162 f = self .tp (rawio )
21762163 f .write (b"123xxx" )
@@ -4092,8 +4079,7 @@ def test_garbage_collection(self):
40924079 # C TextIOWrapper objects are collected, and collecting them flushes
40934080 # all data to disk.
40944081 # The Python version has __del__, so it ends in gc.garbage instead.
4095- with warnings .catch_warnings ():
4096- warnings .simplefilter ("ignore" , ResourceWarning )
4082+ with warnings_helper .check_warnings (('' , ResourceWarning )):
40974083 rawio = self .FileIO (os_helper .TESTFN , "wb" )
40984084 b = self .BufferedWriter (rawio )
40994085 t = self .TextIOWrapper (b , encoding = "ascii" )
0 commit comments