1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
# fmt: off
import pytest
import subprocess
import sys
from typing import List
from conftest import ShellTest
import os
from pathlib import Path
@pytest.mark.parametrize("dot_command", [
".mode box",
""
])
def test_left_align(shell, dot_command):
args = ['-box'] if len(dot_command) == 0 else []
test = (
ShellTest(shell, args)
.statement(dot_command)
.statement(".width 5")
.statement(f'select 100 AS r')
)
result = test.run()
result.check_stdout("│ 100 │")
def test_right_align(shell):
test = (
ShellTest(shell)
.statement(".mode box")
.statement(".width -5")
.statement(f'select 100 AS r')
)
result = test.run()
result.check_stdout("│ 100 │")
@pytest.mark.parametrize("dot_command", [
".mode markdown",
""
])
def test_markdown(shell, dot_command):
args = ['-markdown'] if len(dot_command) == 0 else []
test = (
ShellTest(shell, args)
.statement(dot_command)
.statement("select 42 a, 'hello' str")
)
result = test.run()
result.check_stdout("| a | str |")
def test_mode_insert_table(shell):
test = (
ShellTest(shell)
.statement(".mode box mytable")
)
result = test.run()
result.check_stderr("TABLE argument can only be used with .mode insert")
def test_mode_box_newline(shell):
test = (
ShellTest(shell)
.statement(".mode box")
.statement("select '\n' c;")
)
result = test.run()
result.check_stdout("\\n")
def test_mode_markdown_pipe(shell):
test = (
ShellTest(shell)
.statement(".mode markdown")
.statement("select 'val || other_val' c;")
)
result = test.run()
result.check_stdout("\\|\\|")
def test_mode_json_null(shell):
test = (
ShellTest(shell)
.statement(".mode json")
.statement("select NULL as my_val;")
)
result = test.run()
result.check_stdout("null")
def test_mode_json_escapes(shell):
test = (
ShellTest(shell)
.statement(".mode jsonlines")
.statement("select 'test' as name, [4, 5, 6] a, {'key': 7} s;")
)
result = test.run()
result.check_stdout('{"name":"test","a":[4,5,6],"s":{"key":7}}')
|