pytest-vnc


Namepytest-vnc JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://github.com/barneygale/pytest-vnc
SummaryVNC client for Pytest
upload_time2023-11-06 17:41:15
maintainer
docs_urlNone
authorBarney Gale
requires_python>=3.7
licenseGPL
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pytest-vnc: capture screen and send keyboard & mouse
====================================================

.. image:: https://img.shields.io/badge/source-github-orange
    :target: https://github.com/barneygale/pytest-vnc

.. image:: https://img.shields.io/pypi/v/pytest-vnc?style=flat-square
    :target: https://pypi.org/project/pytest-vnc


pytest-vnc implements a VNC client in pure Python. It works on Mac, Linux and Windows. Use the ``vnc`` fixture to
capture screenshots and send keyboard & mouse from your pytest tests:

.. code-block:: python

    from pytest_vnc import Rect, Point


    def test_thing(vnc):
        # Screenshot
        print(vnc.rect.width, vnc.rect.height)
        pixels = vnc.capture()  # rgba numpy array of entire screen
        pixels = vnc.capture(Rect(x=100, y=0, width=50, height=75))
        # to use PIL/pillow:
        # image = Image.fromarray(pixels)

        # Keyboard input
        vnc.write('hi there!')  # keys are queued
        vnc.press('Ctrl', 'c')  # keys are stacked
        with vnc.hold('Ctrl'):
            vnc.press('Esc')

        # Mouse input
        vnc.move(Point(100, 200))
        vnc.click()
        vnc.double_click()
        vnc.middle_click()
        vnc.right_click()
        vnc.scroll_up()
        vnc.scroll_down(repeat=10)
        with vnc.drag():
            vnc.move(Point(300, 400))
        with vnc.middle_drag():
            vnc.move(Point(500, 600))
        with vnc.right_drag():
            vnc.move(Point(700, 800))


Installation
------------

This package requires Python 3.7+.

Install pytest-vnc by running::

    pip install pytest-vnc


Configuration
-------------

The following configuration options can be set in ``pytest.ini``:

``vnc_host``
  VNC hostname (default: localhost)
``vnc_port``
  VNC port (default: 5900)
``vnc_speed``
  VNC interactions per second (default: 20)
``vnc_timeout``
  VNC connection timeout in seconds (default: 5)
``vnc_pixel_format``
  VNC colour channel order (default: rgba)
``vnc_user``
  VNC username (default: env var: ``PYTEST_VNC_USER`` or current user)
``vnc_passwd``
  VNC password (default: env var: ``PYTEST_VNC_PASSWD``)

The following attributes can be set on the ``vnc`` object:

``speed``
  Interactions per second (default: 20)
``sleep``
  Callable that accepts a duration in seconds and waits for that long (default: ``time.sleep()``)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/barneygale/pytest-vnc",
    "name": "pytest-vnc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Barney Gale",
    "author_email": "",
    "download_url": "",
    "platform": null,
    "description": "pytest-vnc: capture screen and send keyboard & mouse\n====================================================\n\n.. image:: https://img.shields.io/badge/source-github-orange\n    :target: https://github.com/barneygale/pytest-vnc\n\n.. image:: https://img.shields.io/pypi/v/pytest-vnc?style=flat-square\n    :target: https://pypi.org/project/pytest-vnc\n\n\npytest-vnc implements a VNC client in pure Python. It works on Mac, Linux and Windows. Use the ``vnc`` fixture to\ncapture screenshots and send keyboard & mouse from your pytest tests:\n\n.. code-block:: python\n\n    from pytest_vnc import Rect, Point\n\n\n    def test_thing(vnc):\n        # Screenshot\n        print(vnc.rect.width, vnc.rect.height)\n        pixels = vnc.capture()  # rgba numpy array of entire screen\n        pixels = vnc.capture(Rect(x=100, y=0, width=50, height=75))\n        # to use PIL/pillow:\n        # image = Image.fromarray(pixels)\n\n        # Keyboard input\n        vnc.write('hi there!')  # keys are queued\n        vnc.press('Ctrl', 'c')  # keys are stacked\n        with vnc.hold('Ctrl'):\n            vnc.press('Esc')\n\n        # Mouse input\n        vnc.move(Point(100, 200))\n        vnc.click()\n        vnc.double_click()\n        vnc.middle_click()\n        vnc.right_click()\n        vnc.scroll_up()\n        vnc.scroll_down(repeat=10)\n        with vnc.drag():\n            vnc.move(Point(300, 400))\n        with vnc.middle_drag():\n            vnc.move(Point(500, 600))\n        with vnc.right_drag():\n            vnc.move(Point(700, 800))\n\n\nInstallation\n------------\n\nThis package requires Python 3.7+.\n\nInstall pytest-vnc by running::\n\n    pip install pytest-vnc\n\n\nConfiguration\n-------------\n\nThe following configuration options can be set in ``pytest.ini``:\n\n``vnc_host``\n  VNC hostname (default: localhost)\n``vnc_port``\n  VNC port (default: 5900)\n``vnc_speed``\n  VNC interactions per second (default: 20)\n``vnc_timeout``\n  VNC connection timeout in seconds (default: 5)\n``vnc_pixel_format``\n  VNC colour channel order (default: rgba)\n``vnc_user``\n  VNC username (default: env var: ``PYTEST_VNC_USER`` or current user)\n``vnc_passwd``\n  VNC password (default: env var: ``PYTEST_VNC_PASSWD``)\n\nThe following attributes can be set on the ``vnc`` object:\n\n``speed``\n  Interactions per second (default: 20)\n``sleep``\n  Callable that accepts a duration in seconds and waits for that long (default: ``time.sleep()``)\n\n\n",
    "bugtrack_url": null,
    "license": "GPL",
    "summary": "VNC client for Pytest",
    "version": "2.0.0",
    "project_urls": {
        "Homepage": "https://github.com/barneygale/pytest-vnc"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2e380d6b73ab9c640f097e1dfda3003e38ce03675e0a4c19b2bfd2aa180ae6d1",
                "md5": "2ae59f46bb0155dbc5dcafe966f8faf8",
                "sha256": "22e8610244f2762fcec6b204c6a39e8b85eb1fe1e23d7f8c6c2cb5100f1c1ae8"
            },
            "downloads": -1,
            "filename": "pytest_vnc-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2ae59f46bb0155dbc5dcafe966f8faf8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 18226,
            "upload_time": "2023-11-06T17:41:15",
            "upload_time_iso_8601": "2023-11-06T17:41:15.450296Z",
            "url": "https://files.pythonhosted.org/packages/2e/38/0d6b73ab9c640f097e1dfda3003e38ce03675e0a4c19b2bfd2aa180ae6d1/pytest_vnc-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-06 17:41:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "barneygale",
    "github_project": "pytest-vnc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pytest-vnc"
}
        
Elapsed time: 0.19188s