-
Notifications
You must be signed in to change notification settings - Fork 591
Expand file tree
/
Copy pathtest_trailing_comments.py
More file actions
56 lines (40 loc) · 1.71 KB
/
test_trailing_comments.py
File metadata and controls
56 lines (40 loc) · 1.71 KB
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
"""Tests for SQL trailing comment handling.
Verifies that statements with comments after the semicolon are handled
correctly in both the input buffer (pgbuffer) and query execution (pgexecute).
"""
import pytest
from pgcli.pgbuffer import _is_complete
class TestIsCompleteWithTrailingComments:
"""Test _is_complete() handles trailing SQL comments after semicolons."""
def test_simple_semicolon(self):
assert _is_complete("SELECT 1;") is True
def test_no_semicolon(self):
assert _is_complete("SELECT 1") is False
def test_trailing_single_line_comment(self):
assert _is_complete("SELECT 1; -- a comment") is True
def test_trailing_block_comment(self):
assert _is_complete("SELECT 1; /* block comment */") is True
def test_vacuum_with_comment(self):
assert (
_is_complete(
"vacuum freeze verbose tpd.file_delivery; -- 82% towards emergency"
)
is True
)
def test_comment_only(self):
assert _is_complete("-- just a comment") is False
def test_semicolon_inside_string(self):
assert _is_complete("SELECT ';'") is False
def test_semicolon_inside_string_with_trailing_comment(self):
assert _is_complete("SELECT ';' FROM t; -- note") is True
def test_open_quote(self):
assert _is_complete("SELECT '") is False
def test_empty_string(self):
assert _is_complete("") is False
def test_multiple_semicolons_with_comment(self):
assert _is_complete("SELECT 1; SELECT 2; -- done") is True
def test_comment_with_special_chars(self):
assert (
_is_complete("VACUUM ANALYZE; -- 81.0% towards emergency, 971 MB")
is True
)