from __future__ import absolute_import, division, print_function, unicode_literals import pytest from lsql.main import main BASE_DIR = pytest.get_fixture_dir(b'base') NON_ASCII_PATHS_DIR = pytest.get_fixture_dir('non-ascii-paths') # We don't check results (they're checked in test_new_lsql.py). # We just want to check that lsql.main:main never throws exception (even when query is bad). @pytest.mark.parametrize( 'query', [ # empty query is legal '', 'select 1', "select fullpath || 'oops' where size > 0kb and ext != 'py'", 'select name group by name', ]) def test_good_select(query): assert run_query(query) == 0 @pytest.mark.parametrize( 'query', [ # CantTokenizeError: unclosed string literal "select 'text",
def test_non_ascii_paths(query, expected_results): assert_same_items(get_results(query, directory=pytest.get_fixture_dir("non-ascii-paths")), expected_results)
# coding: utf-8 from __future__ import absolute_import, division, print_function, unicode_literals # TODO(aershov182): when done, replace test_lsql with this file import pytest from lsql import ast from lsql import main from lsql import parser BASE_DIR = pytest.get_fixture_dir("base") def idfn(val): if isinstance(val, unicode): return val.encode("utf-8") # TODO(aershov182): remove assert_same_items/get_results duplication in tests def test_select_name(): assert_same_items(get_results("select name"), [("small",), ("LICENSE",), ("README.md",), ("small.py",)]) @pytest.mark.parametrize( "select, result", [ ("1", 1), ("1.3", 1.3),
from __future__ import absolute_import, division, print_function, unicode_literals import pytest from lsql.main import main BASE_DIR = pytest.get_fixture_dir(b'base') NON_ASCII_PATHS_DIR = pytest.get_fixture_dir('non-ascii-paths') # We don't check results (they're checked in test_new_lsql.py). # We just want to check that lsql.main:main never throws exception (even when query is bad). @pytest.mark.parametrize('query', [ # empty query is legal '', 'select 1', "select fullpath || 'oops' where size > 0kb and ext != 'py'", 'select name group by name', ]) def test_good_select(query): assert run_query(query) == 0 @pytest.mark.parametrize('query', [ # CantTokenizeError: unclosed string literal "select 'text", # CantTokenizeError: other "select `", # UnknownLiteralSuffixError "select 1unknown",
def test_non_ascii_paths(query, expected_results): assert_same_items( get_results(query, directory=pytest.get_fixture_dir('non-ascii-paths')), expected_results )
# coding: utf-8 from __future__ import absolute_import, division, print_function, unicode_literals # TODO(aershov182): when done, replace test_lsql with this file import pytest from lsql import ast from lsql import main from lsql import parser BASE_DIR = pytest.get_fixture_dir('base') def idfn(val): if isinstance(val, unicode): return val.encode('utf-8') # TODO(aershov182): remove assert_same_items/get_results duplication in tests def test_select_name(): assert_same_items( get_results('select name'), [ ('small',), ('LICENSE',), ('README.md',), ('small.py',), ] )