Skip to content

Commit 569e131

Browse files
BoboTiGbbc2
authored andcommitted
Fix ResourceWarning: unclosed file in setup.py and test_cli.py
Signed-off-by: Mickaël Schoentgen <[email protected]>
1 parent 98e4eee commit 569e131

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
long_description = f.read()
1515

1616
meta = {}
17-
exec(open('./dotenv/version.py').read(), meta)
17+
with open('./dotenv/version.py') as f:
18+
exec(f.read(), meta)
1819

1920
setup(
2021
name="python-dotenv",

tests/test_cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ def test_get_key_with_interpolation(dotenv_file):
199199
dotenv.set_key(dotenv_file, 'FOO', '${HELLO}')
200200
dotenv.set_key(dotenv_file, 'BAR', 'CONCATENATED_${HELLO}_POSIX_VAR')
201201

202-
lines = list(open(dotenv_file, "r").readlines())
202+
with open(dotenv_file) as f:
203+
lines = f.readlines()
203204
assert lines == [
204205
'HELLO="WORLD"\n',
205206
'FOO="${HELLO}"\n',

0 commit comments

Comments
 (0)