summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2017-11-21 11:34:34 +0100
committerGitHub <noreply@github.com>2017-11-21 11:34:34 +0100
commit8d3c45f46efa6165d67eb4580cc152e8b2402f1d (patch)
tree48a8f6022b722d9f23ed0c483d5f0ebf14c0d085 /tests
parentf8825153da66289c021252f0b221c16302224a86 (diff)
parentacaf00cbaf32e7a14e39bcc0a5fd774a5385faa0 (diff)
downloadsqlparse-8d3c45f46efa6165d67eb4580cc152e8b2402f1d.tar.gz
Merge pull request #365 from jdufresne/unclosed
Fix unclosed file warnings discovered during tests
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cli.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 18c6fcb..485afd3 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -115,9 +115,10 @@ def test_encoding_stdin_utf8(filepath, load_file, capfd):
path = filepath('encoding_utf8.sql')
expected = load_file('encoding_utf8.sql', 'utf-8')
old_stdin = sys.stdin
- sys.stdin = open(path, 'r')
- sys.stdout.encoding = 'utf-8'
- sqlparse.cli.main(['-'])
+ with open(path, 'r') as f:
+ sys.stdin = f
+ sys.stdout.encoding = 'utf-8'
+ sqlparse.cli.main(['-'])
sys.stdin = old_stdin
out, _ = capfd.readouterr()
assert out == expected