Coverage for tests/unit_tests/commands/test_apio_lint.py: 100%

13 statements  

« 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 

8 

9"""Test for the "apio lint" command.""" 

10 

11from tests.conftest import ApioRunner 

12from apio.commands.apio import apio_top_cli as apio 

13 

14 

15def test_lint_no_apio_ini(apio_runner: ApioRunner): 

16 """Test: apio lint without an apio.ini project file.""" 

17 

18 with apio_runner.in_sandbox() as sb: 

19 

20 # -- Execute "apio lint" 

21 result = sb.invoke_apio_cmd(apio, ["lint"]) 

22 assert result.exit_code == 1, result.output 

23 assert "Error: Missing project file apio.ini" in result.output 

24 

25 

26def test_lint_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.""" 

30 

31 with apio_runner.in_sandbox() as sb: 

32 

33 # -- Run "apio lint --env no-such-env" 

34 sb.write_apio_ini({"[env:default]": {"top-module": "main"}}) 

35 result = sb.invoke_apio_cmd(apio, ["lint", "--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 )