Skip to content

Commit ef3e419

Browse files
committed
Fix a resource leak.
1 parent be7cb49 commit ef3e419

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

jsonschema/tests/test_jsonschema_test_suite.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
"""
99

10+
from contextlib import closing
1011
from decimal import Decimal
1112
import glob
1213
import json
@@ -44,12 +45,14 @@
4445
TESTS_DIR = os.path.join(SUITE, "tests")
4546
JSONSCHEMA_SUITE = os.path.join(SUITE, "bin", "jsonschema_suite")
4647

47-
REMOTES = subprocess.Popen(
48+
remotes_stdout = subprocess.Popen(
4849
["python", JSONSCHEMA_SUITE, "remotes"], stdout=subprocess.PIPE,
4950
).stdout
50-
if PY3:
51-
REMOTES = io.TextIOWrapper(REMOTES)
52-
REMOTES = json.load(REMOTES)
51+
52+
with closing(remotes_stdout):
53+
if PY3:
54+
remotes_stdout = io.TextIOWrapper(remotes_stdout)
55+
REMOTES = json.load(remotes_stdout)
5356

5457

5558
def make_case(schema, data, valid, name):

0 commit comments

Comments
 (0)