reportportal / agent-python-pytest

Framework integration with PyTest
Apache License 2.0
95 stars 101 forks source link

pytest-reportportal 5.4.1 and distutils #368

Open fenchu opened 3 weeks ago

fenchu commented 3 weeks ago

Describe the bug Regression? older versions seemed to work fine with python3.12

distutils is not in python3.12 - https://peps.python.org/pep-0632/

In Python 3.12, distutils will no longer be installed by make install or any of the first-party distribution. Third-party redistributors should no longer include distutils in their bundles or repositories.

Steps to Reproduce Steps to reproduce the behavior: pip install pytest pip install pytest-reportportal

run any pytest, do not even need to enable the plugin.

Expected behavior nothing

Actual behavior

Our CI tests with reportportal stopped. All modules are built with latest versions

pytest .\tests\ --webhost=test12 --tenant=ikomm  
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\dist\venvs\multitenant-fullstack-test\Scripts\pytest.exe\__main__.py", line 7, in <module>
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\_pytest\config\__init__.py", line 206, in console_main
    code = main()
           ^^^^^^
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\_pytest\config\__init__.py", line 159, in main
    config = _prepareconfig(args, plugins)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\_pytest\config\__init__.py", line 346, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\pluggy\_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\pluggy\_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\pluggy\_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\pluggy\_callers.py", line 122, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\_pytest\helpconfig.py", line 106, in pytest_cmdline_parse
    config = yield
             ^^^^^
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\pluggy\_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\_pytest\config\__init__.py", line 1152, in pytest_cmdline_parse
    self.parse(args)
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\_pytest\config\__init__.py", line 1501, in parse
    self._preparse(args, addopts=addopts)
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\_pytest\config\__init__.py", line 1388, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\pluggy\_manager.py", line 421, in load_setuptools_entrypoints
    plugin = ep.load()
             ^^^^^^^^^
  File "C:\dist\Python312\Lib\importlib\metadata\__init__.py", line 205, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dist\Python312\Lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\_pytest\assertion\rewrite.py", line 178, in exec_module
    exec(co, module.__dict__)
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\pytest_reportportal\plugin.py", line 29, in <module>
    from .config import AgentConfig
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\_pytest\assertion\rewrite.py", line 178, in exec_module
    exec(co, module.__dict__)
  File "C:\dist\venvs\multitenant-fullstack-test\Lib\site-packages\pytest_reportportal\config.py", line 17, in <module>
    from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils'

Package versions Include version info of the following packages: reportportal-client, pytest-reportportal

pytest                     8.2.2
pytest-reportportal        5.4.1
reportportal-client        5.5.6

Additional context

fenchu commented 3 weeks ago

There are lots of distutils.strtobool rout there t: https://github.com/symonsoft/str2bool

I had the follwoign in my code stolen from somwhere:

#!/usr/bin/env python3

_MAP = {
    'y': True,
    'yes': True,
    't': True,
    'true': True,
    'on': True,
    '1': True,
    'n': False,
    'no': False,
    'f': False,
    'false': False,
    'off': False,
    '0': False
}

def strtobool(value):
    try:
        return _MAP[str(value).lower()]
    except KeyError:
        raise ValueError('"{}" is not a valid bool value'.format(value))