summaryrefslogtreecommitdiff
path: root/tests/test_cli.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_cli.py')
-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