expose mock executing to python library; (#6980)

* expose mock executing to python library;

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* bump

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* Update rust/kcl-python-bindings/src/lib.rs

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
This commit is contained in:
Jess Frazelle
2025-05-15 12:35:29 -07:00
committed by GitHub
parent d93a57d7bf
commit e489222b6a
17 changed files with 130 additions and 45 deletions

View File

@ -68,6 +68,35 @@ async def test_kcl_parse_code():
assert result is True
@pytest.mark.asyncio
async def test_kcl_mock_execute_with_exception():
# Read from a file.
try:
await kcl.mock_execute(os.path.join(files_dir, "parse_file_error"))
except Exception as e:
assert e is not None
assert len(str(e)) > 0
assert "lksjndflsskjfnak;jfna##" in str(e)
@pytest.mark.asyncio
async def test_kcl_mock_execute():
# Read from a file.
result = await kcl.mock_execute(lego_file)
assert result is True
@pytest.mark.asyncio
async def test_kcl_mock_execute_code():
# Read from a file.
with open(lego_file, "r") as f:
code = str(f.read())
assert code is not None
assert len(code) > 0
result = await kcl.mock_execute_code(code)
assert result is True
@pytest.mark.asyncio
async def test_kcl_execute_code():
# Read from a file.