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

20 statements  

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

1"""Test for the "apio" (root) command.""" 

2 

3from tests.conftest import ApioRunner 

4from apio.commands.apio import apio_top_cli as apio 

5 

6 

7def test_apio_cmd(apio_runner: ApioRunner): 

8 """Test the apio root command.""" 

9 

10 with apio_runner.in_sandbox() as sb: 

11 

12 # -- Run 'apio' 

13 result = sb.invoke_apio_cmd(apio, []) 

14 sb.assert_result_ok(result) 

15 assert "WORK WITH FPGAs WITH EASE." in result.output 

16 assert "Build commands:" in result.output 

17 assert "Upload the bitstream to the FPGA" in result.output 

18 

19 # -- Run 'apio --help' 

20 result = sb.invoke_apio_cmd(apio, ["--help"]) 

21 sb.assert_result_ok(result) 

22 assert "WORK WITH FPGAs WITH EASE." in result.output 

23 assert "Build commands:" in result.output 

24 assert "Upload the bitstream to the FPGA" in result.output 

25 

26 # -- Run 'apio --version' 

27 result = sb.invoke_apio_cmd(apio, ["--version"]) 

28 sb.assert_result_ok(result) 

29 assert "apio, version" in result.output 

30 

31 # -- Run 'apio badcommand' 

32 result = sb.invoke_apio_cmd(apio, ["badcommand"]) 

33 assert result.exit_code != 0 

34 assert "Error: No such command 'badcommand'" in result.output