forked from pool/python-sqlparse
- Add stdout-encoding-set.patch to use sys.stdout.reconfigure() if
the stream is an instance of TextIOWrapper to support a pytest change. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-sqlparse?expand=0&rev=20
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Mar 23 06:35:19 UTC 2020 - Steve Kowalik <steven.kowalik@suse.com>
|
Tue Mar 24 02:45:39 UTC 2020 - Steve Kowalik <steven.kowalik@suse.com>
|
||||||
|
|
||||||
- Add stdout-encoding-set.patch to use sys.stdout.reconfigure() for Python 3.
|
- Add stdout-encoding-set.patch to use sys.stdout.reconfigure() if
|
||||||
|
the stream is an instance of TextIOWrapper to support a pytest change.
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Mar 9 16:22:39 UTC 2020 - Dirk Mueller <dmueller@suse.com>
|
Mon Mar 9 16:22:39 UTC 2020 - Dirk Mueller <dmueller@suse.com>
|
||||||
|
@@ -2,48 +2,55 @@ Index: sqlparse-0.3.1/tests/test_cli.py
|
|||||||
===================================================================
|
===================================================================
|
||||||
--- sqlparse-0.3.1.orig/tests/test_cli.py
|
--- sqlparse-0.3.1.orig/tests/test_cli.py
|
||||||
+++ sqlparse-0.3.1/tests/test_cli.py
|
+++ sqlparse-0.3.1/tests/test_cli.py
|
||||||
@@ -78,7 +78,10 @@ def test_script():
|
@@ -1,5 +1,6 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
+import io
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
@@ -78,7 +79,10 @@ def test_script():
|
||||||
def test_encoding_utf8_stdout(filepath, load_file, capfd):
|
def test_encoding_utf8_stdout(filepath, load_file, capfd):
|
||||||
path = filepath('encoding_utf8.sql')
|
path = filepath('encoding_utf8.sql')
|
||||||
expected = load_file('encoding_utf8.sql', 'utf-8')
|
expected = load_file('encoding_utf8.sql', 'utf-8')
|
||||||
- sys.stdout.encoding = 'utf-8'
|
- sys.stdout.encoding = 'utf-8'
|
||||||
+ if sys.hexversion >= 0x3070000:
|
+ if isinstance(sys.stdout, io.TextIOWrapper):
|
||||||
+ sys.stdout.reconfigure(encoding='utf-8')
|
+ sys.stdout.reconfigure(encoding='utf-8')
|
||||||
+ else:
|
+ else:
|
||||||
+ sys.stdout.encoding = 'utf-8'
|
+ sys.stdout.encoding = 'utf-8'
|
||||||
sqlparse.cli.main([path])
|
sqlparse.cli.main([path])
|
||||||
out, _ = capfd.readouterr()
|
out, _ = capfd.readouterr()
|
||||||
assert out == expected
|
assert out == expected
|
||||||
@@ -96,7 +99,10 @@ def test_encoding_utf8_output_file(filep
|
@@ -96,7 +100,10 @@ def test_encoding_utf8_output_file(filep
|
||||||
def test_encoding_gbk_stdout(filepath, load_file, capfd):
|
def test_encoding_gbk_stdout(filepath, load_file, capfd):
|
||||||
path = filepath('encoding_gbk.sql')
|
path = filepath('encoding_gbk.sql')
|
||||||
expected = load_file('encoding_gbk.sql', 'gbk')
|
expected = load_file('encoding_gbk.sql', 'gbk')
|
||||||
- sys.stdout.encoding = 'gbk'
|
- sys.stdout.encoding = 'gbk'
|
||||||
+ if sys.hexversion >= 0x3070000:
|
+ if isinstance(sys.stdout, io.TextIOWrapper):
|
||||||
+ sys.stdout.reconfigure(encoding='gbk')
|
+ sys.stdout.reconfigure(encoding='gbk')
|
||||||
+ else:
|
+ else:
|
||||||
+ sys.stdout.encoding = 'gbk'
|
+ sys.stdout.encoding = 'gbk'
|
||||||
sqlparse.cli.main([path, '--encoding', 'gbk'])
|
sqlparse.cli.main([path, '--encoding', 'gbk'])
|
||||||
out, _ = capfd.readouterr()
|
out, _ = capfd.readouterr()
|
||||||
assert out == expected
|
assert out == expected
|
||||||
@@ -117,7 +123,10 @@ def test_encoding_stdin_utf8(filepath, l
|
@@ -117,7 +124,10 @@ def test_encoding_stdin_utf8(filepath, l
|
||||||
old_stdin = sys.stdin
|
old_stdin = sys.stdin
|
||||||
with open(path, 'r') as f:
|
with open(path, 'r') as f:
|
||||||
sys.stdin = f
|
sys.stdin = f
|
||||||
- sys.stdout.encoding = 'utf-8'
|
- sys.stdout.encoding = 'utf-8'
|
||||||
+ if sys.hexversion >= 0x3070000:
|
+ if isinstance(sys.stdout, io.TextIOWrapper):
|
||||||
+ sys.stdout.reconfigure(encoding='utf-8')
|
+ sys.stdout.reconfigure(encoding='utf-8')
|
||||||
+ else:
|
+ else:
|
||||||
+ sys.stdout.encoding = 'utf-8'
|
+ sys.stdout.encoding = 'utf-8'
|
||||||
sqlparse.cli.main(['-'])
|
sqlparse.cli.main(['-'])
|
||||||
sys.stdin = old_stdin
|
sys.stdin = old_stdin
|
||||||
out, _ = capfd.readouterr()
|
out, _ = capfd.readouterr()
|
||||||
@@ -130,7 +139,10 @@ def test_encoding_stdin_gbk(filepath, lo
|
@@ -130,7 +140,10 @@ def test_encoding_stdin_gbk(filepath, lo
|
||||||
old_stdin = sys.stdin
|
old_stdin = sys.stdin
|
||||||
with open(path, 'r') as stream:
|
with open(path, 'r') as stream:
|
||||||
sys.stdin = stream
|
sys.stdin = stream
|
||||||
- sys.stdout.encoding = 'gbk'
|
- sys.stdout.encoding = 'gbk'
|
||||||
+ if sys.hexversion >= 0x3070000:
|
+ if isinstance(sys.stdout, io.TextIOWrapper):
|
||||||
+ sys.stdout.reconfigure(encoding='gbk')
|
+ sys.stdout.reconfigure(encoding='gbk')
|
||||||
+ else:
|
+ else:
|
||||||
+ sys.stdout.encoding = 'gbk'
|
+ sys.stdout.encoding = 'gbk'
|
||||||
|
Reference in New Issue
Block a user