-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_init.py
61 lines (46 loc) · 1.92 KB
/
test_init.py
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
import pytest
# ---------------------------------------------------------------------------
def test_init_imports():
import cql
import cql.lexer
import cql.parser
# assert cql.parser.CQLParser == cql.CQLParser
assert cql.parser.CQLParser11 == cql.CQLParser11
assert cql.parser.CQLParser12 == cql.CQLParser12
assert cql.lexer.CQLLexer == cql.CQLLexer
def test_init_parse():
import cql
parsed = cql.parse("dc.title any fish or dc.creator any sanderson")
assert parsed is not None
assert parsed.version == "1.2"
def test_init_parse_debug(caplog: pytest.LogCaptureFixture):
import logging
import cql
with caplog.at_level(logging.INFO, "CQLLexer"):
_ = cql.parse(
"dc.title any fish or dc.creator any sanderson", debug_show_lexerinfo=True
)
assert all(record.name == "CQLLexer" for record in caplog.records)
assert all(record.funcName == "lex" for record in caplog.records)
caplog.clear()
with caplog.at_level(logging.DEBUG, "CQLParser"):
_ = cql.parse(
"dc.title any fish or dc.creator any sanderson", debug_show_parserinfo=True
)
assert all(record.name == "CQLParser" for record in caplog.records)
assert {record.funcName for record in caplog.records} == {"yacc", "lr_parse_table"}
assert {record.levelname for record in caplog.records} == {
"INFO",
"DEBUG",
"WARNING",
}
caplog.clear()
with caplog.at_level(logging.DEBUG, "CQLParserSteps"):
_ = cql.parse(
"dc.title any fish or dc.creator any sanderson", debug_parsing=True
)
assert all(record.name == "CQLParserSteps" for record in caplog.records)
assert {record.funcName for record in caplog.records} == {"parse"}
assert {record.levelname for record in caplog.records} == {"INFO", "DEBUG"}
caplog.clear()
# ---------------------------------------------------------------------------