pytest-xvfb-1.0.0/0000755000175000017500000000000013017540457015117 5ustar florianflorian00000000000000pytest-xvfb-1.0.0/README.rst0000644000175000017500000000635113017534644016614 0ustar florianflorian00000000000000pytest-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?branch=master :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 pytest-xvfb-1.0.0/setup.cfg0000644000175000017500000000007313017540457016740 0ustar florianflorian00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 pytest-xvfb-1.0.0/pytest_xvfb.egg-info/0000755000175000017500000000000013017540457021166 5ustar florianflorian00000000000000pytest-xvfb-1.0.0/pytest_xvfb.egg-info/PKG-INFO0000644000175000017500000001164313017540457022270 0ustar florianflorian00000000000000Metadata-Version: 1.1 Name: pytest-xvfb Version: 1.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 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?branch=master :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 Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Topic :: Software Development :: Testing Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: MIT License pytest-xvfb-1.0.0/pytest_xvfb.egg-info/dependency_links.txt0000644000175000017500000000000113017540457025234 0ustar florianflorian00000000000000 pytest-xvfb-1.0.0/pytest_xvfb.egg-info/entry_points.txt0000644000175000017500000000003713017540457024464 0ustar florianflorian00000000000000[pytest11] xvfb = pytest_xvfb pytest-xvfb-1.0.0/pytest_xvfb.egg-info/requires.txt0000644000175000017500000000004613017540457023566 0ustar florianflorian00000000000000pytest>=2.8.1 pyvirtualdisplay>=0.2.1 pytest-xvfb-1.0.0/pytest_xvfb.egg-info/SOURCES.txt0000644000175000017500000000036613017540457023057 0ustar florianflorian00000000000000README.rst pytest_xvfb.py setup.py pytest_xvfb.egg-info/PKG-INFO pytest_xvfb.egg-info/SOURCES.txt pytest_xvfb.egg-info/dependency_links.txt pytest_xvfb.egg-info/entry_points.txt pytest_xvfb.egg-info/requires.txt pytest_xvfb.egg-info/top_level.txtpytest-xvfb-1.0.0/pytest_xvfb.egg-info/top_level.txt0000644000175000017500000000001413017540457023713 0ustar florianflorian00000000000000pytest_xvfb pytest-xvfb-1.0.0/PKG-INFO0000644000175000017500000001164313017540457016221 0ustar florianflorian00000000000000Metadata-Version: 1.1 Name: pytest-xvfb Version: 1.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 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?branch=master :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 Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Topic :: Software Development :: Testing Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: MIT License pytest-xvfb-1.0.0/pytest_xvfb.py0000644000175000017500000000610613017534644020052 0ustar florianflorian00000000000000# -*- coding: utf-8 -*- import os import re import time import os.path import fnmatch import hashlib import tempfile import subprocess import sys import pyvirtualdisplay import pytest def xvfb_available(): # http://stackoverflow.com/a/28909933/2085149 return any( os.access(os.path.join(path, 'Xvfb'), 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') 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) self._virtual_display.cmd.extend(self.args) self._virtual_display.start() self.display = self._virtual_display.display if not self._virtual_display.is_alive(): ret = self._virtual_display.return_code raise XvfbExitedError("Xvfb exited with exit code {0}".format(ret)) def stop(self): self._virtual_display.stop() def pytest_addoption(parser): group = parser.getgroup('xvfb') group.addoption( '--no-xvfb', action='store_true', help='Disable Xvfb for tests.' ) 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='linelist') parser.addini('xvfb_xauth', 'Generate an Xauthority token for Xvfb. Needs xauth.', default=False, type='bool') def pytest_configure(config): if config.getoption('--no-xvfb') or not xvfb_available(): config.xvfb = None if (sys.platform.startswith('linux') and 'DISPLAY' in os.environ and not config.getoption('--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_unconfigure(config): if getattr(config, 'xvfb', None) is not None: config.xvfb.stop() def pytest_collection_modifyitems(items): for item in items: if item.get_marker('no_xvfb') and item.config.xvfb 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-xvfb-1.0.0/setup.py0000644000175000017500000000300113017534732016622 0ustar florianflorian00000000000000#!/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='1.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>=0.2.1'], classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'Topic :: Software Development :: Testing', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', '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', ], }, )