Coverage for tests/unit_tests/commands/test_apio_format.py: 100%
13 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-07 05:08 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-07 05:08 +0000
1# This file is part of the Apio project
2# (C) 2016-present FPGAwars
3# Project authors:
4# * Jesús Arroyo (Jesus89) (2016-2019)
5# * Juan Gonzalez (obijuan) (2019-2024)
6# * The Apio Team (2024-present)
7# License: GPLv2
9"""Test for the "apio format" command."""
11from tests.conftest import ApioRunner
12from apio.commands.apio import apio_top_cli as apio
15def test_format_without_apio_ini(apio_runner: ApioRunner):
16 """Tests the apio format command with a missing apio.ini file."""
18 with apio_runner.in_sandbox() as sb:
20 # -- Run "apio format" with no apio.ini
21 result = sb.invoke_apio_cmd(apio, ["format"])
22 assert result.exit_code != 0, result.output
23 assert "Error: Missing project file apio.ini" in result.output
26def test_format_with_env_arg_error(apio_runner: ApioRunner):
27 """Tests the command with an invalid --env value. This error message
28 confirms that the --env arg was propagated to the apio.ini loading
29 logic."""
31 with apio_runner.in_sandbox() as sb:
33 # -- Run "apio format --env no-such-env"
34 sb.write_apio_ini({"[env:default]": {"top-module": "main"}})
35 result = sb.invoke_apio_cmd(apio, ["format", "--env", "no-such-env"])
36 assert result.exit_code == 1, result.output
37 assert (
38 "Error: Env 'no-such-env' not found in apio.ini" in result.output
39 )