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

13 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-06 10:20 +0000

1"""Test for the "apio test" command.""" 

2 

3from tests.conftest import ApioRunner 

4from apio.commands.apio import apio_top_cli as apio 

5 

6 

7def test_test(apio_runner: ApioRunner): 

8 """Test: apio test 

9 when no apio.ini file is given 

10 No additional parameters are given 

11 """ 

12 

13 with apio_runner.in_sandbox() as sb: 

14 

15 # -- Execute "apio test" 

16 result = sb.invoke_apio_cmd(apio, ["test"]) 

17 assert result.exit_code != 0, result.output 

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

19 

20 

21def test_with_env_arg_error(apio_runner: ApioRunner): 

22 """Tests the command with an invalid --env value. This error message 

23 confirms that the --env arg was propagated to the apio.ini loading 

24 logic.""" 

25 

26 with apio_runner.in_sandbox() as sb: 

27 

28 # -- Run "apio test --env no-such-env" 

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

30 result = sb.invoke_apio_cmd(apio, ["test", "--env", "no-such-env"]) 

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

32 assert ( 

33 "Error: Env 'no-such-env' not found in apio.ini" in result.output 

34 )