Skip to content

Commit 6cd00ee

Browse files
committed
Use with-statement to flush test key-file.
1 parent 26baeaf commit 6cd00ee

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

test/high_availability/ha_tools.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,8 @@ def start_replica_set(members, auth=False, fresh=True):
121121
if auth:
122122
key_file = os.path.join(dbpath, 'key.txt')
123123
if not os.path.exists(key_file):
124-
f = open(key_file, 'w')
125-
try:
124+
with open(key_file, 'w') as f:
126125
f.write("my super secret system password")
127-
finally:
128-
f.close()
129126
os.chmod(key_file, S_IRUSR)
130127

131128
for i in range(len(members)):

0 commit comments

Comments
 (0)