forked from genewildish/Mainline
36 lines
1019 B
Python
36 lines
1019 B
Python
import re
|
|
|
|
from engine.fetch_code import fetch_code
|
|
|
|
|
|
def test_return_shape():
|
|
items, line_count, ignored = fetch_code()
|
|
assert isinstance(items, list)
|
|
assert line_count == len(items)
|
|
assert ignored == 0
|
|
|
|
|
|
def test_items_are_tuples():
|
|
items, _, _ = fetch_code()
|
|
assert items, "expected at least one code line"
|
|
for item in items:
|
|
assert isinstance(item, tuple) and len(item) == 3
|
|
text, src, ts = item
|
|
assert isinstance(text, str)
|
|
assert isinstance(src, str)
|
|
assert isinstance(ts, str)
|
|
|
|
|
|
def test_blank_and_comment_lines_excluded():
|
|
items, _, _ = fetch_code()
|
|
for text, _, _ in items:
|
|
assert text.strip(), "blank line should have been filtered"
|
|
assert not text.strip().startswith("#"), "comment line should have been filtered"
|
|
|
|
|
|
def test_module_path_format():
|
|
items, _, _ = fetch_code()
|
|
pattern = re.compile(r"^engine\.\w+$")
|
|
for _, _, ts in items:
|
|
assert pattern.match(ts), f"unexpected module path: {ts!r}"
|