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

8.2.1: pytest self test fails with NameError: name 'group' is not defined error message #12352

Closed
4 tasks done
kloczek opened this issue May 22, 2024 · 17 comments
Closed
4 tasks done

Comments

@kloczek
Copy link
Contributor

kloczek commented May 22, 2024

  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

OS: Linux x86/64 and python 3.10.14.

After unpackage generated .whl archive in <install/prefix> I'm trying to test pytest using that pytest code by put proper paths in $PYTHONPATH.
Here is result:

+ PATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/bin:/usr/bin:/usr/sbin:/usr/local/sbin
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages
+ /home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/bin/pytest -ra -m 'not network' --import-mode=importlib -p no:flaky -p no:randomly
Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/config/__init__.py", line 206, in console_main
    code = main()
  File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/config/__init__.py", line 159, in main
    config = _prepareconfig(args, plugins)
  File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/config/__init__.py", line 337, in _prepareconfig
    config = get_config(args, plugins)
  File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/config/__init__.py", line 307, in get_config
    pluginmanager.import_plugin(spec)
  File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/config/__init__.py", line 875, in import_plugin
    self.register(mod, modname)
  File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/config/__init__.py", line 508, in register
    plugin_name = super().register(plugin, name)
  File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 169, in register
    hook._maybe_apply_history(hookimpl)
  File "/usr/lib/python3.10/site-packages/pluggy/_hooks.py", line 581, in _maybe_apply_history
    res = self._hookexec(self.name, [method], kwargs, False)
  File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/python.py", line 114, in pytest_addoption
    group.addoption(
NameError: name 'group' is not defined

List of installed python modules in build env

Package                       Version
----------------------------- -----------
alabaster                     0.7.16
attrs                         23.2.0
Automat                       22.10.0
Babel                         2.15.0
build                         1.2.1
charset-normalizer            3.3.2
constantly                    23.10.4
decorator                     5.1.1
defusedxml                    0.7.1
docutils                      0.20.1
elementpath                   4.4.0
exceptiongroup                1.1.3
execnet                       2.1.1
hyperlink                     21.0.0
hypothesis                    6.100.0
idna                          3.7
imagesize                     1.4.1
importlib_metadata            7.1.0
incremental                   22.10.0
iniconfig                     2.0.0
installer                     0.7.0
Jinja2                        3.1.4
MarkupSafe                    2.1.5
packaging                     24.0
Pallets-Sphinx-Themes         2.1.1
pluggy                        1.5.0
Pygments                      2.18.0
pygments_pytest               2.3.0
pyproject_hooks               1.0.0
pytest                        8.1.1
pytest-xdist                  3.6.1
python-dateutil               2.9.0.post0
requests                      2.32.2
setuptools                    69.4.0
setuptools-scm                8.1.0
snowballstemmer               2.2.0
sortedcontainers              2.4.0
Sphinx                        7.3.7
sphinx-removed-in             0.2.2
sphinxcontrib-applehelp       1.0.8
sphinxcontrib-devhelp         1.0.6
sphinxcontrib-htmlhelp        2.0.5
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.7
sphinxcontrib-serializinghtml 1.1.10
sphinxcontrib-trio            1.1.2
tokenize_rt                   5.2.0
tomli                         2.0.1
Twisted                       24.3.0
typing_extensions             4.11.0
urllib3                       2.2.1
wheel                         0.43.0
xmlschema                     3.3.1
zipp                          3.18.2
zope.event                    5.0
zope.interface                6.4
@The-Compiler
Copy link
Member

The line in your traceback doesn't even exist in pytest 8.2.1, it was removed in 1188ea2. Whatever you're running there, it's not actually a clean pytest 8.2.1 source.

@The-Compiler The-Compiler closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2024
@kloczek
Copy link
Contributor Author

kloczek commented May 22, 2024

The line in your traceback doesn't even exist in pytest 8.2.1, it was removed in 1188ea2. Whatever you're running there, it's not actually a clean pytest 8.2.1 source.

Because it is SELF TEST using unpacked pytest .whl.
Exactly the same procedure was VALID multiple times before
#12080
#11955
#9465

@The-Compiler
Copy link
Member

You're not running the code that's shipped in the 8.2.1 .whl.

@nicoddemus
Copy link
Member

nicoddemus commented May 22, 2024

@kloczek

Your traceback points to line 114:

  File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/python.py", line 114, in pytest_addoption
    group.addoption(
NameError: name 'group' is not defined

However we can see on GitHub that line 144 in python.py for 8.2.1 is completely different:

https://github.com/pytest-dev/pytest/blob/8.2.1/src/_pytest/python.py#L107-L115

Also downloading the .whl directly, I can see the same thing:

image

So as @The-Compiler said, you are not running the code shipped with 8.2.1 but something else.

@kloczek
Copy link
Contributor Author

kloczek commented May 22, 2024

Yes because I'm using as input source tar ball autogenerated from git tag -> than:

  • python3 -sBm build -w --no-isolation
  • install .whl file in </install/prefix> using installer module
  • run pytest from $PATH and with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

Nevertheless cause was in my patch adding my own option which still ben using group.addoption() instead new parser.addini() and I must apologise for that.

Nevertheless now after update that patch pytest I've tested self test without my patches and I was able start self test and it passed scanning units and it failed in two units

Here is pytest output:
+ PATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/bin:/usr/bin:/usr/sbin:/usr/local/sbin
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages
+ /home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/bin/pytest -ra -m 'not network' --import-mode=importlib -p no:flaky -p no:randomly
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pytest-8.2.1
configfile: pyproject.toml
testpaths: testing
plugins: xdist-3.6.1, hypothesis-6.100.0
collected 3662 items

testing/_py/test_local.py .................................................................ss..............s.................x.....Xs.....................................sssssss.... [  4%]
........................x...                                                                                                                                                          [  4%]
testing/acceptance_test.py .....                                                                                                                                                      [  5%]
testing/code/test_code.py .................                                                                                                                                           [  5%]
testing/code/test_excinfo.py ......................................................................................................................................................   [  9%]
testing/code/test_source.py .......................................................                                                                                                   [ 11%]
testing/deprecated_test.py ..........                                                                                                                                                 [ 11%]
testing/freeze/tests/test_doctest.txt .                                                                                                                                               [ 11%]
testing/freeze/tests/test_trivial.py ..                                                                                                                                               [ 11%]
testing/io/test_pprint.py ......................................                                                                                                                      [ 12%]
testing/io/test_saferepr.py .............                                                                                                                                             [ 12%]
testing/io/test_terminalwriter.py .................................................                                                                                                   [ 14%]
testing/io/test_wcwidth.py .................                                                                                                                                          [ 14%]
testing/logging/test_fixture.py ....F..............                                                                                                                                   [ 15%]
testing/logging/test_formatter.py ....                                                                                                                                                [ 15%]
testing/logging/test_reporting.py ..                                                                                                                                                  [ 15%]
testing/python/approx.py .sss..sssss......................................sssssss................ss........                                                                           [ 17%]
testing/python/collect.py ..                                                                                                                                                          [ 17%]
testing/python/fixtures.py ...........                                                                                                                                                [ 18%]
testing/python/integration.py ....                                                                                                                                                    [ 18%]
testing/python/metafunc.py .........................................                                                                                                                  [ 19%]
testing/python/raises.py ...................F....                                                                                                                                     [ 19%]
testing/test_argcomplete.py ..                                                                                                                                                        [ 19%]
testing/test_assertion.py .........................................................................                                                                                   [ 21%]
testing/test_assertrewrite.py .............................................                                                                                                           [ 23%]
testing/test_capture.py .............................................................s..                                                                                              [ 24%]
testing/test_collection.py ..                                                                                                                                                         [ 24%]
testing/test_compat.py ...........                                                                                                                                                    [ 25%]
testing/test_config.py .............................................................                                                                                                  [ 26%]
testing/test_conftest.py ...........                                                                                                                                                  [ 27%]
testing/test_debugging.py .                                                                                                                                                           [ 27%]
testing/test_doctest.py .............                                                                                                                                                 [ 27%]
testing/test_entry_points.py .                                                                                                                                                        [ 27%]
testing/test_faulthandler.py ...                                                                                                                                                      [ 27%]
testing/test_findpaths.py ..............s...                                                                                                                                          [ 28%]
testing/test_helpconfig.py .                                                                                                                                                          [ 28%]
testing/test_junitxml.py ....                                                                                                                                                         [ 28%]
testing/test_legacypath.py ....                                                                                                                                                       [ 28%]
testing/test_main.py .....                                                                                                                                                            [ 28%]
testing/test_mark.py ..............                                                                                                                                                   [ 29%]
testing/test_mark_expression.py ....................................................................................                                                                  [ 31%]
testing/test_monkeypatch.py ...............................                                                                                                                           [ 32%]
testing/test_nodes.py ....                                                                                                                                                            [ 32%]
testing/test_parseopt.py .............................                                                                                                                                [ 33%]
testing/test_pastebin.py ....                                                                                                                                                         [ 33%]
testing/test_pluginmanager.py .........                                                                                                                                               [ 33%]
testing/test_pytester.py .....................                                                                                                                                        [ 33%]
testing/test_recwarn.py .........................................................                                                                                                     [ 35%]
testing/test_runner.py ...............                                                                                                                                                [ 35%]
testing/test_scope.py ....                                                                                                                                                            [ 36%]
testing/test_skipping.py .                                                                                                                                                            [ 36%]
testing/test_stash.py .                                                                                                                                                               [ 36%]
testing/test_terminal.py .......................................                                                                                                                      [ 37%]
testing/test_tmpdir.py ...s...............                                                                                                                                            [ 37%]
testing/test_warning_types.py ..............                                                                                                                                          [ 38%]
testing/test_warnings.py .                                                                                                                                                            [ 38%]
testing/acceptance_test.py ......................................................x....................s                                                                               [ 40%]
testing/code/test_excinfo.py ....sssssssss...............                                                                                                                             [ 40%]
testing/deprecated_test.py ....                                                                                                                                                       [ 41%]
testing/examples/test_issue519.py .                                                                                                                                                   [ 41%]
testing/logging/test_fixture.py ........                                                                                                                                              [ 41%]
testing/logging/test_reporting.py ..................................................                                                                                                  [ 42%]
testing/python/approx.py .                                                                                                                                                            [ 42%]
testing/python/collect.py ............................................................................                                                                                [ 44%]
testing/python/fixtures.py .......................................................................x.................................................................................. [ 48%]
...................s.......                                                                                                                                                           [ 49%]
testing/python/integration.py ..s.sss........                                                                                                                                         [ 50%]
testing/python/metafunc.py .................................................................                                                                                          [ 51%]
testing/python/raises.py ...                                                                                                                                                          [ 51%]
testing/python/show_fixtures_per_test.py ........                                                                                                                                     [ 52%]
testing/test_assertion.py ...............................................                                                                                                             [ 53%]
testing/test_assertrewrite.py .................................................................                                                                                       [ 55%]
testing/test_cacheprovider.py .........................................................                                                                                               [ 56%]
testing/test_capture.py ......x....................................                                                                                                                   [ 57%]
testing/test_collection.py ............................x............................................s................s..                                                              [ 60%]
testing/test_compat.py ..                                                                                                                                                             [ 60%]
testing/test_config.py ..................x......................................................................................................................                      [ 64%]
testing/test_conftest.py .............s.............................                                                                                                                  [ 65%]
testing/test_debugging.py .............                                                                                                                                               [ 65%]
testing/test_doctest.py ................................................................x.............................................................s.                              [ 69%]
testing/test_error_diffs.py ............                                                                                                                                              [ 69%]
testing/test_faulthandler.py ...                                                                                                                                                      [ 69%]
testing/test_helpconfig.py ........                                                                                                                                                   [ 69%]
testing/test_junitxml.py ...............................................................................................................................                              [ 73%]
testing/test_legacypath.py ..........                                                                                                                                                 [ 73%]
testing/test_link_resolve.py .                                                                                                                                                        [ 73%]
testing/test_main.py ..............                                                                                                                                                   [ 74%]
testing/test_mark.py ...........................................................x.................                                                                                    [ 76%]
testing/test_monkeypatch.py ....                                                                                                                                                      [ 76%]
testing/test_nodes.py ....                                                                                                                                                            [ 76%]
testing/test_parseopt.py s                                                                                                                                                            [ 76%]
testing/test_pastebin.py ...                                                                                                                                                          [ 76%]
testing/test_pathlib.py ............................................................s...................................                                                              [ 79%]
testing/test_pluginmanager.py ....s............                                                                                                                                       [ 79%]
testing/test_pytester.py x........................                                                                                                                                    [ 80%]
testing/test_python_path.py .....                                                                                                                                                     [ 80%]
testing/test_recwarn.py .....                                                                                                                                                         [ 80%]
testing/test_reports.py ..................                                                                                                                                            [ 81%]
testing/test_runner.py .......................x.........................                                                                                                              [ 82%]
testing/test_runner_xunit.py .............                                                                                                                                            [ 82%]
testing/test_session.py ..........................                                                                                                                                    [ 83%]
testing/test_setuponly.py ..........................                                                                                                                                  [ 84%]
testing/test_setupplan.py ...                                                                                                                                                         [ 84%]
testing/test_skipping.py .........................................................................................                                                                    [ 86%]
testing/test_stepwise.py ..............                                                                                                                                               [ 87%]
testing/test_terminal.py ...........................................................................................................................................                  [ 90%]
testing/test_threadexception.py ....                                                                                                                                                  [ 90%]
testing/test_tmpdir.py ....................                                                                                                                                           [ 91%]
testing/test_unittest.py ..............................................................s...........                                                                                   [ 93%]
testing/test_unraisableexception.py ....                                                                                                                                              [ 93%]
testing/test_warning_types.py .                                                                                                                                                       [ 93%]
testing/test_warnings.py ...................sss..........                                                                                                                             [ 94%]
testing/acceptance_test.py .....                                                                                                                                                      [ 94%]
testing/python/collect.py .                                                                                                                                                           [ 94%]
testing/python/fixtures.py x.                                                                                                                                                         [ 94%]
testing/test_assertion.py ............                                                                                                                                                [ 95%]
testing/test_assertrewrite.py .........                                                                                                                                               [ 95%]
testing/test_capture.py ........................                                                                                                                                      [ 96%]
testing/test_collection.py ...                                                                                                                                                        [ 96%]
testing/test_compat.py .                                                                                                                                                              [ 96%]
testing/test_config.py ..                                                                                                                                                             [ 96%]
testing/test_debugging.py sssssssssss.ssssssssssssssss.sss....ssss.sss                                                                                                                [ 97%]
testing/test_faulthandler.py ..s.                                                                                                                                                     [ 97%]
testing/test_helpconfig.py ..                                                                                                                                                         [ 97%]
testing/test_legacypath.py .                                                                                                                                                          [ 97%]
testing/test_meta.py ...................................................................                                                                                              [ 99%]
testing/test_pytester.py ....s                                                                                                                                                        [ 99%]
testing/test_recwarn.py .                                                                                                                                                             [ 99%]
testing/test_reports.py .                                                                                                                                                             [ 99%]
testing/test_terminal.py ss..                                                                                                                                                         [ 99%]
testing/test_unittest.py s.                                                                                                                                                           [ 99%]
testing/test_warnings.py .........                                                                                                                                                    [100%]

========================================================================================= FAILURES ==========================================================================================
_______________________________________________________________________________ test_with_statement_filtering _______________________________________________________________________________

caplog = <_pytest.logging.LogCaptureFixture object at 0x7f048878b3a0>

    def test_with_statement_filtering(caplog: pytest.LogCaptureFixture) -> None:
        class TestFilter(logging.Filter):
            def filter(self, record: logging.LogRecord) -> bool:
                record.msg = "filtered handler call"
                return True

        with caplog.at_level(logging.INFO):
            with caplog.filtering(TestFilter()):
                logger.info("handler call")
            logger.info("handler call")

        filtered_tuple, unfiltered_tuple = caplog.record_tuples
>       assert filtered_tuple == ("test_fixture", 20, "filtered handler call")
E       AssertionError: assert ('testing.log...handler call') == ('test_fixtur...handler call')
E
E         At index 0 diff: 'testing.logging.test_fixture' != 'test_fixture'
E         Use -v to get more diff

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/logging/test_fixture.py:203: AssertionError
------------------------------------------------------------------------------------- Captured log call -------------------------------------------------------------------------------------
INFO     testing.logging.test_fixture:test_fixture.py:199 filtered handler call
INFO     testing.logging.test_fixture:test_fixture.py:200 handler call
______________________________________________________________________ TestRaises.test_raises_exception_looks_iterable ______________________________________________________________________

self = <testing.python.raises.TestRaises object at 0x7f048b8d8c40>

    def test_raises_exception_looks_iterable(self):
        class Meta(type):
            def __getitem__(self, item):
                return 1 / 0

            def __len__(self):
                return 1

        class ClassLooksIterableException(Exception, metaclass=Meta):
            pass

        with pytest.raises(
            Failed,
            match=r"DID NOT RAISE <class 'raises(\..*)*ClassLooksIterableException'>",
        ):
>           pytest.raises(ClassLooksIterableException, lambda: None)
E           Failed: DID NOT RAISE <class 'testing.python.raises.TestRaises.test_raises_exception_looks_iterable.<locals>.ClassLooksIterableException'>

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/python/raises.py:265: Failed

During handling of the above exception, another exception occurred:

self = <testing.python.raises.TestRaises object at 0x7f048b8d8c40>

    def test_raises_exception_looks_iterable(self):
        class Meta(type):
            def __getitem__(self, item):
                return 1 / 0

            def __len__(self):
                return 1

        class ClassLooksIterableException(Exception, metaclass=Meta):
            pass

>       with pytest.raises(
            Failed,
            match=r"DID NOT RAISE <class 'raises(\..*)*ClassLooksIterableException'>",
        ):
E       AssertionError: Regex pattern did not match.
E        Regex: "DID NOT RAISE <class 'raises(\\..*)*ClassLooksIterableException'>"
E        Input: "DID NOT RAISE <class 'testing.python.raises.TestRaises.test_raises_exception_looks_iterable.<locals>.ClassLooksIterableException'>"

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/python/raises.py:261: AssertionError
========================================================================================= XFAILURES =========================================================================================
_____________________________________________________________________________ TestLocalPath.test_long_filenames _____________________________________________________________________________

cls = <class '_pytest.runner.CallInfo'>, func = <function call_and_report.<locals>.<lambda> at 0x7f048b462320>, when = 'setup'
reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)

    @classmethod
    def from_call(
        cls,
        func: Callable[[], TResult],
        when: Literal["collect", "setup", "call", "teardown"],
        reraise: Optional[
            Union[Type[BaseException], Tuple[Type[BaseException], ...]]
        ] = None,
    ) -> "CallInfo[TResult]":
        """Call func, wrapping the result in a CallInfo.

        :param func:
            The function to call. Called without arguments.
        :param when:
            The phase in which the function is called.
        :param reraise:
            Exception or exceptions that shall propagate if raised by the
            function, instead of being wrapped in the CallInfo.
        """
        excinfo = None
        start = timing.time()
        precise_start = timing.perf_counter()
        try:
>           result: Optional[TResult] = func()

/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py:341:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py:241: in <lambda>
    lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
/usr/lib/python3.10/site-packages/pluggy/_hooks.py:513: in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
/usr/lib/python3.10/site-packages/pluggy/_manager.py:120: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/unraisableexception.py:85: in pytest_runtest_setup
    yield from unraisable_exception_runtest_hook()
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/unraisableexception.py:65: in unraisable_exception_runtest_hook
    yield
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/logging.py:844: in pytest_runtest_setup
    yield from self._runtest_for(item, "setup")
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/logging.py:833: in _runtest_for
    yield
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/capture.py:873: in pytest_runtest_setup
    return (yield)
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/threadexception.py:82: in pytest_runtest_setup
    yield from thread_exception_runtest_hook()
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/threadexception.py:63: in thread_exception_runtest_hook
    yield
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

item = <Function test_long_filenames>

    @hookimpl(tryfirst=True)
    def pytest_runtest_setup(item: Item) -> None:
        skipped = evaluate_skip_marks(item)
        if skipped:
            raise skip.Exception(skipped.reason, _use_item_location=True)

        item.stash[xfailed_key] = xfailed = evaluate_xfail_marks(item)
        if xfailed and not item.config.option.runxfail and not xfailed.run:
>           xfail("[NOTRUN] " + xfailed.reason)
E           _pytest.outcomes.XFailed: [NOTRUN] unreliable est for long filenames

/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/skipping.py:244: XFailed
________________________________________________________________________________ TestUnicode.test_read_write ________________________________________________________________________________

self = <testing._py.test_local.TestUnicode object at 0x7f048c554f10>, tmpdir = local('/tmp/pytest-of-tkloczko/pytest-185/test_read_write0')

    @pytest.mark.xfail(reason="changing read/write might break existing usages")
    def test_read_write(self, tmpdir):
        x = tmpdir.join("hello")
        part = "hällo"
        with ignore_encoding_warning():
            x.write(part)
            assert x.read() == part
            x.write(part.encode(sys.getdefaultencoding()))
>           assert x.read() == part.encode(sys.getdefaultencoding())
E           AssertionError: assert 'hällo' == b'h\xc3\xa4llo'
E            +  where 'hällo' = <bound method LocalPath.read of local('/tmp/pytest-of-tkloczko/pytest-185/test_read_write0/hello')>()
E            +    where <bound method LocalPath.read of local('/tmp/pytest-of-tkloczko/pytest-185/test_read_write0/hello')> = local('/tmp/pytest-of-tkloczko/pytest-185/test_read_write0/hello').read
E            +  and   b'h\xc3\xa4llo' = <built-in method encode of str object at 0x7f048c60c7b0>('utf-8')
E            +    where <built-in method encode of str object at 0x7f048c60c7b0> = 'hällo'.encode
E            +    and   'utf-8' = <built-in function getdefaultencoding>()
E            +      where <built-in function getdefaultencoding> = sys.getdefaultencoding

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/_py/test_local.py:1552: AssertionError
_______________________________________________________________ TestInvocationVariants.test_noclass_discovery_if_not_testcase _______________________________________________________________

self = <testing.acceptance_test.TestInvocationVariants object at 0x7f048c666bf0>
pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-185/test_noclass_discovery_if_not_testcase0')>

    @pytest.mark.xfail(reason="decide: feature or bug")
    def test_noclass_discovery_if_not_testcase(self, pytester: Pytester) -> None:
        testpath = pytester.makepyfile(
            """
            import unittest
            class TestHello(object):
                def test_hello(self):
                    assert self.attr

            class RealTest(unittest.TestCase, TestHello):
                attr = 42
        """
        )
        reprec = pytester.inline_run(testpath)
>       reprec.assertoutcome(passed=1)
E       AssertionError: ([<TestReport 'test_noclass_discovery_if_not_testcase.py::RealTest::test_hello' when='call' outcome='passed'>], [], [<TestReport 'test_noclass_discovery_if_not_testcase.py::TestHello::test_hello' when='call' outcome='failed'>])
E       assert {'failed': 1,... 'skipped': 0} == {'failed': 0,... 'skipped': 0}
E
E         Omitting 2 identical items, use -vv to show
E         Differing items:
E         {'failed': 1} != {'failed': 0}
E         Use -v to get more diff

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/acceptance_test.py:892: AssertionError
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /tmp/pytest-of-tkloczko/pytest-185/test_noclass_discovery_if_not_testcase0
collected 2 items

test_noclass_discovery_if_not_testcase.py F.                             [100%]

=================================== FAILURES ===================================
_____________________________ TestHello.test_hello _____________________________

self = <test_noclass_discovery_if_not_testcase.TestHello object at 0x7f04832920b0>

    def test_hello(self):
>       assert self.attr
E       AttributeError: 'TestHello' object has no attribute 'attr'

test_noclass_discovery_if_not_testcase.py:4: AttributeError
=========================== short test summary info ============================
FAILED test_noclass_discovery_if_not_testcase.py::TestHello::test_hello - Att...
========================= 1 failed, 1 passed in 0.01s ==========================
___________________________________________________________________ TestAutouseDiscovery.test_setup_enabled_functionnode ____________________________________________________________________

self = <testing.python.fixtures.TestAutouseDiscovery object at 0x7f048b4d6f50>, pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-185/test_setup_enabled_functionnode0')>

    @pytest.mark.xfail(reason="'enabled' feature not implemented")
    def test_setup_enabled_functionnode(self, pytester: Pytester) -> None:
        pytester.makepyfile(
            """
            import pytest

            def enabled(parentnode, markers):
                return "needsdb" in markers

            @pytest.fixture(params=[1,2])
            def db(request):
                return request.param

            @pytest.fixture(enabled=enabled, autouse=True)
            def createdb(db):
                pass

            def test_func1(request):
                assert "db" not in request.fixturenames

            @pytest.mark.needsdb
            def test_func2(request):
                assert "db" in request.fixturenames
        """
        )
        reprec = pytester.inline_run("-s")
>       reprec.assertoutcome(passed=2)
E       AssertionError: ([], [], [<CollectReport 'test_setup_enabled_functionnode.py' lenresult=0 outcome='failed'>])
E       assert {'failed': 1,... 'skipped': 0} == {'failed': 0,... 'skipped': 0}
E
E         Omitting 1 identical items, use -vv to show
E         Differing items:
E         {'passed': 0} != {'passed': 2}
E         {'failed': 1} != {'failed': 0}
E         Use -v to get more diff

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/python/fixtures.py:1897: AssertionError
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /tmp/pytest-of-tkloczko/pytest-185/test_setup_enabled_functionnode0
collected 0 items / 1 error

==================================== ERRORS ====================================
_____________ ERROR collecting test_setup_enabled_functionnode.py ______________
test_setup_enabled_functionnode.py:10: in <module>
    @pytest.fixture(enabled=enabled, autouse=True)
E   TypeError: fixture() got an unexpected keyword argument 'enabled'
=========================== short test summary info ============================
ERROR test_setup_enabled_functionnode.py - TypeError: fixture() got an unexpe...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.08s ===============================
_______________________________________________________________________ TestPerTestCapturing.test_capture_scope_cache _______________________________________________________________________

self = <testing.test_capture.TestPerTestCapturing object at 0x7f048ae5f220>, pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-185/test_capture_scope_cache0')>

    @pytest.mark.xfail(reason="unimplemented feature")
    def test_capture_scope_cache(self, pytester: Pytester) -> None:
        p = pytester.makepyfile(
            """
            import sys
            def setup_module(func):
                print("module-setup")
            def setup_function(func):
                print("function-setup")
            def test_func():
                print("in function")
                assert 0
            def teardown_function(func):
                print("in teardown")
        """
        )
        result = pytester.runpytest(p)
>       result.stdout.fnmatch_lines(
            [
                "*test_func():*",
                "*Captured stdout during setup*",
                "module-setup*",
                "function-setup*",
                "*Captured stdout*",
                "in teardown*",
            ]
        )
E       Failed: nomatch: '*test_func():*'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0'
E           and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-185/test_capture_scope_cache0'
E           and: 'collected 1 item'
E           and: ''
E           and: 'test_capture_scope_cache.py F                                            [100%]'
E           and: ''
E           and: '=================================== FAILURES ==================================='
E           and: '__________________________________ test_func ___________________________________'
E           and: ''
E       fnmatch: '*test_func():*'
E          with: '    def test_func():'
E       nomatch: '*Captured stdout during setup*'
E           and: '        print("in function")'
E           and: '>       assert 0'
E           and: 'E       assert 0'
E           and: ''
E           and: 'test_capture_scope_cache.py:8: AssertionError'
E           and: '---------------------------- Captured stdout setup -----------------------------'
E           and: 'module-setup'
E           and: 'function-setup'
E           and: '----------------------------- Captured stdout call -----------------------------'
E           and: 'in function'
E           and: '--------------------------- Captured stdout teardown ---------------------------'
E           and: 'in teardown'
E           and: '=========================== short test summary info ============================'
E           and: 'FAILED test_capture_scope_cache.py::test_func - assert 0'
E           and: '============================== 1 failed in 0.01s ==============================='
E       remains unmatched: '*Captured stdout during setup*'

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/test_capture.py:196: Failed
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /tmp/pytest-of-tkloczko/pytest-185/test_capture_scope_cache0
collected 1 item

test_capture_scope_cache.py F                                            [100%]

=================================== FAILURES ===================================
__________________________________ test_func ___________________________________

    def test_func():
        print("in function")
>       assert 0
E       assert 0

test_capture_scope_cache.py:8: AssertionError
---------------------------- Captured stdout setup -----------------------------
module-setup
function-setup
----------------------------- Captured stdout call -----------------------------
in function
--------------------------- Captured stdout teardown ---------------------------
in teardown
=========================== short test summary info ============================
FAILED test_capture_scope_cache.py::test_func - assert 0
============================== 1 failed in 0.01s ===============================
___________________________________________________________________ TestPrunetraceback.test_collect_report_postprocessing ___________________________________________________________________

self = <testing.test_collection.TestPrunetraceback object at 0x7f048adae6e0>, pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-185/test_collect_report_postprocessing0')>

    @pytest.mark.xfail(reason="other mechanism for adding to reporting needed")
    def test_collect_report_postprocessing(self, pytester: Pytester) -> None:
        p = pytester.makepyfile(
            """
            import not_exists
        """
        )
        pytester.makeconftest(
            """
            import pytest
            @pytest.hookimpl(wrapper=True)
            def pytest_make_collect_report():
                rep = yield
                rep.headerlines += ["header1"]
                return rep
        """
        )
        result = pytester.runpytest(p)
>       result.stdout.fnmatch_lines(["*ERROR collecting*", "*header1*"])
E       Failed: nomatch: '*ERROR collecting*'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0'
E           and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-185/test_collect_report_postprocessing0'
E           and: 'collected 0 items'
E           and: 'INTERNALERROR> Traceback (most recent call last):'
E           and: 'INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/main.py", line 285, in wrap_session'
E           and: 'INTERNALERROR>     session.exitstatus = doit(config, session) or 0'
E           and: 'INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/main.py", line 338, in _main'
E           and: 'INTERNALERROR>     config.hook.pytest_collection(session=session)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__'
E           and: 'INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec'
E           and: 'INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 480, in traced_hookexec'
E           and: 'INTERNALERROR>     return outcome.get_result()'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_result.py", line 100, in get_result'
E           and: 'INTERNALERROR>     raise exc.with_traceback(exc.__traceback__)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_result.py", line 62, in from_call'
E           and: 'INTERNALERROR>     result = func()'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 477, in <lambda>'
E           and: 'INTERNALERROR>     lambda: oldcall(hook_name, hook_impls, caller_kwargs, firstresult)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall'
E           and: 'INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall'
E           and: 'INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]'
E           and: 'INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/logging.py", line 794, in pytest_collection'
E           and: 'INTERNALERROR>     return (yield)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall'
E           and: 'INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]'
E           and: 'INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/warnings.py", line 120, in pytest_collection'
E           and: 'INTERNALERROR>     return (yield)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall'
E           and: 'INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]'
E           and: 'INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1424, in pytest_collection'
E           and: 'INTERNALERROR>     return (yield)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall'
E           and: 'INTERNALERROR>     res = hook_impl.function(*args)'
E           and: 'INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/main.py", line 349, in pytest_collection'
E           and: 'INTERNALERROR>     session.perform_collect()'
E           and: 'INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/main.py", line 791, in perform_collect'
E           and: 'INTERNALERROR>     rep = collect_one_node(self)'
E           and: 'INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py", line 567, in collect_one_node'
E           and: 'INTERNALERROR>     rep: CollectReport = ihook.pytest_make_collect_report(collector=collector)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__'
E           and: 'INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec'
E           and: 'INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 480, in traced_hookexec'
E           and: 'INTERNALERROR>     return outcome.get_result()'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_result.py", line 100, in get_result'
E           and: 'INTERNALERROR>     raise exc.with_traceback(exc.__traceback__)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_result.py", line 62, in from_call'
E           and: 'INTERNALERROR>     result = func()'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 477, in <lambda>'
E           and: 'INTERNALERROR>     lambda: oldcall(hook_name, hook_impls, caller_kwargs, firstresult)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall'
E           and: 'INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)'
E           and: 'INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 124, in _multicall'
E           and: 'INTERNALERROR>     teardown.send(result)  # type: ignore[union-attr]'
E           and: 'INTERNALERROR>   File "/tmp/pytest-of-tkloczko/pytest-185/test_collect_report_postprocessing0/conftest.py", line 5, in pytest_make_collect_report'
E           and: 'INTERNALERROR>     rep.headerlines += ["header1"]'
E           and: "INTERNALERROR> AttributeError: 'CollectReport' object has no attribute 'headerlines'. Did you mean: 'head_line'?"
E           and: ''
E           and: '============================ no tests ran in 0.03s ============================='
E       remains unmatched: '*ERROR collecting*'

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/test_collection.py:367: Failed
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /tmp/pytest-of-tkloczko/pytest-185/test_collect_report_postprocessing0
collected 0 items
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/main.py", line 285, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/main.py", line 338, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 480, in traced_hookexec
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_result.py", line 100, in get_result
INTERNALERROR>     raise exc.with_traceback(exc.__traceback__)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_result.py", line 62, in from_call
INTERNALERROR>     result = func()
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 477, in <lambda>
INTERNALERROR>     lambda: oldcall(hook_name, hook_impls, caller_kwargs, firstresult)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/logging.py", line 794, in pytest_collection
INTERNALERROR>     return (yield)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/warnings.py", line 120, in pytest_collection
INTERNALERROR>     return (yield)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1424, in pytest_collection
INTERNALERROR>     return (yield)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/main.py", line 349, in pytest_collection
INTERNALERROR>     session.perform_collect()
INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/main.py", line 791, in perform_collect
INTERNALERROR>     rep = collect_one_node(self)
INTERNALERROR>   File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/runner.py", line 567, in collect_one_node
INTERNALERROR>     rep: CollectReport = ihook.pytest_make_collect_report(collector=collector)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 480, in traced_hookexec
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_result.py", line 100, in get_result
INTERNALERROR>     raise exc.with_traceback(exc.__traceback__)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_result.py", line 62, in from_call
INTERNALERROR>     result = func()
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_manager.py", line 477, in <lambda>
INTERNALERROR>     lambda: oldcall(hook_name, hook_impls, caller_kwargs, firstresult)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/usr/lib/python3.10/site-packages/pluggy/_callers.py", line 124, in _multicall
INTERNALERROR>     teardown.send(result)  # type: ignore[union-attr]
INTERNALERROR>   File "/tmp/pytest-of-tkloczko/pytest-185/test_collect_report_postprocessing0/conftest.py", line 5, in pytest_make_collect_report
INTERNALERROR>     rep.headerlines += ["header1"]
INTERNALERROR> AttributeError: 'CollectReport' object has no attribute 'headerlines'. Did you mean: 'head_line'?

============================ no tests ran in 0.03s =============================
_______________________________________________________________________________ TestParseIni.test_confcutdir ________________________________________________________________________________

self = <testing.test_config.TestParseIni object at 0x7f048adecf70>, pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-185/test_confcutdir0')>

    @pytest.mark.xfail(reason="probably not needed")
    def test_confcutdir(self, pytester: Pytester) -> None:
        sub = pytester.mkdir("sub")
        os.chdir(sub)
        pytester.makeini(
            """
            [pytest]
            addopts = --qwe
        """
        )
        result = pytester.inline_run("--confcutdir=.")
>       assert result.ret == 0
E       AssertionError: assert <ExitCode.USAGE_ERROR: 4> == 0
E        +  where <ExitCode.USAGE_ERROR: 4> = <class '_pytest.pytester.Pytester.inline_run.<locals>.reprec'>.ret

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/test_config.py:246: AssertionError
----------------------------------------------------------------------------------- Captured stderr call ------------------------------------------------------------------------------------
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --qwe
  inifile: /tmp/pytest-of-tkloczko/pytest-185/test_confcutdir0/tox.ini
  rootdir: /tmp/pytest-of-tkloczko/pytest-185/test_confcutdir0

___________________________________________________________________ TestLiterals.test_number_non_matches['3.1416'-'3.14'] ___________________________________________________________________

self = <testing.test_doctest.TestLiterals object at 0x7f048b100d90>, pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-185/test_number_non_matches10')>, expression = "'3.1416'"
output = "'3.14'"

    @pytest.mark.parametrize(
        "expression,output",
        [
            # ints shouldn't match floats:
            ("3.0", "3"),
            ("3e0", "3"),
            ("1e3", "1000"),
            ("3", "3.0"),
            # Rounding:
            ("3.1", "3.0"),
            ("3.1", "3.2"),
            ("3.1", "4.0"),
            ("8.22e5", "810000.0"),
            # Only the actual output is rounded up, not the expected output:
            ("3.0", "2.98"),
            ("1e3", "999"),
            # The current implementation doesn't understand that numbers inside
            # strings shouldn't be treated as numbers:
            pytest.param("'3.1416'", "'3.14'", marks=pytest.mark.xfail),
        ],
    )
    def test_number_non_matches(self, pytester, expression, output):
        pytester.maketxtfile(
            test_doc=f"""
            >>> {expression} #doctest: +NUMBER
            {output}
            """
        )
        reprec = pytester.inline_run()
>       reprec.assertoutcome(passed=0, failed=1)
E       AssertionError: ([<TestReport 'test_doc.txt::test_doc.txt' when='call' outcome='passed'>], [], [])
E       assert {'failed': 0,... 'skipped': 0} == {'failed': 1,... 'skipped': 0}
E
E         Omitting 1 identical items, use -vv to show
E         Differing items:
E         {'passed': 1} != {'passed': 0}
E         {'failed': 0} != {'failed': 1}
E         Use -v to get more diff

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/test_doctest.py:1130: AssertionError
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /tmp/pytest-of-tkloczko/pytest-185/test_number_non_matches10
collected 1 item

test_doc.txt .                                                           [100%]

============================== 1 passed in 0.00s ===============================
_______________________________________________________________________ TestKeywordSelection.test_keyword_extra_dash ________________________________________________________________________

self = <testing.test_mark.TestKeywordSelection object at 0x7f048a601870>, pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-185/test_keyword_extra_dash0')>

    @pytest.mark.xfail
    def test_keyword_extra_dash(self, pytester: Pytester) -> None:
        p = pytester.makepyfile(
            """
           def test_one():
               assert 0
           test_one.mykeyword = True
        """
        )
        # with argparse the argument to an option cannot
        # start with '-'
        reprec = pytester.inline_run("-k", "-mykeyword", p)
>       passed, skipped, failed = reprec.countoutcomes()
E       AttributeError: type object 'reprec' has no attribute 'countoutcomes'

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/test_mark.py:851: AttributeError
----------------------------------------------------------------------------------- Captured stderr call ------------------------------------------------------------------------------------
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument -k: expected one argument

__________________________________________________________________________________ test_make_hook_recorder __________________________________________________________________________________

pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-185/test_make_hook_recorder0')>

    def test_make_hook_recorder(pytester: Pytester) -> None:
        item = pytester.getitem("def test_func(): pass")
        recorder = pytester.make_hook_recorder(item.config.pluginmanager)
        assert not recorder.getfailures()

        # (The silly condition is to fool mypy that the code below this is reachable)
        if 1 + 1 == 2:
>           pytest.xfail("internal reportrecorder tests need refactoring")
E           _pytest.outcomes.XFailed: internal reportrecorder tests need refactoring

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/test_pytester.py:28: XFailed
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /tmp/pytest-of-tkloczko/pytest-185/test_make_hook_recorder0
collected 0 items

============================ no tests ran in 0.00s =============================
______________________________________________________________________________ test_runtest_in_module_ordering ______________________________________________________________________________

pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-185/test_runtest_in_module_ordering0')>

    @pytest.mark.xfail
    def test_runtest_in_module_ordering(pytester: Pytester) -> None:
        p1 = pytester.makepyfile(
            """
            import pytest
            def pytest_runtest_setup(item): # runs after class-level!
                item.function.mylist.append("module")
            class TestClass(object):
                def pytest_runtest_setup(self, item):
                    assert not hasattr(item.function, 'mylist')
                    item.function.mylist = ['class']
                @pytest.fixture
                def mylist(self, request):
                    return request.function.mylist
                @pytest.hookimpl(wrapper=True)
                def pytest_runtest_call(self, item):
                    try:
                        yield
                    except ValueError:
                        pass
                def test_hello1(self, mylist):
                    assert mylist == ['class', 'module'], mylist
                    raise ValueError()
                def test_hello2(self, mylist):
                    assert mylist == ['class', 'module'], mylist
            def pytest_runtest_teardown(item):
                del item.function.mylist
        """
        )
        result = pytester.runpytest(p1)
>       result.stdout.fnmatch_lines(["*2 passed*"])
E       Failed: nomatch: '*2 passed*'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0'
E           and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-185/test_runtest_in_module_ordering0'
E           and: 'collected 2 items'
E           and: ''
E           and: 'test_runtest_in_module_ordering.py EE                                    [100%]'
E           and: ''
E           and: '==================================== ERRORS ===================================='
E           and: '___________________ ERROR at setup of TestClass.test_hello1 ____________________'
E           and: ''
E           and: 'self = <test_runtest_in_module_ordering.TestClass object at 0x7f0483f59900>'
E           and: "request = <SubRequest 'mylist' for <Function test_hello1>>"
E           and: ''
E           and: '    @pytest.fixture'
E           and: '    def mylist(self, request):'
E           and: '>       return request.function.mylist'
E           and: "E       AttributeError: 'function' object has no attribute 'mylist'"
E           and: ''
E           and: 'test_runtest_in_module_ordering.py:10: AttributeError'
E           and: '___________________ ERROR at setup of TestClass.test_hello2 ____________________'
E           and: ''
E           and: 'self = <test_runtest_in_module_ordering.TestClass object at 0x7f0483f5a890>'
E           and: "request = <SubRequest 'mylist' for <Function test_hello2>>"
E           and: ''
E           and: '    @pytest.fixture'
E           and: '    def mylist(self, request):'
E           and: '>       return request.function.mylist'
E           and: "E       AttributeError: 'function' object has no attribute 'mylist'"
E           and: ''
E           and: 'test_runtest_in_module_ordering.py:10: AttributeError'
E           and: '=========================== short test summary info ============================'
E           and: 'ERROR test_runtest_in_module_ordering.py::TestClass::test_hello1 - AttributeE...'
E           and: 'ERROR test_runtest_in_module_ordering.py::TestClass::test_hello2 - AttributeE...'
E           and: '============================== 2 errors in 0.02s ==============================='
E       remains unmatched: '*2 passed*'

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/test_runner.py:564: Failed
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /tmp/pytest-of-tkloczko/pytest-185/test_runtest_in_module_ordering0
collected 2 items

test_runtest_in_module_ordering.py EE                                    [100%]

==================================== ERRORS ====================================
___________________ ERROR at setup of TestClass.test_hello1 ____________________

self = <test_runtest_in_module_ordering.TestClass object at 0x7f0483f59900>
request = <SubRequest 'mylist' for <Function test_hello1>>

    @pytest.fixture
    def mylist(self, request):
>       return request.function.mylist
E       AttributeError: 'function' object has no attribute 'mylist'

test_runtest_in_module_ordering.py:10: AttributeError
___________________ ERROR at setup of TestClass.test_hello2 ____________________

self = <test_runtest_in_module_ordering.TestClass object at 0x7f0483f5a890>
request = <SubRequest 'mylist' for <Function test_hello2>>

    @pytest.fixture
    def mylist(self, request):
>       return request.function.mylist
E       AttributeError: 'function' object has no attribute 'mylist'

test_runtest_in_module_ordering.py:10: AttributeError
=========================== short test summary info ============================
ERROR test_runtest_in_module_ordering.py::TestClass::test_hello1 - AttributeE...
ERROR test_runtest_in_module_ordering.py::TestClass::test_hello2 - AttributeE...
============================== 2 errors in 0.02s ===============================
___________________________________________________________________________ TestRequestBasic.test_request_garbage ___________________________________________________________________________

self = <testing.python.fixtures.TestRequestBasic object at 0x7f048c5ceb30>, pytester = <Pytester PosixPath('/tmp/pytest-of-tkloczko/pytest-185/test_request_garbage0')>

    @pytest.mark.skipif(
        hasattr(sys, "pypy_version_info"),
        reason="this method of test doesn't work on pypy",
    )
    def test_request_garbage(self, pytester: Pytester) -> None:
        try:
            import xdist  # noqa: F401
        except ImportError:
            pass
        else:
>           pytest.xfail("this test is flaky when executed with xdist")
E           _pytest.outcomes.XFailed: this test is flaky when executed with xdist

/home/tkloczko/rpmbuild/BUILD/pytest-8.2.1/testing/python/fixtures.py:719: XFailed
========================================================================================== XPASSES ==========================================================================================
================================================================================== short test summary info ==================================================================================
SKIPPED [1] testing/_py/test_local.py:464: sys.version_info < (3,6)
SKIPPED [1] testing/_py/test_local.py:469: sys.version_info < (3,6)
SKIPPED [1] testing/_py/test_local.py:669: case-insensitive only on windows
SKIPPED [1] testing/_py/test_local.py:890: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1242: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1248: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1260: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1266: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1271: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1279: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/_py/test_local.py:1286: condition: not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')
SKIPPED [1] testing/python/approx.py:187: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/python/approx.py:245: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/python/approx.py:271: could not import 'numpy': No module named 'numpy'
SKIPPED [5] testing/python/approx.py:363: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/python/approx.py:678: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/python/approx.py:702: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/python/approx.py:726: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/python/approx.py:744: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/python/approx.py:758: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/python/approx.py:767: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/python/approx.py:788: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/python/approx.py:917: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/python/approx.py:928: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/test_capture.py:1435: only on windows
SKIPPED [1] testing/test_findpaths.py:142: condition: sys.platform != 'win32'
SKIPPED [1] testing/test_tmpdir.py:359: win only
SKIPPED [1] testing/acceptance_test.py:1424: Test is not isolated
SKIPPED [9] testing/code/test_excinfo.py:1665: Native ExceptionGroup not implemented
SKIPPED [1] testing/python/fixtures.py:4501: could not import 'numpy': No module named 'numpy'
SKIPPED [1] testing/python/integration.py:98: could not import 'mock': No module named 'mock'
SKIPPED [1] testing/python/integration.py:149: could not import 'mock': No module named 'mock'
SKIPPED [1] testing/python/integration.py:182: could not import 'mock': No module named 'mock'
SKIPPED [1] testing/python/integration.py:206: could not import 'mock': No module named 'mock'
SKIPPED [1] ../../BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/pathlib.py:473: symlinks not supported: [Errno 17] File exists: '/tmp/pytest-of-tkloczko/pytest-185/test_collect_symlink_dir0/symlink_dir' -> '/tmp/pytest-of-tkloczko/pytest-185/test_collect_symlink_dir0/dir'
SKIPPED [1] testing/test_collection.py:1784: Windows only
SKIPPED [1] testing/test_conftest.py:397: only relevant for case-insensitive file systems
SKIPPED [1] testing/test_doctest.py:1574: could not import 'mock': No module named 'mock'
SKIPPED [1] testing/test_parseopt.py:344: argcomplete not available
SKIPPED [1] testing/test_pathlib.py:547: Windows only
SKIPPED [1] testing/test_pluginmanager.py:108: requires a case-insensitive file system
SKIPPED [1] testing/test_unittest.py:1322: could not import 'asynctest': No module named 'asynctest'
SKIPPED [3] testing/test_warnings.py:518: not relevant until pytest 9.0
SKIPPED [41] ../../BUILDROOT/python-pytest-8.2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/_pytest/pytester.py:1520: could not import 'pexpect': No module named 'pexpect'
SKIPPED [1] testing/test_faulthandler.py:72: sometimes crashes on CI (#7022)
XFAIL testing/_py/test_local.py::TestLocalPath::test_long_filenames - reason: [NOTRUN] unreliable est for long filenames
XFAIL testing/_py/test_local.py::TestUnicode::test_read_write - changing read/write might break existing usages
XFAIL testing/acceptance_test.py::TestInvocationVariants::test_noclass_discovery_if_not_testcase - decide: feature or bug
XFAIL testing/python/fixtures.py::TestAutouseDiscovery::test_setup_enabled_functionnode - 'enabled' feature not implemented
XFAIL testing/test_capture.py::TestPerTestCapturing::test_capture_scope_cache - unimplemented feature
XFAIL testing/test_collection.py::TestPrunetraceback::test_collect_report_postprocessing - other mechanism for adding to reporting needed
XFAIL testing/test_config.py::TestParseIni::test_confcutdir - probably not needed
XFAIL testing/test_doctest.py::TestLiterals::test_number_non_matches['3.1416'-'3.14']
XFAIL testing/test_mark.py::TestKeywordSelection::test_keyword_extra_dash
XFAIL testing/test_pytester.py::test_make_hook_recorder - reason: internal reportrecorder tests need refactoring
XFAIL testing/test_runner.py::test_runtest_in_module_ordering
XFAIL testing/python/fixtures.py::TestRequestBasic::test_request_garbage - reason: this test is flaky when executed with xdist
XPASS testing/_py/test_local.py::TestLocalPath::test_make_numbered_dir_multiprocess_safe - #11603
FAILED testing/logging/test_fixture.py::test_with_statement_filtering - AssertionError: assert ('testing.log...handler call') == ('test_fixtur...handler call')
FAILED testing/python/raises.py::TestRaises::test_raises_exception_looks_iterable - AssertionError: Regex pattern did not match.
======================================================= 2 failed, 3548 passed, 99 skipped, 12 xfailed, 1 xpassed in 205.76s (0:03:25) =======================================================

@kloczek
Copy link
Contributor Author

kloczek commented May 22, 2024

Your traceback points to line 114:

That is correct.
At this point I had my own patch which still been using group.addoption() (my fault that a bit blindly updated my own pytest option patch).

Nevertheless I have now two failing units without my patches (just clean pytest tree)

@nicoddemus
Copy link
Member

I see thanks for clarifying.

The failing tests seem related to how your environment is setup (in special the test about testing.logging.test_fixture vs test_fixture, which is usually related to how Python is importing modules). I'm afraid I cannot help much further than that.

@kloczek
Copy link
Contributor Author

kloczek commented May 22, 2024

he failing tests seem related to how your environment is setup (in special the test about testing.logging.test_fixture vs test_fixture, which is usually related to how Python is importing modules). I'm afraid I cannot help much further than that.

Does it mean that this procedure with self test will be no longer valid? 🤔
It was really useful ..

@nicoddemus
Copy link
Member

nicoddemus commented May 22, 2024

Does it mean that this procedure with self test will be no longer valid? 🤔

AFAIK it was never officially supported?

pytest officially supports being installed via pip -- not even other popular methods like conda are officially supported, but are known to work. Unfortunately maintainer's time is limited so we need to narrow what we can support officially.

@kloczek
Copy link
Contributor Author

kloczek commented May 22, 2024

AFAIK it was never officially supported?

Lets say that it was accepted and kind of actively supported 😋
I understand kind of weak support for that procedure and only have question: do you want me to inform about any changes in result of that procedure against next versions? 🤔

Self test is useful for packaging procedures because it allows build, install and test in on pass as long as packaging procedures have no permission to change build system image.

@nicoddemus
Copy link
Member

do you want me to inform about any changes in result of that procedure against next versions? 🤔

It is not very actionable on our side, to be honest.

Self test is useful for packaging procedures

Sorry to ask, but "self test" here is the name of a standard procedure that I'm not aware of, or is how you call your procedure you use to test pytest itself?

@kloczek
Copy link
Contributor Author

kloczek commented May 22, 2024

Packaging procedure steps:

  • take tar ball from git tar ball and unpack
  • python3 -sBm build -w --no-isolation
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix> using installer module
  • set $PATH and with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
  • run pytest with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

Above allows to build and test without install pytest in system image and all can be performed from non-root account.

@RonnyPfannschmidt
Copy link
Member

whats the process fedora/rhel use, and how does it differ from yours

in my experience with rpm packaging its important to follow the example of fedora/rhel/centos for one primary concern - redhat is one of the few downstream's that ensures correct packaging in case of icky details and they ensure patches/fixes that often go upstream

leveraging the engineering time redhat spend on both the packaging mechanisms and the upstreamapatches is a pretty good way to manage risk, in particular if you deal with your own package set without the same manpower in packaging engineering

@kloczek
Copy link
Contributor Author

kloczek commented May 23, 2024

I share the same testing methodology as fedora uses in most of the packages with python modules.
Methodology is called "test as installed" which is not using tox/nox (env isolation does not make sense in such cases because build process is isolated env by definition).
In my case difference is that I'm using pytest with +99% of all python modules (even with those which have no pytest units) when in Fedora it test suite is used only with less than 30%.

[tkloczko@pers-jacek SPECS.fedora]$ ls -1 python-*.spec | wc -l; grep ^%pytest python-*.spec | wc -l
3297
1163
[tkloczko@pers-jacek SPECS]$ ls -1 python-*.spec | wc -l; grep ^%pytest python-*.spec | wc -l
1251
1234

Whole build process is performed from non-root account without possibility switching to root.

in my experience with rpm packaging its important to follow the example of fedora/rhel/centos for one primary concern

Here is %check section of the pytest.spec from Fedora. It checks only is module importable or not,

%check
%if %{with tests}
%global __pytest %{buildroot}%{_bindir}/pytest
# optional_tests deps contain pytest-xdist, so we can use it to run tests faster
%pytest testing %{?with_timeout:--timeout=30} %{?with_optional_tests:-n auto} -rs
%else
%pyproject_check_import
%endif

Test suites executions of the packages are VERY impotent because because they are allow to catch faulty not only just packaged resources but all other components involved in test suite execution.

@kloczek
Copy link
Contributor Author

kloczek commented May 23, 2024

I have question about my own patch which started this ticket.
I need option to handle pytest exit with exit code 0 if there is no any units (just to hahe possibility use that as scaffolding to be able perform for example pytest execution with pytrst-black or other pytest extension.
Looks like parser.addini() should not be used instead group.addoption() and I'm struggling with locate where this should be hooked.
Here is my (incorrect) patch

--- a/src/_pytest/main.py
+++ b/src/_pytest/main.py
@@ -323,7 +323,7 @@

     if session.testsfailed:
         return ExitCode.TESTS_FAILED
-    elif session.testscollected == 0:
+    elif session.testscollected == 0 and not session.config.getoption("exit_0_if_no_units"):
         return ExitCode.NO_TESTS_COLLECTED
     return None

--- a/src/_pytest/python.py
+++ b/src/_pytest/python.py
@@ -111,6 +111,12 @@
         help="Disable string escape non-ASCII characters, might cause unwanted "
         "side effects(use at your own risk)",
     )
+    parser.addini(
+        "--exit-0-if-no-units",
+        type="args",
+        default=False,
+        help="finish with exit 0 if there is no test units",
+    )


 def pytest_generate_tests(metafunc: "Metafunc") -> None:
``
May I ask about hint where `--exit-0-if-no-units` command line param should be hooked? 🤔 

@The-Compiler
Copy link
Member

Use a plugin instead and don't patch pytest at all (especially when you don't understand that your patching is causing issues, and then open issues without mentioning that you're patching things). See #2393.

@kloczek
Copy link
Contributor Author

kloczek commented May 23, 2024

In my case I need that OOTB and not only as the option when extension is installed.
I think that I manage to update my patch

--- a/src/_pytest/main.py
+++ b/src/_pytest/main.py
@@ -323,7 +323,7 @@

     if session.testsfailed:
         return ExitCode.TESTS_FAILED
-    elif session.testscollected == 0:
+    elif session.testscollected == 0 and not session.config.getoption("exit_0_if_no_units"):
         return ExitCode.NO_TESTS_COLLECTED
     return None

--- a/src/_pytest/main.py
+++ b/src/_pytest/main.py
@@ -229,6 +229,13 @@
         default=False,
         help="Consider namespace packages when resolving module names during import",
     )
+    group.addoption(
+        "--exit-0-if-no-units",
+        action="store_true",
+        dest="exit_0_if_no_units",
+        default=False,
+        help="finish with exit 0 if there is no test units",
+    )

     group = parser.getgroup("debugconfig", "test session debugging and configuration")
     group.addoption(
```

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

No branches or pull requests

4 participants