提交 e1c7e2fe 编写于 作者: J Jacob Champion 提交者: Mark Sliva

gpconfig: add UTF-8 test case

application_name explicitly filters non-ASCII bytes, so we went with
search_path.

We had to work around some ASCII/Unicode mixing in the tests, which will
probably come back to haunt us during the Python 3 move.
Co-authored-by: NMark Sliva <msliva@pivotal.io>
上级 cd80aa25
......@@ -78,6 +78,7 @@ Feature: gpconfig integration tests
| application_name | string | zzzzzz | '' | '' | | '' | '' | '' | '' | |
| application_name | string | boo | "\'" | '\\''' | \' | "\'" | '\\''' | "\'" | '\\''' | \' |
| application_name | string | boo | "''''" | '''''''''' | '''' | "''" | '''''' | "'" | '''' | ' |
| search_path | string | boo | Ομήρου | 'Ομήρου' | Ομήρου | Ομήρου | 'Ομήρου' | Ομήρου | 'Ομήρου' | Ομήρου |
@concourse_cluster
@demo_cluster
......
import codecs
import math
import fnmatch
import getpass
......@@ -1325,9 +1326,11 @@ def impl(context, filename, output):
def find_string_in_master_data_directory(context, filename, output, escapeStr=False):
contents = ''
file_path = os.path.join(master_data_dir, filename)
with open(file_path) as fr:
for line in fr:
with codecs.open(file_path, encoding='utf-8') as f:
for line in f:
contents = line.strip()
if escapeStr:
output = re.escape(output)
pat = re.compile(output)
......@@ -1419,7 +1422,9 @@ def impl(context, filename, output):
cmd_str = 'ssh %s "tail -n1 %s"' % (host, filepath)
cmd = Command(name='Running remote command: %s' % cmd_str, cmdStr=cmd_str)
cmd.run(validateAfter=True)
if output not in cmd.get_stdout():
actual = cmd.get_stdout().decode('utf-8')
if output not in actual:
raise Exception('File %s on host %s does not contain "%s"' % (filepath, host, output))
@given('the gpfdists occupying port {port} on host "{hostfile}"')
......
......@@ -129,8 +129,13 @@ def check_stdout_msg(context, msg, escapeStr = False):
if escapeStr:
msg = re.escape(msg)
pat = re.compile(msg)
if not pat.search(context.stdout_message):
err_str = "Expected stdout string '%s' and found: '%s'" % (msg, context.stdout_message)
actual = context.stdout_message
if isinstance(msg, unicode):
actual = actual.decode('utf-8')
if not pat.search(actual):
err_str = "Expected stdout string '%s' and found: '%s'" % (msg, actual)
raise Exception(err_str)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册