Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-pytest-xvfb for openSUSE:Factory checked in at 2023-09-29 21:12:50 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pytest-xvfb (Old) and /work/SRC/openSUSE:Factory/.python-pytest-xvfb.new.28202 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-pytest-xvfb" Fri Sep 29 21:12:50 2023 rev:9 rq:1114075 version:3.0.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pytest-xvfb/python-pytest-xvfb.changes 2023-06-12 15:24:53.318497258 +0200 +++ /work/SRC/openSUSE:Factory/.python-pytest-xvfb.new.28202/python-pytest-xvfb.changes 2023-09-29 21:13:13.120979783 +0200 @@ -1,0 +2,19 @@ +Wed Sep 27 10:03:35 UTC 2023 - Ben Greiner <code@bnavigator.de> + +- Update to 3.0.0 + * New --xvfb-backend argument, which can be used to run Xephyr or + Xvnc in place of Xvfb (e.g. for visual inspection but on a + remote system or a consistent screen size needed). + * Support for Python 3.5 and 3.6 is now dropped, while official + support for 3.9, 3.10 and 3.11 was added (with no code chances + required). + * The Xvfb instance is now no longer saved in pytest's config + object as config.xvfb anymore, and only available via the xvfb + fixture. + * Xvfb is now shut down as late as possible (via an atexit hook + registered at import time), seemingly avoiding errors such as + "XIO: fatal IO error 0 (Success)". + * Code reformatting using black/shed. + * Packaging refresh using pyproject.toml. + +------------------------------------------------------------------- Old: ---- LICENSE pytest-xvfb-2.0.0.tar.gz New: ---- pytest-xvfb-3.0.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pytest-xvfb.spec ++++++ --- /var/tmp/diff_new_pack.wpQXCr/_old 2023-09-29 21:13:14.345023947 +0200 +++ /var/tmp/diff_new_pack.wpQXCr/_new 2023-09-29 21:13:14.345023947 +0200 @@ -18,21 +18,22 @@ %{?sle15_python_module_pythons} Name: python-pytest-xvfb -Version: 2.0.0 +Version: 3.0.0 Release: 0 Summary: Pytest plugin to run Xvfb for tests License: MIT URL: https://github.com/The-Compiler/pytest-xvfb Source: https://files.pythonhosted.org/packages/source/p/pytest-xvfb/pytest-xvfb-%{version}.tar.gz -# https://github.com/The-Compiler/pytest-xvfb/pull/26 -Source1: https://raw.githubusercontent.com/The-Compiler/pytest-xvfb/master/LICENSE -BuildRequires: %{python_module PyVirtualDisplay >= 0.3} +BuildRequires: %{python_module PyVirtualDisplay >= 1.3} +BuildRequires: %{python_module base >= 3.7} +BuildRequires: %{python_module pip} BuildRequires: %{python_module pytest >= 2.8.1} -BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module setuptools >= 61.2} +BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros BuildRequires: xvfb-run -Requires: python-PyVirtualDisplay >= 0.3 +Requires: python-PyVirtualDisplay >= 1.3 Requires: python-pytest >= 2.8.1 Requires: xdpyinfo Recommends: xorg-x11-server @@ -57,21 +58,23 @@ %prep %setup -q -n pytest-xvfb-%{version} rm tests/test_xvfb_windows.py -cp %{SOURCE1} . %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check -# test_failing_start fails on i586 -%pytest -k 'not test_failing_start' +# can't test this on obs +donttest="test_empty_display or test_no_xvfb_marker or test_xvfb_with_xauth" +%pytest -k "not ($donttest)" %files %{python_files} %license LICENSE %doc README.rst -%{python_sitelib}/* +%{python_sitelib}/pytest_xvfb.py +%pycache_only %{python_sitelib}/__pycache__/pytest_xvfb*.pyc +%{python_sitelib}/pytest_xvfb-%{version}.dist-info ++++++ pytest-xvfb-2.0.0.tar.gz -> pytest-xvfb-3.0.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/CHANGELOG.rst new/pytest-xvfb-3.0.0/CHANGELOG.rst --- old/pytest-xvfb-2.0.0/CHANGELOG.rst 2020-06-09 19:16:09.000000000 +0200 +++ new/pytest-xvfb-3.0.0/CHANGELOG.rst 2023-05-29 13:54:19.000000000 +0200 @@ -1,6 +1,22 @@ pytest-xvfb changelog ===================== +v3.0.0 +------ + +- New ``--xvfb-backend`` argument, which can be used to run Xephyr or Xvnc in + place of Xvfb (e.g. for visual inspection but on a remote system or a + consistent screen size needed). +- Support for Python 3.5 and 3.6 is now dropped, while official support for 3.9, + 3.10 and 3.11 was added (with no code chances required). +- The ``Xvfb`` instance is now no longer saved in pytest's ``config`` object as + ``config.xvfb`` anymore, and only available via the ``xvfb`` fixture. +- Xvfb is now shut down as late as possible (via an ``atexit`` hook registered + at import time), seemingly avoiding errors such as + "XIO: fatal IO error 0 (Success)". +- Code reformatting using black/shed. +- Packaging refresh using ``pyproject.toml``. + v2.0.0 ------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/LICENSE new/pytest-xvfb-3.0.0/LICENSE --- old/pytest-xvfb-2.0.0/LICENSE 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-xvfb-3.0.0/LICENSE 2023-05-29 13:54:19.000000000 +0200 @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Florian Bruhin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/MANIFEST.in new/pytest-xvfb-3.0.0/MANIFEST.in --- old/pytest-xvfb-2.0.0/MANIFEST.in 2020-06-09 19:16:09.000000000 +0200 +++ new/pytest-xvfb-3.0.0/MANIFEST.in 2023-05-29 13:54:19.000000000 +0200 @@ -1,2 +1,3 @@ include CHANGELOG.rst +include LICENSE recursive-include tests *.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/PKG-INFO new/pytest-xvfb-3.0.0/PKG-INFO --- old/pytest-xvfb-2.0.0/PKG-INFO 2020-06-09 19:16:19.892358800 +0200 +++ new/pytest-xvfb-3.0.0/PKG-INFO 2023-05-29 13:54:26.292681200 +0200 @@ -1,120 +1,124 @@ -Metadata-Version: 1.2 +Metadata-Version: 2.1 Name: pytest-xvfb -Version: 2.0.0 -Summary: A pytest plugin to run Xvfb for tests. -Home-page: https://github.com/The-Compiler/pytest-xvfb -Author: Florian Bruhin -Author-email: me@the-compiler.org -Maintainer: Florian Bruhin -Maintainer-email: me@the-compiler.org +Version: 3.0.0 +Summary: A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. +Author-email: Florian Bruhin <me@the-compiler.org> +Maintainer-email: Florian Bruhin <me@the-compiler.org> License: MIT -Description: pytest-xvfb - =================================== - - .. image:: https://travis-ci.org/The-Compiler/pytest-xvfb.svg?branch=master - :target: https://travis-ci.org/The-Compiler/pytest-xvfb - :alt: See Build Status on Travis CI - - .. image:: https://ci.appveyor.com/api/projects/status/github/The-Compiler/pytest-xvfb?... - :target: https://ci.appveyor.com/project/The-Compiler/pytest-xvfb/branch/master - :alt: See Build Status on AppVeyor - - A pytest plugin to run Xvfb for tests. - - ---- - - Installation - ------------ - - You can install "`pytest-xvfb`_" via `pip`_ from `PyPI`_:: - - $ pip install pytest-xvfb - - - Usage - ----- - - With Xvfb and the plugin installed, your testsuite automatically runs with `Xvfb`_. This allows tests to be run without windows popping up during GUI tests or on systems without a display (like a CI). - - If Xvfb is not installed, the plugin does not run and your tests will still work as normal. However, - a warning message will print to standard output letting you know that Xvfb is not installed. - - If you're currently using ``xvfb-run`` in something like ``.travis.yml``, - simply remove it and install this plugin instead - then you'll also have the - benefits of Xvfb locally. - - Features - -------- - - You can pass ``--no-xvfb`` to explicitly turn off Xvfb (e.g. to visually - inspect a failure). - - You can mark tests with ``@pytest.mark.no_xvfb`` to skip them when they're - running with Xvfb. - - A ``xvfb`` fixture is available with the following attributes: - - - ``width``: The configured width of the screen. - - ``height``: The configured height of the screen. - - ``colordepth``: The configured colordepth of the screen. - - ``args``: The arguments to be passed to Xvfb. - - ``display``: The display number (as int) which is used. - - Contributing - ------------ - - Contributions are very welcome. Tests can be run with `tox`_, please ensure - the coverage at least stays the same before you submit a pull request. - - License - ------- - - Distributed under the terms of the `MIT`_ license, "pytest-xvfb" is free and open source software - - Thanks - ------ - - This `pytest`_ plugin was generated with `Cookiecutter`_ along with - `@hackebrot`_'s `Cookiecutter-pytest-plugin`_ template. - - Thanks to `@cgoldberg`_ for `xvfbwrapper`_ which was the inspiration for this - project. - - Issues - ------ - - If you encounter any problems, please `file an issue`_ along with a detailed description. - - .. _`pytest-xvfb`: https://pypi.python.org/pypi/pytest-xvfb/ - .. _`Xvfb`: http://www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml - .. _`Cookiecutter`: https://github.com/audreyr/cookiecutter - .. _`@hackebrot`: https://github.com/hackebrot - .. _`@cgoldberg`: https://github.com/cgoldberg - .. _`xvfbwrapper`: https://github.com/cgoldberg/xvfbwrapper - .. _`MIT`: http://opensource.org/licenses/MIT - .. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause - .. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt - .. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0 - .. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin - .. _`file an issue`: https://github.com/The-Compiler/pytest-xvfb/issues - .. _`pytest`: https://github.com/pytest-dev/pytest - .. _`tox`: https://tox.readthedocs.org/en/latest/ - .. _`pip`: https://pypi.python.org/pypi/pip/ - .. _`PyPI`: https://pypi.python.org/pypi - -Platform: UNKNOWN +Project-URL: Homepage, https://github.com/The-Compiler/pytest-xvfb Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Topic :: Software Development :: Testing Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.5 -Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: MIT License -Requires-Python: >=3.5 +Requires-Python: >=3.7 +Description-Content-Type: text/x-rst +License-File: LICENSE + +pytest-xvfb +=================================== + +A pytest plugin to run `Xvfb`_ (or `Xephyr`_/`Xvnc`_) for tests. + +---- + +Installation +------------ + +You can install "`pytest-xvfb`_" via `pip`_ from `PyPI`_:: + + $ pip install pytest-xvfb + + +Usage +----- + +With Xvfb and the plugin installed, your testsuite automatically runs with `Xvfb`_. This allows tests to be run without windows popping up during GUI tests or on systems without a display (like a CI). + +The plugin sees Xvfb being installed as "optional", since the tests can still +run without it installed. If it's unavailable, it will show an informational +message, if on Linux and a ``DISPLAY`` is available. When using +``--xvfb-backend xvfb``, this message will turn into a hard error instead. + +If you're currently using ``xvfb-run`` in something like a GitHub Actions YAML +file simply remove the wrapper and install this plugin instead - then you'll +also have the benefits of Xvfb locally. + +Features +-------- + +You can pass ``--no-xvfb`` to explicitly turn off Xvfb (e.g. to visually +inspect a failure). + +With ``--xvfb-backend xephyr`` or ``--xvfb-backend xvnc``, you can use Xephyr +or Xvnc in place of Xvfb, e.g. to visually inspect failures. + +**NOTE:** Support for ``xvnc`` is currently experimental and not tested on CI, +due to incompatibilities with PyVirtualDisplay and Ubuntu 22.04's tightvncserver. + +You can mark tests with ``@pytest.mark.no_xvfb`` to skip them when they're +running with Xvfb. + +A ``xvfb`` fixture is available with the following attributes: + +- ``width``: The configured width of the screen. +- ``height``: The configured height of the screen. +- ``colordepth``: The configured colordepth of the screen. +- ``args``: The arguments to be passed to Xvfb. +- ``display``: The display number (as int) which is used. +- ``backend``: Either ``None`` (Xvfb), ``"xvfb"``, ``"xephyr"``, or ``"xvnc"``. + +In a pytest.ini, ``xvfb_width``, ``xvfb_height``, ``xvfb_colordepth`` and +``xvfb_args`` can be used to configure the respective values. In addition, +``xvfb_xauth`` can be set to ``true`` to generate an ``Xauthority`` token. + +Contributing +------------ + +Contributions are very welcome. Tests can be run with `tox`_, please ensure +the coverage at least stays the same before you submit a pull request. + +License +------- + +Distributed under the terms of the `MIT`_ license, "pytest-xvfb" is free and open source software + +Thanks +------ + +This `pytest`_ plugin was generated with `Cookiecutter`_ along with +`@hackebrot`_'s `Cookiecutter-pytest-plugin`_ template. + +Thanks to `@cgoldberg`_ for `xvfbwrapper`_ which was the inspiration for this +project. + +Issues +------ + +If you encounter any problems, please `file an issue`_ along with a detailed description. + +.. _`pytest-xvfb`: https://pypi.python.org/pypi/pytest-xvfb/ +.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter +.. _`@hackebrot`: https://github.com/hackebrot +.. _`@cgoldberg`: https://github.com/cgoldberg +.. _`xvfbwrapper`: https://github.com/cgoldberg/xvfbwrapper +.. _`MIT`: http://opensource.org/licenses/MIT +.. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin +.. _`file an issue`: https://github.com/The-Compiler/pytest-xvfb/issues +.. _`pytest`: https://github.com/pytest-dev/pytest +.. _`tox`: https://tox.readthedocs.org/en/latest/ +.. _`pip`: https://pypi.python.org/pypi/pip/ +.. _`PyPI`: https://pypi.python.org/pypi +.. _`Xvfb`: https://en.wikipedia.org/wiki/Xvfb +.. _`Xephyr`: https://www.freedesktop.org/wiki/Software/Xephyr/ +.. _`Xvnc`: https://tigervnc.org/doc/Xvnc.html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/README.rst new/pytest-xvfb-3.0.0/README.rst --- old/pytest-xvfb-2.0.0/README.rst 2020-06-09 19:16:09.000000000 +0200 +++ new/pytest-xvfb-3.0.0/README.rst 2023-05-29 13:54:19.000000000 +0200 @@ -1,15 +1,7 @@ pytest-xvfb =================================== -.. image:: https://travis-ci.org/The-Compiler/pytest-xvfb.svg?branch=master - :target: https://travis-ci.org/The-Compiler/pytest-xvfb - :alt: See Build Status on Travis CI - -.. image:: https://ci.appveyor.com/api/projects/status/github/The-Compiler/pytest-xvfb?... - :target: https://ci.appveyor.com/project/The-Compiler/pytest-xvfb/branch/master - :alt: See Build Status on AppVeyor - -A pytest plugin to run Xvfb for tests. +A pytest plugin to run `Xvfb`_ (or `Xephyr`_/`Xvnc`_) for tests. ---- @@ -26,12 +18,14 @@ With Xvfb and the plugin installed, your testsuite automatically runs with `Xvfb`_. This allows tests to be run without windows popping up during GUI tests or on systems without a display (like a CI). -If Xvfb is not installed, the plugin does not run and your tests will still work as normal. However, -a warning message will print to standard output letting you know that Xvfb is not installed. - -If you're currently using ``xvfb-run`` in something like ``.travis.yml``, -simply remove it and install this plugin instead - then you'll also have the -benefits of Xvfb locally. +The plugin sees Xvfb being installed as "optional", since the tests can still +run without it installed. If it's unavailable, it will show an informational +message, if on Linux and a ``DISPLAY`` is available. When using +``--xvfb-backend xvfb``, this message will turn into a hard error instead. + +If you're currently using ``xvfb-run`` in something like a GitHub Actions YAML +file simply remove the wrapper and install this plugin instead - then you'll +also have the benefits of Xvfb locally. Features -------- @@ -39,6 +33,12 @@ You can pass ``--no-xvfb`` to explicitly turn off Xvfb (e.g. to visually inspect a failure). +With ``--xvfb-backend xephyr`` or ``--xvfb-backend xvnc``, you can use Xephyr +or Xvnc in place of Xvfb, e.g. to visually inspect failures. + +**NOTE:** Support for ``xvnc`` is currently experimental and not tested on CI, +due to incompatibilities with PyVirtualDisplay and Ubuntu 22.04's tightvncserver. + You can mark tests with ``@pytest.mark.no_xvfb`` to skip them when they're running with Xvfb. @@ -49,6 +49,11 @@ - ``colordepth``: The configured colordepth of the screen. - ``args``: The arguments to be passed to Xvfb. - ``display``: The display number (as int) which is used. +- ``backend``: Either ``None`` (Xvfb), ``"xvfb"``, ``"xephyr"``, or ``"xvnc"``. + +In a pytest.ini, ``xvfb_width``, ``xvfb_height``, ``xvfb_colordepth`` and +``xvfb_args`` can be used to configure the respective values. In addition, +``xvfb_xauth`` can be set to ``true`` to generate an ``Xauthority`` token. Contributing ------------ @@ -76,18 +81,17 @@ If you encounter any problems, please `file an issue`_ along with a detailed description. .. _`pytest-xvfb`: https://pypi.python.org/pypi/pytest-xvfb/ -.. _`Xvfb`: http://www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml .. _`Cookiecutter`: https://github.com/audreyr/cookiecutter .. _`@hackebrot`: https://github.com/hackebrot .. _`@cgoldberg`: https://github.com/cgoldberg .. _`xvfbwrapper`: https://github.com/cgoldberg/xvfbwrapper .. _`MIT`: http://opensource.org/licenses/MIT -.. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause -.. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt -.. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0 .. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin .. _`file an issue`: https://github.com/The-Compiler/pytest-xvfb/issues .. _`pytest`: https://github.com/pytest-dev/pytest .. _`tox`: https://tox.readthedocs.org/en/latest/ .. _`pip`: https://pypi.python.org/pypi/pip/ .. _`PyPI`: https://pypi.python.org/pypi +.. _`Xvfb`: https://en.wikipedia.org/wiki/Xvfb +.. _`Xephyr`: https://www.freedesktop.org/wiki/Software/Xephyr/ +.. _`Xvnc`: https://tigervnc.org/doc/Xvnc.html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/pyproject.toml new/pytest-xvfb-3.0.0/pyproject.toml --- old/pytest-xvfb-2.0.0/pyproject.toml 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-xvfb-3.0.0/pyproject.toml 2023-05-29 13:54:19.000000000 +0200 @@ -0,0 +1,41 @@ +[build-system] +requires = ["setuptools>=61.2"] +build-backend = "setuptools.build_meta" + +[project] +name = "pytest-xvfb" +version = "3.0.0" +authors = [{name = "Florian Bruhin", email = "me@the-compiler.org"}] +maintainers = [{name = "Florian Bruhin", email = "me@the-compiler.org"}] +license = {text = "MIT"} +description = "A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests." +readme = "README.rst" +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Topic :: Software Development :: Testing", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Operating System :: OS Independent", + "License :: OSI Approved :: MIT License", +] +requires-python = ">=3.7" +dependencies = ["pytest>=2.8.1", "pyvirtualdisplay>=1.3"] + +[project.urls] +Homepage = "https://github.com/The-Compiler/pytest-xvfb" + +[project.entry-points] +pytest11 = {xvfb = "pytest_xvfb"} + +[tool.setuptools] +py-modules = ["pytest_xvfb"] +include-package-data = false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/pytest_xvfb.egg-info/PKG-INFO new/pytest-xvfb-3.0.0/pytest_xvfb.egg-info/PKG-INFO --- old/pytest-xvfb-2.0.0/pytest_xvfb.egg-info/PKG-INFO 2020-06-09 19:16:19.000000000 +0200 +++ new/pytest-xvfb-3.0.0/pytest_xvfb.egg-info/PKG-INFO 2023-05-29 13:54:26.000000000 +0200 @@ -1,120 +1,124 @@ -Metadata-Version: 1.2 +Metadata-Version: 2.1 Name: pytest-xvfb -Version: 2.0.0 -Summary: A pytest plugin to run Xvfb for tests. -Home-page: https://github.com/The-Compiler/pytest-xvfb -Author: Florian Bruhin -Author-email: me@the-compiler.org -Maintainer: Florian Bruhin -Maintainer-email: me@the-compiler.org +Version: 3.0.0 +Summary: A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. +Author-email: Florian Bruhin <me@the-compiler.org> +Maintainer-email: Florian Bruhin <me@the-compiler.org> License: MIT -Description: pytest-xvfb - =================================== - - .. image:: https://travis-ci.org/The-Compiler/pytest-xvfb.svg?branch=master - :target: https://travis-ci.org/The-Compiler/pytest-xvfb - :alt: See Build Status on Travis CI - - .. image:: https://ci.appveyor.com/api/projects/status/github/The-Compiler/pytest-xvfb?... - :target: https://ci.appveyor.com/project/The-Compiler/pytest-xvfb/branch/master - :alt: See Build Status on AppVeyor - - A pytest plugin to run Xvfb for tests. - - ---- - - Installation - ------------ - - You can install "`pytest-xvfb`_" via `pip`_ from `PyPI`_:: - - $ pip install pytest-xvfb - - - Usage - ----- - - With Xvfb and the plugin installed, your testsuite automatically runs with `Xvfb`_. This allows tests to be run without windows popping up during GUI tests or on systems without a display (like a CI). - - If Xvfb is not installed, the plugin does not run and your tests will still work as normal. However, - a warning message will print to standard output letting you know that Xvfb is not installed. - - If you're currently using ``xvfb-run`` in something like ``.travis.yml``, - simply remove it and install this plugin instead - then you'll also have the - benefits of Xvfb locally. - - Features - -------- - - You can pass ``--no-xvfb`` to explicitly turn off Xvfb (e.g. to visually - inspect a failure). - - You can mark tests with ``@pytest.mark.no_xvfb`` to skip them when they're - running with Xvfb. - - A ``xvfb`` fixture is available with the following attributes: - - - ``width``: The configured width of the screen. - - ``height``: The configured height of the screen. - - ``colordepth``: The configured colordepth of the screen. - - ``args``: The arguments to be passed to Xvfb. - - ``display``: The display number (as int) which is used. - - Contributing - ------------ - - Contributions are very welcome. Tests can be run with `tox`_, please ensure - the coverage at least stays the same before you submit a pull request. - - License - ------- - - Distributed under the terms of the `MIT`_ license, "pytest-xvfb" is free and open source software - - Thanks - ------ - - This `pytest`_ plugin was generated with `Cookiecutter`_ along with - `@hackebrot`_'s `Cookiecutter-pytest-plugin`_ template. - - Thanks to `@cgoldberg`_ for `xvfbwrapper`_ which was the inspiration for this - project. - - Issues - ------ - - If you encounter any problems, please `file an issue`_ along with a detailed description. - - .. _`pytest-xvfb`: https://pypi.python.org/pypi/pytest-xvfb/ - .. _`Xvfb`: http://www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml - .. _`Cookiecutter`: https://github.com/audreyr/cookiecutter - .. _`@hackebrot`: https://github.com/hackebrot - .. _`@cgoldberg`: https://github.com/cgoldberg - .. _`xvfbwrapper`: https://github.com/cgoldberg/xvfbwrapper - .. _`MIT`: http://opensource.org/licenses/MIT - .. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause - .. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt - .. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0 - .. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin - .. _`file an issue`: https://github.com/The-Compiler/pytest-xvfb/issues - .. _`pytest`: https://github.com/pytest-dev/pytest - .. _`tox`: https://tox.readthedocs.org/en/latest/ - .. _`pip`: https://pypi.python.org/pypi/pip/ - .. _`PyPI`: https://pypi.python.org/pypi - -Platform: UNKNOWN +Project-URL: Homepage, https://github.com/The-Compiler/pytest-xvfb Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Topic :: Software Development :: Testing Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.5 -Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: MIT License -Requires-Python: >=3.5 +Requires-Python: >=3.7 +Description-Content-Type: text/x-rst +License-File: LICENSE + +pytest-xvfb +=================================== + +A pytest plugin to run `Xvfb`_ (or `Xephyr`_/`Xvnc`_) for tests. + +---- + +Installation +------------ + +You can install "`pytest-xvfb`_" via `pip`_ from `PyPI`_:: + + $ pip install pytest-xvfb + + +Usage +----- + +With Xvfb and the plugin installed, your testsuite automatically runs with `Xvfb`_. This allows tests to be run without windows popping up during GUI tests or on systems without a display (like a CI). + +The plugin sees Xvfb being installed as "optional", since the tests can still +run without it installed. If it's unavailable, it will show an informational +message, if on Linux and a ``DISPLAY`` is available. When using +``--xvfb-backend xvfb``, this message will turn into a hard error instead. + +If you're currently using ``xvfb-run`` in something like a GitHub Actions YAML +file simply remove the wrapper and install this plugin instead - then you'll +also have the benefits of Xvfb locally. + +Features +-------- + +You can pass ``--no-xvfb`` to explicitly turn off Xvfb (e.g. to visually +inspect a failure). + +With ``--xvfb-backend xephyr`` or ``--xvfb-backend xvnc``, you can use Xephyr +or Xvnc in place of Xvfb, e.g. to visually inspect failures. + +**NOTE:** Support for ``xvnc`` is currently experimental and not tested on CI, +due to incompatibilities with PyVirtualDisplay and Ubuntu 22.04's tightvncserver. + +You can mark tests with ``@pytest.mark.no_xvfb`` to skip them when they're +running with Xvfb. + +A ``xvfb`` fixture is available with the following attributes: + +- ``width``: The configured width of the screen. +- ``height``: The configured height of the screen. +- ``colordepth``: The configured colordepth of the screen. +- ``args``: The arguments to be passed to Xvfb. +- ``display``: The display number (as int) which is used. +- ``backend``: Either ``None`` (Xvfb), ``"xvfb"``, ``"xephyr"``, or ``"xvnc"``. + +In a pytest.ini, ``xvfb_width``, ``xvfb_height``, ``xvfb_colordepth`` and +``xvfb_args`` can be used to configure the respective values. In addition, +``xvfb_xauth`` can be set to ``true`` to generate an ``Xauthority`` token. + +Contributing +------------ + +Contributions are very welcome. Tests can be run with `tox`_, please ensure +the coverage at least stays the same before you submit a pull request. + +License +------- + +Distributed under the terms of the `MIT`_ license, "pytest-xvfb" is free and open source software + +Thanks +------ + +This `pytest`_ plugin was generated with `Cookiecutter`_ along with +`@hackebrot`_'s `Cookiecutter-pytest-plugin`_ template. + +Thanks to `@cgoldberg`_ for `xvfbwrapper`_ which was the inspiration for this +project. + +Issues +------ + +If you encounter any problems, please `file an issue`_ along with a detailed description. + +.. _`pytest-xvfb`: https://pypi.python.org/pypi/pytest-xvfb/ +.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter +.. _`@hackebrot`: https://github.com/hackebrot +.. _`@cgoldberg`: https://github.com/cgoldberg +.. _`xvfbwrapper`: https://github.com/cgoldberg/xvfbwrapper +.. _`MIT`: http://opensource.org/licenses/MIT +.. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin +.. _`file an issue`: https://github.com/The-Compiler/pytest-xvfb/issues +.. _`pytest`: https://github.com/pytest-dev/pytest +.. _`tox`: https://tox.readthedocs.org/en/latest/ +.. _`pip`: https://pypi.python.org/pypi/pip/ +.. _`PyPI`: https://pypi.python.org/pypi +.. _`Xvfb`: https://en.wikipedia.org/wiki/Xvfb +.. _`Xephyr`: https://www.freedesktop.org/wiki/Software/Xephyr/ +.. _`Xvnc`: https://tigervnc.org/doc/Xvnc.html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/pytest_xvfb.egg-info/SOURCES.txt new/pytest-xvfb-3.0.0/pytest_xvfb.egg-info/SOURCES.txt --- old/pytest-xvfb-2.0.0/pytest_xvfb.egg-info/SOURCES.txt 2020-06-09 19:16:19.000000000 +0200 +++ new/pytest-xvfb-3.0.0/pytest_xvfb.egg-info/SOURCES.txt 2023-05-29 13:54:26.000000000 +0200 @@ -1,6 +1,8 @@ CHANGELOG.rst +LICENSE MANIFEST.in README.rst +pyproject.toml pytest_xvfb.py setup.py pytest_xvfb.egg-info/PKG-INFO @@ -10,5 +12,6 @@ pytest_xvfb.egg-info/requires.txt pytest_xvfb.egg-info/top_level.txt tests/conftest.py +tests/test_qtwe_xio_error.py tests/test_xvfb.py tests/test_xvfb_windows.py \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/pytest_xvfb.egg-info/entry_points.txt new/pytest-xvfb-3.0.0/pytest_xvfb.egg-info/entry_points.txt --- old/pytest-xvfb-2.0.0/pytest_xvfb.egg-info/entry_points.txt 2020-06-09 19:16:19.000000000 +0200 +++ new/pytest-xvfb-3.0.0/pytest_xvfb.egg-info/entry_points.txt 2023-05-29 13:54:26.000000000 +0200 @@ -1,3 +1,2 @@ [pytest11] xvfb = pytest_xvfb - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/pytest_xvfb.py new/pytest-xvfb-3.0.0/pytest_xvfb.py --- old/pytest-xvfb-2.0.0/pytest_xvfb.py 2020-06-09 19:16:09.000000000 +0200 +++ new/pytest-xvfb-3.0.0/pytest_xvfb.py 2023-05-29 13:54:19.000000000 +0200 @@ -1,112 +1,133 @@ -# -*- coding: utf-8 -*- +from __future__ import annotations +import atexit import os -import re -import time import os.path -import fnmatch -import hashlib -import tempfile -import subprocess import sys +import pytest import pyvirtualdisplay -import pytest +xvfb_instance = None + + +def shutdown_xvfb() -> None: + if xvfb_instance is not None: + xvfb_instance.stop() -def is_xdist_master(config): - return ( - config.getoption("dist", "no") != "no" and - not os.environ.get("PYTEST_XDIST_WORKER") +# This needs to be done as early as possible (before importing QtWebEngine for +# example), so that Xvfb gets shut down as late as possible. +atexit.register(shutdown_xvfb) + + +def is_xdist_master(config: pytest.Config) -> bool: + return config.getoption("dist", "no") != "no" and not os.environ.get( + "PYTEST_XDIST_WORKER" ) -def xvfb_available(): +def has_executable(name: str) -> bool: # http://stackoverflow.com/a/28909933/2085149 return any( - os.access(os.path.join(path, 'Xvfb'), os.X_OK) + os.access(os.path.join(path, name), os.X_OK) for path in os.environ["PATH"].split(os.pathsep) ) class XvfbExitedError(Exception): - pass -class Xvfb(object): - - def __init__(self, config): - self.width = int(config.getini('xvfb_width')) - self.height = int(config.getini('xvfb_height')) - self.colordepth = int(config.getini('xvfb_colordepth')) - self.args = config.getini('xvfb_args') or [] - self.xauth = config.getini('xvfb_xauth') +class Xvfb: + def __init__(self, config: pytest.Config) -> None: + self.width = int(config.getini("xvfb_width")) + self.height = int(config.getini("xvfb_height")) + self.colordepth = int(config.getini("xvfb_colordepth")) + self.args = config.getini("xvfb_args") or [] + self.xauth = config.getini("xvfb_xauth") + self.backend = config.getoption("--xvfb-backend") self.display = None self._virtual_display = None - def start(self): - self._virtual_display = pyvirtualdisplay.Display( - backend='xvfb', size=(self.width, self.height), - color_depth=self.colordepth, use_xauth=self.xauth, - extra_args=self.args) + def start(self) -> None: + self._virtual_display = pyvirtualdisplay.Display( # type: ignore[attr-defined] + backend=self.backend, + size=(self.width, self.height), + color_depth=self.colordepth, + use_xauth=self.xauth, + extra_args=self.args, + ) + assert self._virtual_display is not None # mypy self._virtual_display.start() self.display = self._virtual_display.display assert self._virtual_display.is_alive() - def stop(self): + def stop(self) -> None: if self.display is not None: # starting worked self._virtual_display.stop() -def pytest_addoption(parser): - group = parser.getgroup('xvfb') +def pytest_addoption(parser: pytest.Parser) -> None: + group = parser.getgroup("xvfb") + group.addoption("--no-xvfb", action="store_true", help="Disable Xvfb for tests.") group.addoption( - '--no-xvfb', - action='store_true', - help='Disable Xvfb for tests.' + "--xvfb-backend", + action="store", + choices=["xvfb", "xvnc", "xephyr"], + help="Use Xephyr or Xvnc instead of Xvfb for tests. Will be ignored if --no-xvfb is given.", + ) + + parser.addini("xvfb_width", "Width of the Xvfb display", default="800") + parser.addini("xvfb_height", "Height of the Xvfb display", default="600") + parser.addini("xvfb_colordepth", "Color depth of the Xvfb display", default="16") + parser.addini("xvfb_args", "Additional arguments for Xvfb", type="args") + parser.addini( + "xvfb_xauth", + "Generate an Xauthority token for Xvfb. Needs xauth.", + default=False, + type="bool", ) - parser.addini('xvfb_width', 'Width of the Xvfb display', default='800') - parser.addini('xvfb_height', 'Height of the Xvfb display', default='600') - parser.addini('xvfb_colordepth', 'Color depth of the Xvfb display', - default='16') - parser.addini('xvfb_args', 'Additional arguments for Xvfb', - type='args') - parser.addini('xvfb_xauth', - 'Generate an Xauthority token for Xvfb. Needs xauth.', - default=False, type='bool') - - -def pytest_configure(config): - no_xvfb = config.getoption('--no-xvfb') or is_xdist_master(config) - if no_xvfb or not xvfb_available(): - config.xvfb = None - if (sys.platform.startswith('linux') - and 'DISPLAY' in os.environ - and not no_xvfb): - print('pytest-xvfb could not find Xvfb. ' - 'You can install it to prevent windows from being shown.') - else: - config.xvfb = Xvfb(config) - config.xvfb.start() - config.addinivalue_line("markers", "no_xvfb: Skip test when using Xvfb") +def pytest_configure(config: pytest.Config) -> None: + global xvfb_instance -def pytest_unconfigure(config): - if getattr(config, 'xvfb', None) is not None: - config.xvfb.stop() + no_xvfb = config.getoption("--no-xvfb") or is_xdist_master(config) + backend = config.getoption("--xvfb-backend") + + if no_xvfb: + pass + elif backend is None and not has_executable("Xvfb"): + # soft fail + if sys.platform.startswith("linux") and "DISPLAY" in os.environ: + print( + "pytest-xvfb could not find Xvfb. " + "You can install it to prevent windows from being shown." + ) + elif ( + backend == "xvfb" + and not has_executable("Xvfb") + or backend == "xvnc" + and not has_executable("Xvnc") + or backend == "xephyr" + and not has_executable("Xephyr") + ): + raise pytest.UsageError(f"xvfb backend {backend} requested but not installed.") + else: + xvfb_instance = Xvfb(config) + xvfb_instance.start() + + config.addinivalue_line("markers", "no_xvfb: Skip test when using Xvfb") -def pytest_collection_modifyitems(items): +def pytest_collection_modifyitems(items: list[pytest.Item]) -> None: for item in items: - if item.get_closest_marker('no_xvfb') and item.config.xvfb is not None: - skipif_marker = pytest.mark.skipif( - True, reason="Skipped with Xvfb") + if item.get_closest_marker("no_xvfb") and xvfb_instance is not None: + skipif_marker = pytest.mark.skipif(True, reason="Skipped with Xvfb") item.add_marker(skipif_marker) -@pytest.fixture(scope='session') -def xvfb(pytestconfig): - return pytestconfig.xvfb +@pytest.fixture(scope="session") +def xvfb() -> Xvfb | None: + return xvfb_instance diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/setup.py new/pytest-xvfb-3.0.0/setup.py --- old/pytest-xvfb-2.0.0/setup.py 2020-06-09 19:16:09.000000000 +0200 +++ new/pytest-xvfb-3.0.0/setup.py 2023-05-29 13:54:19.000000000 +0200 @@ -1,49 +1,3 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import codecs from setuptools import setup - -def read(fname): - file_path = os.path.join(os.path.dirname(__file__), fname) - return codecs.open(file_path, encoding='utf-8').read() - - -setup( - name='pytest-xvfb', - version='2.0.0', - author='Florian Bruhin', - author_email='me@the-compiler.org', - maintainer='Florian Bruhin', - maintainer_email='me@the-compiler.org', - license='MIT', - url='https://github.com/The-Compiler/pytest-xvfb', - description='A pytest plugin to run Xvfb for tests.', - long_description=read('README.rst'), - py_modules=['pytest_xvfb'], - install_requires=['pytest>=2.8.1', 'pyvirtualdisplay>=1.3'], - python_requires='>=3.5', - classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Topic :: Software Development :: Testing', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Operating System :: OS Independent', - 'License :: OSI Approved :: MIT License', - ], - entry_points={ - 'pytest11': [ - 'xvfb = pytest_xvfb', - ], - }, -) +setup() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/tests/conftest.py new/pytest-xvfb-3.0.0/tests/conftest.py --- old/pytest-xvfb-2.0.0/tests/conftest.py 2020-06-09 19:16:09.000000000 +0200 +++ new/pytest-xvfb-3.0.0/tests/conftest.py 2023-05-29 13:54:19.000000000 +0200 @@ -1 +1 @@ -pytest_plugins = 'pytester' +pytest_plugins = "pytester" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/tests/test_qtwe_xio_error.py new/pytest-xvfb-3.0.0/tests/test_qtwe_xio_error.py --- old/pytest-xvfb-2.0.0/tests/test_qtwe_xio_error.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-xvfb-3.0.0/tests/test_qtwe_xio_error.py 2023-05-29 13:54:19.000000000 +0200 @@ -0,0 +1,32 @@ +from __future__ import annotations + +import os +import sys + +import pytest + +if sys.version_info == (3, 12, 0, "beta", 1) and "CI" in os.environ: + pytest.skip( + reason="Segfaults on GHA for unknown reasons", + allow_module_level=True, + ) + +pytest.importorskip("PyQt5.QtWebEngineWidgets") + + +def test_qt_output(pytester: pytest.Pytester) -> None: + pytester.makepyfile( + """ + import sys + import PyQt5.QtWebEngineWidgets + from PyQt5.QtWidgets import QWidget, QApplication + + app = QApplication(sys.argv) + + def test_widget(): + widget = QWidget() + widget.show() + """ + ) + res = pytester.runpytest() + assert res.ret == 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/tests/test_xvfb.py new/pytest-xvfb-3.0.0/tests/test_xvfb.py --- old/pytest-xvfb-2.0.0/tests/test_xvfb.py 2020-06-09 19:16:09.000000000 +0200 +++ new/pytest-xvfb-3.0.0/tests/test_xvfb.py 2023-05-29 13:54:19.000000000 +0200 @@ -1,91 +1,170 @@ -# -*- coding: utf-8 -*- +from __future__ import annotations import os +from typing import Iterator import pytest +import pyvirtualdisplay import pytest_xvfb - xauth_available = any( - os.access(os.path.join(path, 'xauth'), os.X_OK) - for path in os.environ.get('PATH', '').split(os.pathsep) + os.access(os.path.join(path, "xauth"), os.X_OK) + for path in os.environ.get("PATH", "").split(os.pathsep) ) -@pytest.fixture(autouse=True, scope='session') -def ensure_xvfb(): - if not pytest_xvfb.xvfb_available(): +@pytest.fixture(autouse=True, scope="session") +def ensure_xvfb() -> None: + if not pytest_xvfb.has_executable("Xvfb"): raise Exception("Tests need Xvfb to run.") -def test_xvfb_available(testdir, monkeypatch): - monkeypatch.delenv('DISPLAY') - testdir.makepyfile(""" +needs_xephyr = pytest.mark.skipif( + not pytest_xvfb.has_executable("Xephyr"), reason="Needs Xephyr" +) +needs_xvnc = pytest.mark.skipif( + not pytest_xvfb.has_executable("Xvnc"), reason="Needs Xvnc" +) + + +@pytest.fixture( + params=[ + None, + "xvfb", + pytest.param("xephyr", marks=needs_xephyr), + pytest.param("xvnc", marks=needs_xvnc), + ] +) +def backend_args( + request: pytest.FixtureRequest, monkeypatch: pytest.MonkeyPatch +) -> Iterator[list[str]]: + monkeypatch.delenv("DISPLAY") + args = [] if request.param is None else ["--xvfb-backend", request.param] + if request.param == "xephyr": + # we need a host display for it... PyVirtualDisplay and Xvfb to the + # rescue! + display = pyvirtualdisplay.Display() # type: ignore[attr-defined] + display.start() + yield args + display.stop() + else: + yield args + + +def test_xvfb_available(pytester: pytest.Pytester, backend_args: list[str]) -> None: + pytester.makepyfile( + """ import os def test_display(): assert 'DISPLAY' in os.environ - """) - result = testdir.runpytest() + """ + ) + result = pytester.runpytest(*backend_args) assert result.ret == 0 -def test_empty_display(testdir, monkeypatch): - monkeypatch.setenv('DISPLAY', '') - testdir.makepyfile(""" +def test_empty_display( + pytester: pytest.Pytester, monkeypatch: pytest.MonkeyPatch, backend_args: list[str] +) -> None: + if backend_args == ["--xvfb-backend", "xephyr"]: + pytest.skip("Xephyr needs a host display") + + monkeypatch.setenv("DISPLAY", "") + pytester.makepyfile( + """ import os def test_display(): assert 'DISPLAY' in os.environ - """) - result = testdir.runpytest() - assert os.environ['DISPLAY'] == '' + """ + ) + result = pytester.runpytest(*backend_args) + assert os.environ["DISPLAY"] == "" assert result.ret == 0 -def test_xvfb_unavailable(testdir, monkeypatch): - monkeypatch.setenv('PATH', '') - monkeypatch.setenv('DISPLAY', ':42') - testdir.makepyfile(""" +def test_xvfb_unavailable( + pytester: pytest.Pytester, monkeypatch: pytest.MonkeyPatch +) -> None: + monkeypatch.setenv("PATH", "") + monkeypatch.setenv("DISPLAY", ":42") + pytester.makepyfile( + """ import os def test_display(): assert os.environ['DISPLAY'] == ':42' - """) - assert os.environ['DISPLAY'] == ':42' - result = testdir.runpytest() - result.stdout.fnmatch_lines('* could not find Xvfb.*') + """ + ) + assert os.environ["DISPLAY"] == ":42" + result = pytester.runpytest() + result.stdout.fnmatch_lines("* could not find Xvfb.*") assert result.ret == 0 -def test_no_xvfb_arg(testdir, monkeypatch): - monkeypatch.setenv('DISPLAY', ':42') - testdir.makepyfile(""" +def test_xvfb_unavailable_explicit( + pytester: pytest.Pytester, monkeypatch: pytest.MonkeyPatch, backend_args: list[str] +) -> None: + """If an explicitly chosen backend is unavailable: Hard error.""" + if not backend_args: + pytest.skip("Already tested above") + + monkeypatch.setenv("PATH", "") + monkeypatch.setenv("DISPLAY", ":42") + pytester.makepyfile( + """ + import os + + def test_display(): + assert False # never run + """ + ) + assert os.environ["DISPLAY"] == ":42" + result = pytester.runpytest(*backend_args) + result.stderr.fnmatch_lines("*xvfb backend * requested but not installed.") + assert result.ret == pytest.ExitCode.USAGE_ERROR + + +def test_no_xvfb_arg( + pytester: pytest.Pytester, monkeypatch: pytest.MonkeyPatch, backend_args: list[str] +) -> None: + monkeypatch.setenv("DISPLAY", ":42") + pytester.makepyfile( + """ import os def test_display(): assert os.environ['DISPLAY'] == ':42' - """) - assert os.environ['DISPLAY'] == ':42' - result = testdir.runpytest('--no-xvfb') + """ + ) + assert os.environ["DISPLAY"] == ":42" + result = pytester.runpytest("--no-xvfb", *backend_args) assert result.ret == 0 -@pytest.mark.parametrize('configured', [True, False]) -def test_screen_size(testdir, configured): +@pytest.mark.parametrize("configured", [True, False]) +def test_screen_size( + pytester: pytest.Pytester, configured: bool, backend_args: list[str] +) -> None: + if backend_args == ["--xvfb-backend", "xvnc"]: + pytest.skip("Seems to be unsupported with Xvnc") + try: - import tkinter + import tkinter # noqa except ImportError: - pytest.importorskip('Tkinter') + pytest.importorskip("Tkinter") if configured: - testdir.makeini(""" + pytester.makeini( + """ [pytest] xvfb_width = 1024 xvfb_height = 768 xvfb_colordepth = 8 - """) + """ + ) expected_width = 1024 expected_height = 768 expected_depth = 8 @@ -94,7 +173,8 @@ expected_height = 600 expected_depth = 16 - testdir.makepyfile(""" + pytester.makepyfile( + """ try: import tkinter as tk except ImportError: @@ -105,34 +185,50 @@ assert root.winfo_screenwidth() == {width} assert root.winfo_screenheight() == {height} assert root.winfo_screendepth() == {depth} - """.format(width=expected_width, height=expected_height, - depth=expected_depth)) - result = testdir.runpytest() + """.format( + width=expected_width, height=expected_height, depth=expected_depth + ) + ) + result = pytester.runpytest(*backend_args) assert result.ret == 0 -def test_failing_start(testdir, monkeypatch): - testdir.makeini(""" +def test_failing_start( + pytester: pytest.Pytester, monkeypatch: pytest.MonkeyPatch, backend_args: list[str] +) -> None: + pytester.makeini( + """ [pytest] xvfb_args = -foo - """) - testdir.makepyfile(""" + """ + ) + pytester.makepyfile( + """ def test_none(): pass - """) - result = testdir.runpytest() - result.stderr.fnmatch_lines([ - "INTERNALERROR> *.XStartError: Xvfb program closed. *", - ]) - assert 'OSError' not in str(result.stderr) - - -@pytest.mark.parametrize('args, outcome', [ - ([], '1 passed, 1 skipped'), - (['--no-xvfb'], '2 passed'), -]) -def test_no_xvfb_marker(testdir, args, outcome): - testdir.makepyfile(""" + """ + ) + result = pytester.runpytest(*backend_args) + result.stderr.fnmatch_lines( + [ + "INTERNALERROR> *.XStartError: X* program closed. *", + ] + ) + assert "OSError" not in str(result.stderr) + + +@pytest.mark.parametrize( + "args, outcome", + [ + ([], "1 passed, 1 skipped"), + (["--no-xvfb"], "2 passed"), + ], +) +def test_no_xvfb_marker( + pytester: pytest.Pytester, args: list[str], outcome: str, backend_args: list[str] +) -> None: + pytester.makepyfile( + """ import pytest @pytest.mark.no_xvfb @@ -141,13 +237,15 @@ def test_unmarked(): pass - """) - res = testdir.runpytest(*args) - res.stdout.fnmatch_lines('*= {0}*'.format(outcome)) + """ + ) + res = pytester.runpytest(*args, *backend_args) + res.stdout.fnmatch_lines(f"*= {outcome}*") -def test_xvfb_fixture(testdir): - testdir.makepyfile(""" +def test_xvfb_fixture(pytester: pytest.Pytester, backend_args: list[str]) -> None: + pytester.makepyfile( + """ import os def test_display(xvfb): @@ -160,15 +258,18 @@ def test_args(xvfb): assert xvfb.args == [] - """) - result = testdir.runpytest() + """ + ) + result = pytester.runpytest(*backend_args) assert result.ret == 0 -def test_early_display(monkeypatch, testdir): +def test_early_display( + monkeypatch: pytest.MonkeyPatch, pytester: pytest.Pytester, backend_args: list[str] +) -> None: """Make sure DISPLAY is set in a session-scoped fixture already.""" - monkeypatch.delenv('DISPLAY') - testdir.makepyfile(""" + pytester.makepyfile( + """ import os import pytest @@ -179,24 +280,30 @@ def test_foo(): pass - """) + """ + ) + result = pytester.runpytest(*backend_args) + assert result.ret == 0 -def test_strict_markers(testdir): - testdir.makepyfile(""" +def test_strict_markers(pytester: pytest.Pytester) -> None: + pytester.makepyfile( + """ import pytest @pytest.mark.no_xvfb def test_marked(): pass - """) - result = testdir.runpytest('--strict') + """ + ) + result = pytester.runpytest("--strict") assert result.ret == 0 -def test_xvfb_session_fixture(testdir): +def test_xvfb_session_fixture(pytester: pytest.Pytester) -> None: """Make sure the xvfb fixture can be used from a session-wide one.""" - testdir.makepyfile(""" + pytester.makepyfile( + """ import pytest @pytest.fixture(scope='session') @@ -205,32 +312,37 @@ def test_fixt(fixt): pass - """) - result = testdir.runpytest() + """ + ) + result = pytester.runpytest() assert result.ret == 0 -@pytest.mark.skipif(not xauth_available, reason='no xauth') -def test_xvfb_with_xauth(testdir): - original_auth = os.environ.get('XAUTHORITY') - testdir.makeini(""" +@pytest.mark.skipif(not xauth_available, reason="no xauth") +def test_xvfb_with_xauth(pytester: pytest.Pytester, backend_args: list[str]) -> None: + original_auth = os.environ.get("XAUTHORITY") + pytester.makeini( + """ [pytest] xvfb_xauth = True - """) - testdir.makepyfile(""" + """ + ) + pytester.makepyfile( + """ import os def test_xauth(): print('\\nXAUTHORITY: ' + os.environ['XAUTHORITY']) assert os.path.isfile(os.environ['XAUTHORITY']) assert os.access(os.environ['XAUTHORITY'], os.R_OK) - """) - result = testdir.runpytest('-s') + """ + ) + result = pytester.runpytest("-s", *backend_args) # Get and parse the XAUTHORITY: line - authline = next(l for l in result.outlines if l.startswith('XAUTHORITY:')) - authfile = authline.split(' ', 1)[1] + authline = next(l for l in result.outlines if l.startswith("XAUTHORITY:")) + authfile = authline.split(" ", 1)[1] assert result.ret == 0 # Make sure the authfile is deleted assert not os.path.exists(authfile) - assert os.environ.get('XAUTHORITY') == original_auth + assert os.environ.get("XAUTHORITY") == original_auth diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xvfb-2.0.0/tests/test_xvfb_windows.py new/pytest-xvfb-3.0.0/tests/test_xvfb_windows.py --- old/pytest-xvfb-2.0.0/tests/test_xvfb_windows.py 2020-06-09 19:16:09.000000000 +0200 +++ new/pytest-xvfb-3.0.0/tests/test_xvfb_windows.py 2023-05-29 13:54:19.000000000 +0200 @@ -1,12 +1,15 @@ -# -*- coding: utf-8 -*- +from __future__ import annotations -"""Make sure things don't break on Windows with no Xvfb available.""" +import pytest -def test_xvfb_windows(testdir): - testdir.makepyfile(""" +def test_xvfb_windows(pytester: pytest.Pytester) -> None: + """Make sure things don't break on Windows with no Xvfb available.""" + pytester.makepyfile( + """ def test_nothing(): pass - """) - result = testdir.runpytest() + """ + ) + result = pytester.runpytest() assert result.ret == 0