pyproject-api icon indicating copy to clipboard operation
pyproject-api copied to clipboard

1.7.1: pytest fails in 2 units

Open kloczek opened this issue 1 year ago • 1 comments

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-pyproject-api-1.7.1-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pyproject-api-1.7.1-2.fc37.x86_64/usr/lib/python3.10/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.10.14, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pyproject-api-1.7.1
configfile: pyproject.toml
plugins: mock-3.14.0
collected 59 items

tests/test_backend.py ........                                           [ 13%]
tests/test_frontend.py .............................                     [ 62%]
tests/test_frontend_setuptools.py .F.F......                             [ 79%]
tests/test_main.py .......                                               [ 91%]
tests/test_util.py ....                                                  [ 98%]
tests/test_version.py .                                                  [100%]

=================================== FAILURES ===================================
_________________ test_setuptools_get_requires_for_build_wheel _________________

frontend_setuptools = <pyproject_api._via_fresh_subprocess.SubprocessFrontend object at 0x7f292fe3ba90>

    def test_setuptools_get_requires_for_build_wheel(frontend_setuptools: SubprocessFrontend) -> None:
        result = frontend_setuptools.get_requires_for_build_wheel()
>       assert not result.requires
E       assert not (<Requirement('wheel')>,)
E        +  where (<Requirement('wheel')>,) = RequiresBuildWheelResult(requires=(<Requirement('wheel')>,), out="started backend BackendProxy(backend=<module 'setupt...t'\nBackend: Wrote response {'return': ['wheel']} to /tmp/pep517_get_requires_for_build_wheel-ec7ekdym.json\n", err='').requires

tests/test_frontend_setuptools.py:61: AssertionError
_________________________ test_setuptools_build_sdist __________________________

frontend_setuptools = <pyproject_api._via_fresh_subprocess.SubprocessFrontend object at 0x7f292fe3ba90>
tmp_path = PosixPath('/tmp/pytest-of-tkloczko/pytest-73/test_setuptools_build_sdist0')

    def test_setuptools_build_sdist(frontend_setuptools: SubprocessFrontend, tmp_path: Path) -> None:
        result = frontend_setuptools.build_sdist(tmp_path)
        sdist = result.sdist
        assert sdist.exists()
        assert sdist.is_file()
>       assert sdist.name == "demo-1.0.tar.gz"
E       AssertionError: assert 'demo-1.tar.gz' == 'demo-1.0.tar.gz'
E
E         - demo-1.0.tar.gz
E         ?        --
E         + demo-1.tar.gz

tests/test_frontend_setuptools.py:93: AssertionError
=========================== short test summary info ============================
FAILED tests/test_frontend_setuptools.py::test_setuptools_get_requires_for_build_wheel
FAILED tests/test_frontend_setuptools.py::test_setuptools_build_sdist - Asser...
========================= 2 failed, 57 passed in 5.20s =========================
List of installed modules in build env:
Package                       Version
----------------------------- -----------
alabaster                     0.7.16
Babel                         2.15.0
build                         1.2.1
charset-normalizer            3.3.2
defusedxml                    0.7.1
distro                        1.9.0
docutils                      0.20.1
exceptiongroup                1.1.3
hatch-vcs                     0.4.0
hatchling                     1.24.2
imagesize                     1.4.1
importlib_metadata            7.2.0
iniconfig                     2.0.0
installer                     0.7.0
Jinja2                        3.1.4
MarkupSafe                    2.1.5
packaging                     24.0
pathspec                      0.12.1
pluggy                        1.5.0
Pygments                      2.18.0
pyproject_hooks               1.0.0
pytest                        8.2.2
pytest-mock                   3.14.0
python-dateutil               2.9.0.post0
requests                      2.32.3
setuptools                    69.4.0
setuptools-scm                8.1.0
snowballstemmer               2.2.0
Sphinx                        7.3.7
sphinx-autodoc-typehints      2.2.1
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
tokenize_rt                   5.2.0
tomli                         2.0.1
trove-classifiers             2024.6.19
urllib3                       2.2.2
wheel                         0.43.0
zipp                          3.19.2

Please let me know if you need more details or want me to perform some diagnostics.

kloczek avatar Jun 22 '24 05:06 kloczek

I do see the test_setuptools_get_requires_for_build_wheel failure too on OpenIndiana. The test_setuptools_build_sdist test pass here. Tested with setuptools 70.0.0.

mtelka avatar Jun 23 '24 10:06 mtelka

Both test_setuptools_get_requires_for_build_wheel and test_setuptools_build_sdist pass here with pyproject-api 1.7.2.

mtelka avatar Sep 18 '24 13:09 mtelka

Just tested 1.7.2 and pytest still fails in one unit.

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pyproject-api-1.7.2-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pyproject-api-1.7.2-2.fc37.x86_64/usr/lib/python3.10/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.10.14, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pyproject-api-1.7.2
configfile: pyproject.toml
plugins: mock-3.14.0
collected 59 items

tests/test_backend.py ........                                           [ 13%]
tests/test_frontend.py .............................                     [ 62%]
tests/test_frontend_setuptools.py ..F.......                             [ 79%]
tests/test_main.py .......                                               [ 91%]
tests/test_util.py ....                                                  [ 98%]
tests/test_version.py .                                                  [100%]

=================================== FAILURES ===================================
_______________ test_setuptools_prepare_metadata_for_build_wheel _______________

frontend_setuptools = <pyproject_api._via_fresh_subprocess.SubprocessFrontend object at 0x7fb3462943a0>
tmp_path = PosixPath('/tmp/pytest-of-tkloczko/pytest-34/test_setuptools_prepare_metada0')

    def test_setuptools_prepare_metadata_for_build_wheel(frontend_setuptools: SubprocessFrontend, tmp_path: Path) -> None:
        meta = tmp_path / "meta"
        result = frontend_setuptools.prepare_metadata_for_build_wheel(metadata_directory=meta)
        assert result is not None
        dist = Distribution.at(str(result.metadata))
        assert list(dist.entry_points) == [EntryPoint(name="demo_exe", value="demo:a", group="console_scripts")]
        assert dist.version == "1.0"
        assert dist.metadata["Name"] == "demo"
        values = [v for k, v in dist.metadata.items() if k == "Requires-Dist"]  # type: ignore[attr-defined]
        # ignore because "PackageMetadata" has no attribute "items"
>       assert sorted(values) == ["magic >3", "requests >2"]
E       AssertionError: assert ['magic>3', 'requests>2'] == ['magic >3', 'requests >2']
E
E         At index 0 diff: 'magic>3' != 'magic >3'
E         Use -v to get more diff

tests/test_frontend_setuptools.py:76: AssertionError
=========================== short test summary info ============================
FAILED tests/test_frontend_setuptools.py::test_setuptools_prepare_metadata_for_build_wheel
========================= 1 failed, 58 passed in 5.01s =========================
/usr/lib/python3.10/site-packages/_pytest/pathlib.py:98: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-718f4e7a-7d12-42c5-9cdb-bf9ab12acb11/test_static_directory_without_0
<class 'OSError'>: [Errno 39] Directory not empty: 'test_static_directory_without_0'
  warnings.warn(
/usr/lib/python3.10/site-packages/_pytest/pathlib.py:98: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-718f4e7a-7d12-42c5-9cdb-bf9ab12acb11/test_static_directory_without_1
<class 'OSError'>: [Errno 39] Directory not empty: 'test_static_directory_without_1'
  warnings.warn(
/usr/lib/python3.10/site-packages/_pytest/pathlib.py:98: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-718f4e7a-7d12-42c5-9cdb-bf9ab12acb11
<class 'OSError'>: [Errno 39] Directory not empty: '/tmp/pytest-of-tkloczko/garbage-718f4e7a-7d12-42c5-9cdb-bf9ab12acb11'
  warnings.warn(

kloczek avatar Sep 18 '24 20:09 kloczek

Just tested 1.7.2 and pytest still fails in one unit.

Yes. This failure is different than those two you reported for 1.7.1 and it is tracked as #153.

mtelka avatar Sep 18 '24 20:09 mtelka

OK so this ticket can be closed (I've subscribed to #153). Thank you.

PS. I've dropped you trivial PR with filter all code over pyupgrade.

kloczek avatar Sep 18 '24 20:09 kloczek