mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-22831: Use "with" to avoid possible fd leaks in tests (part 2). (GH-10929)
This commit is contained in:
parent
9e4861f523
commit
5b10b98247
25 changed files with 253 additions and 312 deletions
|
@ -238,9 +238,8 @@ class RunModuleTestCase(unittest.TestCase, CodeExecutionMixin):
|
|||
if verbose > 1: print(" Next level in:", sub_dir)
|
||||
if verbose > 1: print(" Created:", pkg_fname)
|
||||
mod_fname = os.path.join(sub_dir, test_fname)
|
||||
mod_file = open(mod_fname, "w")
|
||||
mod_file.write(source)
|
||||
mod_file.close()
|
||||
with open(mod_fname, "w") as mod_file:
|
||||
mod_file.write(source)
|
||||
if verbose > 1: print(" Created:", mod_fname)
|
||||
mod_name = (pkg_name+".")*depth + mod_base
|
||||
mod_spec = importlib.util.spec_from_file_location(mod_name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue