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
PytestAssertRewriteWarning breaks test_apply_tag_hook #453
Comments
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 %_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 |
(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 |
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!
The text was updated successfully, but these errors were encountered: