Coverage for tests/unit_tests/commands/test_apio_devices.py: 100%
17 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 devices" command."""
11from tests.conftest import ApioRunner
12from apio.common.apio_console import cunstyle
13from apio.commands.apio import apio_top_cli as apio
16def test_devices(apio_runner: ApioRunner):
17 """Test "apio devices" """
19 with apio_runner.in_sandbox() as sb:
21 # -- Execute "apio devices"
22 result = sb.invoke_apio_cmd(apio, ["devices"])
23 sb.assert_result_ok(result)
24 assert "apio devices scan-usb" in cunstyle(result.output)
25 assert "apio devices scan-serial" in cunstyle(result.output)
28def test_apio_devices(apio_runner: ApioRunner):
29 """Test "apio devices scan-usb|serial" """
31 with apio_runner.in_sandbox() as sb:
33 # -- Execute "apio devices scan-usb". We run it in a
34 # -- subprocess such that it releases the libusb1 file it uses.
35 # -- This also means that it's not included in the pytest test
36 # -- coverage report.
37 result = sb.invoke_apio_cmd(
38 apio, ["devices", "scan-usb"], in_subprocess=True
39 )
40 sb.assert_result_ok(result)
41 print(result.output)
43 # -- Execute "apio devices scan-serial". We run it in a
44 # -- subprocess such that it releases the libusb1 file it uses.
45 # -- This also means that it's not included in the pytest test
46 # -- coverage report.
47 result = sb.invoke_apio_cmd(
48 apio, ["devices", "scan-serial"], in_subprocess=True
49 )
50 sb.assert_result_ok(result)
51 print(result.output)