Closed musicinmybrain closed 4 days ago
The new version of pip does in-tree builds by default. Maybe some files exist twice on the sys.path now and that triggers the warning?
The new version of pip does in-tree builds by default. Maybe some files exist twice on the sys.path now and that triggers the warning?
Thanks, it does appear to be related to that change. As a hacky test (Fedora-specific RPM macro talk ahead) I can replace %pyproject_wheel
with its expansion and add --use-deprecated=out-of-tree-build
to the pip arguments, such that the whole expansion looks like:
%_set_pytest_addopts
mkdir -p "%{_pyproject_builddir}"
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" TMPDIR="%{_pyproject_builddir}" \
%{__python3} -m pip wheel --wheel-dir %{_pyproject_wheeldir} --no-deps --use-pep517 --no-build-isolation --disable-pip-version-check --no-clean --progress-bar off --verbose --use-deprecated=out-of-tree-build .
and the warning disappears. Obviously, that’s not a practical approach—both because hard-coding the expansion is not ideal and because, more importantly, the --use-deprecated=out-of-tree-build
option is supposed to go away at some point—but it does narrow down the cause, even though I have still not managed to reproduce the warning outside of a Fedora RPM build.
(Edited my previous comment to remove some things that were not true, because I accidentally stopped building with pip 21.3 while testing.)
These are things that do not work around the warning:
mv pytest_bdd _pytest_bdd.noimport
%tox
mkdir -p _empty && cd _empty
%pytest ../tests
rm -rf pytest_bdd
%tox
These are things that do work around the warning:
mkdir -p _empty && cp -rp tests *.ini _empty && cd _empty
%tox
(I’m now doing the above in the Fedora package instead of loosening the glob.)
mkdir -p _empty && cp -rp tests _empty && cd _empty
%pytest
Hello @musicinmybrain!
I appreciate it has been a long time, but is this still an issue?
Hello @musicinmybrain!
I appreciate it has been a long time, but is this still an issue?
Great question! Thanks for checking in on this issue.
I just tried removing the workaround described in https://github.com/pytest-dev/pytest-bdd/issues/453#issuecomment-944385209 and test-building RPM packages of pytest-bdd 7.3.0 in Fedora Rawhide/42 and 41 (with pip 24.2 and pytest 8.3.3), 40 (with pip 23.3.2 and pytest 7.4.3), and 39 (with pip 23.2.1 and pytest 7.3.2). All succeeded.
I suppose that means that this has been fixed somewhere. 🤷
Fab! If it appears as an issue feel free to raise a new issue or reopen
This is a bit of a strange one, in that it’s hard to reproduce. I’m the maintainer of the
python-pytest-bdd
package in Fedora Linux, and I’m seeing a test failure associated with Fedora’s update to pip 21.3.All of the other tests still pass. As you can see, the glob
'*= 1 skipped, 1 xpassed * =*'
does not match= 1 skipped, 1 xpassed, 1 warning in 0.01s =
due to the unexpectedPytestAssertRewriteWarning
. I’m not sure why this should be triggered by an update of pip.Annoyingly, I can’t seem to reproduce this in a plain Python 3.10 virtualenv, using pip 21.3 and pip-installed dependency instead of Fedora-packaged ones.
I found that pytest-cov had a similar issue several years ago and worked around it by adding
PYTEST_DONT_REWRITE
to the module docstringpytest_cov/__init__.py
.I can confirm that adding
PYTEST_DONT_REWRITE
to the docstring inpytest_bdd/__init__.py
does fix the unexpected warning, but I don’t really understand the pytest rewriting system, so I don’t know if this would have unintended consequences.Alternatively, either skipping
test_apply_tag_hook
or loosening the glob very subtly to'*= 1 skipped, 1 xpassed* =*'
can work around the issue.For now, I’m loosening the glob in the test.
I’m curious:
pytest-bdd
needs any changes upstream based on this reportThanks!