Skip to content

0.22.0: pytest fails in two units #283

@kloczek

Description

@kloczek

What happened? What is the problem?

Looks like pytest fails in two units.

What did you expect to happen?

pytest should not fail.

Example URL(s)

N/A

Steps to reproduce

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • 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
  • run pytest with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
  • build is performed in env which is cut off from access to the public network (pytest is executed with -m "not network")

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-specfile-0.22.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-specfile-0.22.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.18, pytest-7.4.0, pluggy-1.3.0
rootdir: /home/tkloczko/rpmbuild/BUILD/specfile-0.22.0
collected 272 items

tests/integration/test_specfile.py .......................................                                                                                                            [ 14%]
tests/performance/test_parse.py F                                                                                                                                                     [ 14%]
tests/unit/test_changelog.py ....................................                                                                                                                     [ 27%]
tests/unit/test_conditions.py ....                                                                                                                                                    [ 29%]
tests/unit/test_formatter.py ...........                                                                                                                                              [ 33%]
tests/unit/test_guess_packager.py .........                                                                                                                                           [ 36%]
tests/unit/test_macro_definitions.py .....                                                                                                                                            [ 38%]
tests/unit/test_macros.py ....F                                                                                                                                                       [ 40%]
tests/unit/test_options.py .....................                                                                                                                                      [ 48%]
tests/unit/test_prep.py ................                                                                                                                                              [ 54%]
tests/unit/test_sections.py ............                                                                                                                                              [ 58%]
tests/unit/test_sourcelist.py ...                                                                                                                                                     [ 59%]
tests/unit/test_sources.py ...............................................                                                                                                            [ 76%]
tests/unit/test_spec_parser.py ....                                                                                                                                                   [ 78%]
tests/unit/test_specfile.py ..........                                                                                                                                                [ 81%]
tests/unit/test_tags.py ....                                                                                                                                                          [ 83%]
tests/unit/test_utils.py ............................                                                                                                                                 [ 93%]
tests/unit/test_value_parser.py .................                                                                                                                                     [100%]

========================================================================================= FAILURES ==========================================================================================
__________________________________________________________________________________ test_parse_texlive_spec __________________________________________________________________________________

    @pytest.mark.fail_slow(30)
    def test_parse_texlive_spec():
>       spec = Specfile("/tmp/texlive.spec")

tests/performance/test_parse.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
specfile/specfile.py:67: in __init__
    self._lines = self._read_lines(self._path)
specfile/specfile.py:106: in _read_lines
    return path.read_text(encoding="utf8", errors="surrogateescape").splitlines()
/usr/lib64/python3.8/pathlib.py:1236: in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
/usr/lib64/python3.8/pathlib.py:1222: in open
    return io.open(self, mode, buffering, encoding, errors, newline,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = PosixPath('/tmp/texlive.spec'), name = '/tmp/texlive.spec', flags = 524288, mode = 438

    def _opener(self, name, flags, mode=0o666):
        # A stub for the opener argument to built-in open()
>       return self._accessor.open(self, flags, mode)
E       FileNotFoundError: [Errno 2] No such file or directory: '/tmp/texlive.spec'

/usr/lib64/python3.8/pathlib.py:1078: FileNotFoundError
____________________________________________________________________________________ test_macros_reinit _____________________________________________________________________________________

    def test_macros_reinit():
        Macros.reinit(MacroLevel.BUILTIN)
>       assert all(m.level == MacroLevel.BUILTIN for m in Macros.dump())
E       assert False
E        +  where False = all(<generator object test_macros_reinit.<locals>.<genexpr> at 0x7f15ca04b200>)

tests/unit/test_macros.py:112: AssertionError
===================================================================================== warnings summary ======================================================================================
tests/performance/test_parse.py:9
  /home/tkloczko/rpmbuild/BUILD/specfile-0.22.0/tests/performance/test_parse.py:9: PytestUnknownMarkWarning: Unknown pytest.mark.fail_slow - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.fail_slow(30)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ==================================================================================
FAILED tests/performance/test_parse.py::test_parse_texlive_spec - FileNotFoundError: [Errno 2] No such file or directory: '/tmp/texlive.spec'
FAILED tests/unit/test_macros.py::test_macros_reinit - assert False
========================================================================= 2 failed, 270 passed, 1 warning in 4.04s ==========================================================================

Here is list of installed modules in build env

Package                    Version
-------------------------- -------
build                      0.10.0
distro                     1.8.0
exceptiongroup             1.1.3
flexmock                   0.11.3
gpg                        1.21.0
iniconfig                  2.0.0
installer                  0.7.0
libcomps                   0.1.19
packaging                  23.1
pkg                        0.0.0
pluggy                     1.3.0
pyproject_hooks            1.0.0
pytest                     7.4.0
python-dateutil            2.8.2
setuptools                 68.0.0
setuptools-scm             7.1.0
setuptools-scm-git-archive 1.4
six                        1.16.0
tomli                      2.0.1
typing_extensions          4.7.1
wheel                      0.41.1

Workaround

  • There is an existing workaround that can be used until this issue is fixed.

Participation

  • I am willing to submit a pull request for this issue. (Packit team is happy to help!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/generalNot tied to a specific areacomplexity/single-taskRegular task; should be done within daysgain/lowDoesn't bring much value to usersimpact/lowAffects only few of the userskind/bugAn unexpected problem or behavior

    Type

    No type

    Projects

    Status

    backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions