-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtest_pretty_print.py
46 lines (40 loc) · 1.61 KB
/
test_pretty_print.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
import logging
import textwrap
from dbt_semantic_interfaces.pretty_print import pformat_big_objects, pretty_format
from dbt_semantic_interfaces.test_utils import default_meta
logger = logging.getLogger(__name__)
def test_pretty_print() -> None: # noqa: D
assert pretty_format("foo") == "foo"
assert pretty_format(1) == "1"
assert pretty_format(0.1) == "0.1"
assert pretty_format(["bar", "baz"]) == "['bar', 'baz']"
assert pretty_format(("bar", "baz")) == "('bar', 'baz')"
assert pretty_format({"foo": 1}) == "{'foo': 1}"
def test_pformat_big_objects() -> None: # noqa: D
meta = default_meta()
assert pformat_big_objects(meta) == (
textwrap.dedent(
"""\
{'class': 'PydanticMetadata',
'repo_file_path': '/not/from/a/repo',
'file_slice': {'filename': 'not_from_file.py',
'content': 'N/A',
'start_line_number': 0,
'end_line_number': 0}}
"""
).rstrip()
)
logger.error(f"Output:\n{pformat_big_objects(meta=meta)}")
assert pformat_big_objects(meta=meta) == (
textwrap.dedent(
"""\
meta:
{'class': 'PydanticMetadata',
'repo_file_path': '/not/from/a/repo',
'file_slice': {'filename': 'not_from_file.py',
'content': 'N/A',
'start_line_number': 0,
'end_line_number': 0}}
"""
).rstrip()
)