Skip to content

HAL Interfaces Tests#3233

Merged
javizqh merged 10 commits intohumble-develfrom
backend_testing
Oct 20, 2025
Merged

HAL Interfaces Tests#3233
javizqh merged 10 commits intohumble-develfrom
backend_testing

Conversation

@Apolo151
Copy link
Copy Markdown
Collaborator

@Apolo151 Apolo151 commented Sep 11, 2025

resolves #3195

@javizqh
Copy link
Copy Markdown
Member

javizqh commented Oct 3, 2025

How are you supposed to launch the tests @Apolo151 ?

I have tried inside and outside the RADi and I cannot get them to complete without crashing. Here is the log when running inside the RADI:

root@9ab22f2c3652:/RoboticsAcademy# pytest-3 tests/
============================================================================== test session starts ===============================================================================
platform linux -- Python 3.10.12, pytest-6.2.5, py-1.11.0, pluggy-0.13.0
rootdir: /RoboticsAcademy, configfile: pytest.ini
plugins: launch-testing-1.0.10, launch-testing-ros-0.19.10, ament-xmllint-0.12.14, ament-pep257-0.12.14, ament-flake8-0.12.14, ament-lint-0.12.14, ament-copyright-0.12.14, hypothesis-6.36.0, mock-3.6.1, arraydiff-0.5.0, remotedata-0.3.3, astropy-header-0.2.0, openfiles-0.5.0, doctestplus-0.11.2, filter-subpackage-0.1.1, colcon-core-0.20.0, cov-3.0.0
collected 0 items / 3 errors                                                                                                                                                     

===================================================================================== ERRORS =====================================================================================
_____________________________________________________________ ERROR collecting tests/console_interfaces/__init__.py ______________________________________________________________
/usr/lib/python3/dist-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:92: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:83: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/usr/lib/python3/dist-packages/_pytest/python.py:200: in pytest_collect_file
    module: Module = ihook.pytest_pycollect_makemodule(path=path, parent=parent)
/usr/lib/python3/dist-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:92: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:83: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/opt/ros/humble/lib/python3.10/site-packages/launch_testing/pytest/hooks.py:193: in pytest_pycollect_makemodule
    entrypoint = find_launch_test_entrypoint(path)
/opt/ros/humble/lib/python3.10/site-packages/launch_testing/pytest/hooks.py:186: in find_launch_test_entrypoint
    module = path.pyimport()
/usr/local/lib/python3.10/dist-packages/py/_path/local.py:704: in pyimport
    __import__(modname)
/usr/lib/python3/dist-packages/_pytest/assertion/rewrite.py:170: in exec_module
    exec(co, module.__dict__)
tests/console_interfaces/test_console.py:5: in <module>
    from console_interfaces.general.console import start_console, close_console
E   ModuleNotFoundError: No module named 'console_interfaces'
_______________________________________________________________ ERROR collecting tests/gui_interfaces/__init__.py ________________________________________________________________
/usr/lib/python3/dist-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:92: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:83: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/usr/lib/python3/dist-packages/_pytest/python.py:200: in pytest_collect_file
    module: Module = ihook.pytest_pycollect_makemodule(path=path, parent=parent)
/usr/lib/python3/dist-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:92: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:83: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/opt/ros/humble/lib/python3.10/site-packages/launch_testing/pytest/hooks.py:193: in pytest_pycollect_makemodule
    entrypoint = find_launch_test_entrypoint(path)
/opt/ros/humble/lib/python3.10/site-packages/launch_testing/pytest/hooks.py:186: in find_launch_test_entrypoint
    module = path.pyimport()
/usr/local/lib/python3.10/dist-packages/py/_path/local.py:704: in pyimport
    __import__(modname)
/usr/lib/python3/dist-packages/_pytest/assertion/rewrite.py:170: in exec_module
    exec(co, module.__dict__)
tests/gui_interfaces/test_measuring_gui.py:5: in <module>
    from gui_interfaces.general.measuring_threading_gui import MeasuringThreadingGUI
E   ModuleNotFoundError: No module named 'gui_interfaces'
_______________________________________________________________ ERROR collecting tests/hal_interfaces/__init__.py ________________________________________________________________
/usr/lib/python3/dist-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:92: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:83: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/usr/lib/python3/dist-packages/_pytest/python.py:200: in pytest_collect_file
    module: Module = ihook.pytest_pycollect_makemodule(path=path, parent=parent)
/usr/lib/python3/dist-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:92: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:83: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/opt/ros/humble/lib/python3.10/site-packages/launch_testing/pytest/hooks.py:193: in pytest_pycollect_makemodule
    entrypoint = find_launch_test_entrypoint(path)
/opt/ros/humble/lib/python3.10/site-packages/launch_testing/pytest/hooks.py:186: in find_launch_test_entrypoint
    module = path.pyimport()
/usr/local/lib/python3.10/dist-packages/py/_path/local.py:704: in pyimport
    __import__(modname)
/usr/lib/python3/dist-packages/_pytest/assertion/rewrite.py:170: in exec_module
    exec(co, module.__dict__)
tests/hal_interfaces/test_bumper.py:2: in <module>
    from hal_interfaces.general.bumper import (
E   ModuleNotFoundError: No module named 'hal_interfaces'
================================================================================ warnings summary ================================================================================
../usr/lib/python3/dist-packages/_pytest/config/__init__.py:1233
  Warning: Unknown config option: DJANGO_SETTINGS_MODULE

-- Docs: https://docs.pytest.org/en/stable/warnings.html
============================================================================ short test summary info =============================================================================
ERROR tests/console_interfaces/__init__.py - ModuleNotFoundError: No module named 'console_interfaces'
ERROR tests/gui_interfaces/__init__.py - ModuleNotFoundError: No module named 'gui_interfaces'
ERROR tests/hal_interfaces/__init__.py - ModuleNotFoundError: No module named 'hal_interfaces'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================================== 1 warning, 3 errors in 0.18s ==========================================================================

@Apolo151
Copy link
Copy Markdown
Collaborator Author

Hi @javizqh,

I have added the steps to run the tests at tests/README.md.

@javizqh
Copy link
Copy Markdown
Member

javizqh commented Oct 13, 2025

I now can launch the tests, but there are 3 error in the GUI tests because it is calling some methods that do not exist. Can you check this and the I will merge it.

tests/console_interfaces/test_console.py ..                                                                                                                                               [  2%]
tests/gui_interfaces/test_measuring_gui.py FFF                                                                                                                                            [  6%]
tests/gui_interfaces/test_threading_gui.py ......                                                                                                                                         [ 14%]
tests/hal_interfaces/test_bumper.py ......                                                                                                                                                [ 22%]
tests/hal_interfaces/test_camera.py ....                                                                                                                                                  [ 27%]
tests/hal_interfaces/test_classnet.py .....                                                                                                                                               [ 34%]
tests/hal_interfaces/test_laser.py .......                                                                                                                                                [ 43%]
tests/hal_interfaces/test_motors.py ......                                                                                                                                                [ 51%]
tests/hal_interfaces/test_noise_odometry.py ..............                                                                                                                                [ 69%]
tests/hal_interfaces/test_odometry.py ..............                                                                                                                                      [ 88%]
tests/hal_interfaces/test_sim_time.py .........                                                                                                                                           [100%]

=========================================================================================== FAILURES ============================================================================================
_________________________________________________________________________ TestMeasuringThreadingGUI.test_initialization _________________________________________________________________________

self = <tests.gui_interfaces.test_measuring_gui.TestMeasuringThreadingGUI testMethod=test_initialization>

    def test_initialization(self):
        # Test initialization parameters
        self.assertEqual(self.gui.host, "ws://test:2303")
        self.assertEqual(self.gui.out_period, 0.1)  # 1/10Hz
>       self.assertEqual(self.gui.ideal_cycle, 0.1)
E       AssertionError: 80 != 0.1

tests/gui_interfaces/test_measuring_gui.py:27: AssertionError
_________________________________________________________________________ TestMeasuringThreadingGUI.test_measure_thread _________________________________________________________________________

self = <tests.gui_interfaces.test_measuring_gui.TestMeasuringThreadingGUI testMethod=test_measure_thread>

    def test_measure_thread(self):
        # Test the measure_thread method
        self.gui.iteration_counter = 10
    
        # Mock time.time() to return controlled values
        with patch("time.time") as mock_time:
            # First call to get start_time
            mock_time.return_value = 100.0
>           self.gui.measure_thread()
E           AttributeError: 'MeasuringThreadingGUI' object has no attribute 'measure_thread'

tests/gui_interfaces/test_measuring_gui.py:38: AttributeError
_____________________________________________________________________ TestMeasuringThreadingGUI.test_send_frequency_message _____________________________________________________________________

self = <tests.gui_interfaces.test_measuring_gui.TestMeasuringThreadingGUI testMethod=test_send_frequency_message>

    def test_send_frequency_message(self):
        # Test sending frequency message to client
        self.gui.real_freq = 9.5  # Slightly lower than target
        self.gui.ideal_cycle = 0.1  # 10Hz target
    
        # Call method to send frequency info
>       self.gui.send_frequency_message()
E       AttributeError: 'MeasuringThreadingGUI' object has no attribute 'send_frequency_message'. Did you mean: 'frequency_message'?

tests/gui_interfaces/test_measuring_gui.py:56: AttributeError
==================================================================================== short test summary info ====================================================================================
FAILED tests/gui_interfaces/test_measuring_gui.py::TestMeasuringThreadingGUI::test_initialization - AssertionError: 80 != 0.1
FAILED tests/gui_interfaces/test_measuring_gui.py::TestMeasuringThreadingGUI::test_measure_thread - AttributeError: 'MeasuringThreadingGUI' object has no attribute 'measure_thread'
FAILED tests/gui_interfaces/test_measuring_gui.py::TestMeasuringThreadingGUI::test_send_frequency_message - AttributeError: 'MeasuringThreadingGUI' object has no attribute 'send_frequency_message'. Did you mean: 'frequency_message'?
================================================================================= 3 failed, 73 passed in 0.75s =================================================================================

@Apolo151
Copy link
Copy Markdown
Collaborator Author

Hi @javizqh,

I have updated the tests, all of them run successfully now.

@javizqh
Copy link
Copy Markdown
Member

javizqh commented Oct 20, 2025

Works fine now

@javizqh javizqh merged commit 3bd15a4 into humble-devel Oct 20, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tests] Add Backend Tests

2 participants