mirror of
https://github.com/apache/impala.git
synced 2025-12-19 18:12:08 -05:00
Upgrades the impala-shell's bundled version of sqlparse to 0.3.1. There were some API changes in 0.2.0+ that required a re-write of the StripLeadingCommentFilter in impala_shell.py. A slight perf optimization was also added to avoid using the filter altogether if no leading comment is readily discernible. As 0.1.19 was the last version of sqlparse to support python 2.6, this patch also breaks Impala's compatibility with python 2.6. No new tests were added, but all existing tests passed without modification. Change-Id: I77a1fd5ae311634a18ee04b8c389d8a3f3a6e001 Reviewed-on: http://gerrit.cloudera.org:8080/15642 Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
"""Helpers for testing."""
|
|
|
|
import io
|
|
import os
|
|
|
|
import pytest
|
|
|
|
DIR_PATH = os.path.dirname(__file__)
|
|
FILES_DIR = os.path.join(DIR_PATH, 'files')
|
|
|
|
|
|
@pytest.fixture()
|
|
def filepath():
|
|
"""Returns full file path for test files."""
|
|
|
|
def make_filepath(filename):
|
|
# https://stackoverflow.com/questions/18011902/py-test-pass-a-parameter-to-a-fixture-function
|
|
# Alternate solution is to use parametrization `indirect=True`
|
|
# https://stackoverflow.com/questions/18011902/py-test-pass-a-parameter-to-a-fixture-function/33879151#33879151
|
|
# Syntax is noisy and requires specific variable names
|
|
return os.path.join(FILES_DIR, filename)
|
|
|
|
return make_filepath
|
|
|
|
|
|
@pytest.fixture()
|
|
def load_file(filepath):
|
|
"""Opens filename with encoding and return its contents."""
|
|
|
|
def make_load_file(filename, encoding='utf-8'):
|
|
# https://stackoverflow.com/questions/18011902/py-test-pass-a-parameter-to-a-fixture-function
|
|
# Alternate solution is to use parametrization `indirect=True`
|
|
# https://stackoverflow.com/questions/18011902/py-test-pass-a-parameter-to-a-fixture-function/33879151#33879151
|
|
# Syntax is noisy and requires specific variable names
|
|
# And seems to be limited to only 1 argument.
|
|
with io.open(filepath(filename), encoding=encoding) as f:
|
|
return f.read().strip()
|
|
|
|
return make_load_file
|
|
|
|
|
|
@pytest.fixture()
|
|
def get_stream(filepath):
|
|
def make_stream(filename, encoding='utf-8'):
|
|
return io.open(filepath(filename), encoding=encoding)
|
|
|
|
return make_stream
|