Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest 8.1 incompatibility: TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages' #765

Closed
jtbandes opened this issue Mar 12, 2024 · 3 comments · Fixed by #766

Comments

@jtbandes
Copy link
Member

jtbandes commented Mar 12, 2024

Bug report

Required Info:

  • Operating System:
    • GitHub Actions ubuntu-22.04
  • Installation type:
    • binaries via action-ros-ci
      platform linux -- Python 3.10.12, pytest-8.1.1, pluggy-1.4.0
      cachedir: build/foxglove_msgs/ament_cmake_pytest/foxglove_msgs_test_msgs/.cache
      rootdir: /__w/schemas/schemas/ros_ws
      plugins: launch-testing-ros-0.26.4, launch-testing-3.4.0, ament-pep257-0.16.3, ament-flake8-0.16.3, ament-xmllint-0.16.3, ament-lint-0.16.3, ament-copyright-0.16.3, mock-3.12.0, cov-4.1.0, rerunfailures-13.0, colcon-core-0.15.1, repeat-0.9.3

Steps to reproduce issue

A test failure was encountered here (for Humble, Iron, and Rolling): https://github.com/foxglove/schemas/actions/runs/8241439601/job/22538701279

  /usr/bin/bash -c source /opt/ros/rolling/setup.sh && colcon test-result --verbose
  /usr/local/lib/python3.10/dist-packages/colcon_core/argument_parser/type_collector.py:9: UserWarning: 'colcon_core.argument_parser.type_collector.TypeCollectorDecorator' has been deprecated
    class TypeCollectorDecorator(ArgumentParserDecorator):
  /usr/local/lib/python3.10/dist-packages/colcon_core/argument_parser/type_collector.py:62: UserWarning: 'colcon_core.argument_parser.type_collector.SuppressTypeConversions' has been deprecated, use 'colcon_core.argument_parser.action_collector.SuppressTypeConversions' instead
    class SuppressTypeConversions:
  build/foxglove_msgs/Testing/20240312-0011/Test.xml: 34 tests, 0 errors, 1 failure, 0 skipped
  - foxglove_msgs_test_msgs
    <<< failure message
      -- run_test.py: invoking following command in '/__w/schemas/schemas/ros_ws/build/foxglove_msgs':
       - /usr/bin/python3.10 -u -m pytest /__w/schemas/schemas/ros_ws/src/l3sikm3bb4/schemas/ros_foxglove_msgs/test/test_msgs.py -o cache_dir=/__w/schemas/schemas/ros_ws/build/foxglove_msgs/ament_cmake_pytest/foxglove_msgs_test_msgs/.cache --junit-xml=/__w/schemas/schemas/ros_ws/build/foxglove_msgs/test_results/foxglove_msgs/foxglove_msgs_test_msgs.xunit.xml --junit-prefix=foxglove_msgs
      ============================= test session starts ==============================
      platform linux -- Python 3.10.12, pytest-8.1.1, pluggy-1.4.0
      cachedir: build/foxglove_msgs/ament_cmake_pytest/foxglove_msgs_test_msgs/.cache
      rootdir: /__w/schemas/schemas/ros_ws
      plugins: launch-testing-ros-0.26.4, launch-testing-3.4.0, ament-pep257-0.16.3, ament-flake8-0.16.3, ament-xmllint-0.16.3, ament-lint-0.16.3, ament-copyright-0.16.3, mock-3.12.0, cov-4.1.0, rerunfailures-13.0, colcon-core-0.15.1, repeat-0.9.3
      collected 0 items / 1 error
      
      ==================================== ERRORS ====================================
      ________ ERROR collecting src/l3sikm3bb4/schemas/ros_foxglove_msgs/test ________
      /usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py:501: in __call__
          return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
      /usr/local/lib/python3.10/dist-packages/pluggy/_manager.py:119: in _hookexec
          return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
      /usr/local/lib/python3.10/dist-packages/_pytest/python.py:225: in pytest_collect_file
          module: Module = ihook.pytest_pycollect_makemodule(
      /usr/local/lib/python3.10/dist-packages/_pytest/config/compat.py:79: in fixed_hook
          return hook(**kw)
      /usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py:501: in __call__
          return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
      /usr/local/lib/python3.10/dist-packages/pluggy/_manager.py:119: in _hookexec
          return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
      /opt/ros/rolling/lib/python3.10/site-packages/launch_testing/pytest/hooks.py:188: in pytest_pycollect_makemodule
          entrypoint = find_launch_test_entrypoint(path)
      /opt/ros/rolling/lib/python3.10/site-packages/launch_testing/pytest/hooks.py:178: in find_launch_test_entrypoint
          module = import_path(path, root=None)
      E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
      - generated xml file: /__w/schemas/schemas/ros_ws/build/foxglove_msgs/test_results/foxglove_msgs/foxglove_msgs_test_msgs.xunit.xml -
      =========================== short test summary info ============================
      ERROR ../../src/l3sikm3bb4/schemas/ros_foxglove_msgs/test - TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
      =============================== 1 error in 0.10s ===============================
      ERROR: found no collectors for /__w/schemas/schemas/ros_ws/src/l3sikm3bb4/schemas/ros_foxglove_msgs/test/test_msgs.py
      
      -- run_test.py: return code 4
      -- run_test.py: verify result file '/__w/schemas/schemas/ros_ws/build/foxglove_msgs/test_results/foxglove_msgs/foxglove_msgs_test_msgs.xunit.xml'
    >>>
  build/foxglove_msgs/test_results/foxglove_msgs/foxglove_msgs_test_msgs.xunit.xml: 1 test, 1 error, 0 failures, 0 skipped
  - foxglove_msgs src.l3sikm3bb4.schemas.ros_foxglove_msgs.test
    <<< error message
      collection failure
    >>>
  
  Summary: 4190 tests, 1 error, 1 failure, 1363 skipped

The error points to this line of code:

module = import_path(path, root=None)

Additional information

This consider_namespace_packages arg appears to have become required in pytest 8.1 (pytest-dev/pytest#11997). This is also causing issues for other pytest plugin authors (scientific-python/pytest-doctestplus#240). You can see an example fix at scientific-python/pytest-doctestplus#241.

jtbandes added a commit to foxglove/schemas that referenced this issue Mar 12, 2024
Update to latest links and product names.

Includes a pytest downgrade to work around a CI failure
ros2/launch#765 (similar to
scientific-python/pytest-doctestplus#240)
@xydesa
Copy link

xydesa commented Mar 12, 2024

My team is seeing this issue as well.

@tonynajjar
Copy link
Contributor

tonynajjar commented Mar 12, 2024

We're also facing this issue. I think it's safe to say it's a bug affecting a lot of people

@tonynajjar
Copy link
Contributor

Created PR #766

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 a pull request may close this issue.

3 participants