def test__linter__path_from_paths__file(): """Test extracting paths from a file path.""" lntr = Linter(config=FluffConfig()) paths = lntr.paths_from_path('test/fixtures/linter/indentation_errors.sql') assert normalise_paths(paths) == { 'test.fixtures.linter.indentation_errors.sql' }
def test__linter__path_from_paths__ignore(path): """Test extracting paths from a dot.""" lntr = Linter(config=FluffConfig()) paths = lntr.paths_from_path(path) # We should only get query_b, because of the sqlfluffignore files. assert normalise_paths(paths) == { 'test.fixtures.linter.sqlfluffignore.path_b.query_b.sql' }
def test__linter__path_from_paths__dir(): """Test extracting paths from directories.""" lntr = Linter(config=FluffConfig()) paths = lntr.paths_from_path('test/fixtures/lexer') assert normalise_paths(paths) == { 'test.fixtures.lexer.block_comment.sql', 'test.fixtures.lexer.inline_comment.sql', 'test.fixtures.lexer.basic.sql' }
def test__linter__path_from_paths_dot(): lntr = Linter() paths = lntr.paths_from_path('.') # Use set theory to check that we get AT LEAST these files assert normalise_paths(paths) >= set([ 'test.fixtures.lexer.block_comment.sql', 'test.fixtures.lexer.inline_comment.sql', 'test.fixtures.lexer.basic.sql' ])
def test__linter__path_from_paths__dir(): lntr = Linter() paths = lntr.paths_from_path('test/fixtures/lexer') # NB This test might fail on Linux or Mac - should probably correct... assert normalise_paths(paths) == set([ 'test.fixtures.lexer.block_comment.sql', 'test.fixtures.lexer.inline_comment.sql', 'test.fixtures.lexer.basic.sql' ])
def test__linter__path_from_paths__dot(): """Test extracting paths from a dot.""" lntr = Linter(config=FluffConfig()) paths = lntr.paths_from_path('.') # Use set theory to check that we get AT LEAST these files assert normalise_paths(paths) >= { 'test.fixtures.lexer.block_comment.sql', 'test.fixtures.lexer.inline_comment.sql', 'test.fixtures.lexer.basic.sql' }
def test__linter__path_from_paths__file(): lntr = Linter() paths = lntr.paths_from_path('test/fixtures/linter/indentation_errors.sql') assert normalise_paths(paths) == set(['test.fixtures.linter.indentation_errors.sql'])
def test__linter__path_from_paths__not_exist_ignore(): """Test extracting paths from a file path.""" lntr = Linter(config=FluffConfig()) paths = lntr.paths_from_path('asflekjfhsakuefhse', ignore_non_existent_files=True) assert len(paths) == 0
def test__linter__path_from_paths__not_exist(): """Test extracting paths from a file path.""" lntr = Linter(config=FluffConfig()) with pytest.raises(IOError): lntr.paths_from_path('asflekjfhsakuefhse')