pytest-dev / pytest-django

A Django plugin for pytest.
https://pytest-django.readthedocs.io/
Other
1.33k stars 341 forks source link

self-tests fail against Pytest 7 #995

Closed stanislavlevin closed 2 years ago

stanislavlevin commented 2 years ago

1 test fails on migration to Pytest 7:

=================================== FAILURES ===================================
______________ test_django_project_found_invalid_settings_version ______________

django_testdir = <Testdir local('/usr/src/tmp/pytest-of-builder/pytest-0/test_django_project_found_invalid_settings_version0')>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f2af96481f0>

    @pytest.mark.django_project(project_root="django_project_root", create_manage_py=True)
    def test_django_project_found_invalid_settings_version(django_testdir, monkeypatch) -> None:
        """Invalid DSM should not cause an error with --help or --version."""
        monkeypatch.setenv("DJANGO_SETTINGS_MODULE", "DOES_NOT_EXIST")

        result = django_testdir.runpytest_subprocess("django_project_root", "--version", "--version")
        assert result.ret == 0
>       result.stderr.fnmatch_lines(["*This is pytest version*"])
E       Failed: remains unmatched: '*This is pytest version*'

/usr/src/RPM/BUILD/python3-module-pytest-django-4.5.2/tests/test_manage_py_scan.py:121: Failed
----------------------------- Captured stdout call -----------------------------
running: /usr/src/RPM/BUILD/python3-module-pytest-django-4.5.2/.tox/py3/bin/python -mpytest --basetemp=/usr/src/tmp/pytest-of-builder/pytest-0/test_django_project_found_invalid_settings_version0/runpytest-0 django_project_root --version --version
     in: /usr/src/tmp/pytest-of-builder/pytest-0/test_django_project_found_invalid_settings_version0
This is pytest version 7.0.1, imported from /usr/lib/python3/site-packages/pytest/__init__.py
setuptools registered plugins:
  pytest-django-4.5.2 at /usr/src/RPM/BUILD/python3-module-pytest-django-4.5.2/pytest_django/plugin.py

https://docs.pytest.org/en/7.0.x/changelog.html#breaking-changes:

pytest#8246: --version now writes version information to stdout rather than stderr.