Solved unclosed file <_io.TextIOWrapper warnings

This commit is contained in:
2025-07-16 14:33:10 +02:00
parent e4ce3848fc
commit dea2669de2
3 changed files with 12 additions and 4 deletions

View File

@@ -88,7 +88,8 @@ class TestCreateDockerRoleCLI(unittest.TestCase):
data['ports']['localhost']['http']['app2'] = 8001
dump_yaml_with_comments(data, self.ports_file)
# Check comment and new entry
text = open(self.ports_file).read()
with open(self.ports_file) as f:
text = f.read()
self.assertIn('# existing port', text)
self.assertIn('app2: 8001', text)
@@ -128,7 +129,8 @@ class TestCreateDockerRoleCLI(unittest.TestCase):
f.write('Line1\n')
builtins.input = lambda _: '3'
render_templates(src, dst, {})
content = open(out_file).read().splitlines()
with open(out_file) as f:
content = f.read().splitlines()
self.assertIn('Line1', content)
self.assertIn('Line2', content)
builtins.input = original_input