pytest-textual-snapshot


Namepytest-textual-snapshot JSON
Version 0.4.0 PyPI version JSON
download
home_pagehttps://github.com/darrenburns/pytest-textual-snapshot
SummarySnapshot testing for Textual apps
upload_time2023-08-23 11:13:11
maintainerDarren Burns
docs_urlNone
authorDarren Burns
requires_python>=3.6,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pytest-textual-snapshot

Snapshot testing for Textual apps.

## Installation

Install using `pip`:

```
pip install pytest-textual-snapshot
```

After installing, the `snap_compare` fixture will automatically be made available.

## About

A `pytest-textual-snapshot` test saves an SVG screenshot of a running Textual app to disk. 
The next time the test runs, it takes another screenshot and compares it to the saved one.
If the new screenshot differs from the old one, the test fails.
This is a convenient way to quickly and automatically detect visual regressions in your applications.

## Usage

### Running tests

You can run your tests using `pytest` as normal.

#### My snapshot test failed, what do I do?

If your snapshot test fails, it means that the screenshot taken during the test session
differs from the last screenshot taken.
This change is shown in the failure report, which you'll be given a linked to in the event of a failure.

If the diff shown in the failure report looks correct, you can update the snapshot on disk
by running `pytest` with the `--snapshot-update` flag.

### Writing tests

#### Basic usage

Inject the `snap_compare` fixture into your test and call
it with the path to the Textual app (the file containing the `App` subclass).

```python
def test_something(snap_compare):
    assert snap_compare("path/to/app.py")
``` 

#### Pressing keys

Key presses can be simulated before the screenshot is taken.

```python
def test_something(snap_compare):
    assert snap_compare("path/to/app.py", press=["tab", "left", "a"])
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/darrenburns/pytest-textual-snapshot",
    "name": "pytest-textual-snapshot",
    "maintainer": "Darren Burns",
    "docs_url": null,
    "requires_python": ">=3.6,<4.0",
    "maintainer_email": "darren@textualize.io",
    "keywords": "",
    "author": "Darren Burns",
    "author_email": "darren@textualize.io",
    "download_url": "https://files.pythonhosted.org/packages/f7/cf/582c7e2dcbc2947dc68252821578404a0c5ec2ff6e5aa91a3ddc0e4bfbab/pytest_textual_snapshot-0.4.0.tar.gz",
    "platform": null,
    "description": "# pytest-textual-snapshot\n\nSnapshot testing for Textual apps.\n\n## Installation\n\nInstall using `pip`:\n\n```\npip install pytest-textual-snapshot\n```\n\nAfter installing, the `snap_compare` fixture will automatically be made available.\n\n## About\n\nA `pytest-textual-snapshot` test saves an SVG screenshot of a running Textual app to disk. \nThe next time the test runs, it takes another screenshot and compares it to the saved one.\nIf the new screenshot differs from the old one, the test fails.\nThis is a convenient way to quickly and automatically detect visual regressions in your applications.\n\n## Usage\n\n### Running tests\n\nYou can run your tests using `pytest` as normal.\n\n#### My snapshot test failed, what do I do?\n\nIf your snapshot test fails, it means that the screenshot taken during the test session\ndiffers from the last screenshot taken.\nThis change is shown in the failure report, which you'll be given a linked to in the event of a failure.\n\nIf the diff shown in the failure report looks correct, you can update the snapshot on disk\nby running `pytest` with the `--snapshot-update` flag.\n\n### Writing tests\n\n#### Basic usage\n\nInject the `snap_compare` fixture into your test and call\nit with the path to the Textual app (the file containing the `App` subclass).\n\n```python\ndef test_something(snap_compare):\n    assert snap_compare(\"path/to/app.py\")\n``` \n\n#### Pressing keys\n\nKey presses can be simulated before the screenshot is taken.\n\n```python\ndef test_something(snap_compare):\n    assert snap_compare(\"path/to/app.py\", press=[\"tab\", \"left\", \"a\"])\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Snapshot testing for Textual apps",
    "version": "0.4.0",
    "project_urls": {
        "Homepage": "https://github.com/darrenburns/pytest-textual-snapshot"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "638b445c871e8dc096419e756bb3d34de9e074d302278f7e584d1bd8f0e4a0ef",
                "md5": "f781cc55a8a6133e87bfef75019fe736",
                "sha256": "879cc5de29cdd31cfe1b6daeb1dc5e42682abebcf4f88e7e3375bd5200683fc0"
            },
            "downloads": -1,
            "filename": "pytest_textual_snapshot-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f781cc55a8a6133e87bfef75019fe736",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6,<4.0",
            "size": 8580,
            "upload_time": "2023-08-23T11:13:10",
            "upload_time_iso_8601": "2023-08-23T11:13:10.457773Z",
            "url": "https://files.pythonhosted.org/packages/63/8b/445c871e8dc096419e756bb3d34de9e074d302278f7e584d1bd8f0e4a0ef/pytest_textual_snapshot-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7cf582c7e2dcbc2947dc68252821578404a0c5ec2ff6e5aa91a3ddc0e4bfbab",
                "md5": "5842a00bf14bf764dbc309b8fe6eddf5",
                "sha256": "63782e053928a925d88ff7359dd640f2900e23bc708b3007f8b388e65f2527cb"
            },
            "downloads": -1,
            "filename": "pytest_textual_snapshot-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5842a00bf14bf764dbc309b8fe6eddf5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6,<4.0",
            "size": 7476,
            "upload_time": "2023-08-23T11:13:11",
            "upload_time_iso_8601": "2023-08-23T11:13:11.901539Z",
            "url": "https://files.pythonhosted.org/packages/f7/cf/582c7e2dcbc2947dc68252821578404a0c5ec2ff6e5aa91a3ddc0e4bfbab/pytest_textual_snapshot-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-23 11:13:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "darrenburns",
    "github_project": "pytest-textual-snapshot",
    "github_not_found": true,
    "lcname": "pytest-textual-snapshot"
}
        
Elapsed time: 0.14881s