Jestspectation


NameJestspectation JSON
Version 1.4.5 PyPI version JSON
download
home_pagehttps://maddyguthridge.github.io/Jestspectation
SummaryPattern matching tools to test complex data structures
upload_time2025-01-19 10:32:45
maintainerNone
docs_urlNone
authorMaddy Guthridge
requires_python>=3.9
licenseMIT
keywords jest pattern matching pytest equality
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Jestspectation

Pattern matching tools to test complex data structures.

The design is inspired by the `expect` system from JavaScript's Jest testing
framework.

```py
>>> import jestspectation as expect
>>> assert {
...     "a": 1,
...     "b": 2,
...     "c": 3.0,
... } == {
...     "a": 1,
...     "b": expect.Any(int),
...     "c": expect.FloatApprox(2.5, magnitude=0.5)
... }

```

## Documentation

Documentation can be found [on GitHub Pages](https://maddyguthridge.github.io/Jestspectation/).

## Installation

```sh
pip install jestspectation
```

## Usage with Pytest

The library can be used as a pytest plugin, which can give access to much more
detailed error messages when assertions fail.

This should result in output similar to the following

```txt
    def test_goodbye():
>       assert 1 == expect.Any(float)
E       assert Type mismatch
E         Expected any object of type float
E         Received 1 (int)
```

These advanced completions can also be used for most standard Python objects
by wrapping the expected values in an `Equals`. For example:

```txt
    def test_lists():
>       assert expect.Equals([1, 2, 3, 4]) == [1, 2, 3, 5, 6]
E       assert [1, 2, 3, 4] == [1, 2, 3, 5, 6]
E         !! [3] 4 == 5
E            Value mismatch
E            Expected 4
E            Received 5
E         ++ [4] 6
```

To automatically use Jestspectation's diff parsing, you can configure
Jestspectation.

```py
>>> import jestspectation
>>> jestspectation.configure().pytest_all_diffs = True

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://maddyguthridge.github.io/Jestspectation",
    "name": "Jestspectation",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "jest, pattern, matching, pytest, equality",
    "author": "Maddy Guthridge",
    "author_email": "hello@maddyguthridge.com",
    "download_url": "https://files.pythonhosted.org/packages/85/db/ec9c86ee59bcd2cd9dc08d43579aad1a2977cfebb16d997d69fde4b1d440/jestspectation-1.4.5.tar.gz",
    "platform": null,
    "description": "# Jestspectation\n\nPattern matching tools to test complex data structures.\n\nThe design is inspired by the `expect` system from JavaScript's Jest testing\nframework.\n\n```py\n>>> import jestspectation as expect\n>>> assert {\n...     \"a\": 1,\n...     \"b\": 2,\n...     \"c\": 3.0,\n... } == {\n...     \"a\": 1,\n...     \"b\": expect.Any(int),\n...     \"c\": expect.FloatApprox(2.5, magnitude=0.5)\n... }\n\n```\n\n## Documentation\n\nDocumentation can be found [on GitHub Pages](https://maddyguthridge.github.io/Jestspectation/).\n\n## Installation\n\n```sh\npip install jestspectation\n```\n\n## Usage with Pytest\n\nThe library can be used as a pytest plugin, which can give access to much more\ndetailed error messages when assertions fail.\n\nThis should result in output similar to the following\n\n```txt\n    def test_goodbye():\n>       assert 1 == expect.Any(float)\nE       assert Type mismatch\nE         Expected any object of type float\nE         Received 1 (int)\n```\n\nThese advanced completions can also be used for most standard Python objects\nby wrapping the expected values in an `Equals`. For example:\n\n```txt\n    def test_lists():\n>       assert expect.Equals([1, 2, 3, 4]) == [1, 2, 3, 5, 6]\nE       assert [1, 2, 3, 4] == [1, 2, 3, 5, 6]\nE         !! [3] 4 == 5\nE            Value mismatch\nE            Expected 4\nE            Received 5\nE         ++ [4] 6\n```\n\nTo automatically use Jestspectation's diff parsing, you can configure\nJestspectation.\n\n```py\n>>> import jestspectation\n>>> jestspectation.configure().pytest_all_diffs = True\n\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Pattern matching tools to test complex data structures",
    "version": "1.4.5",
    "project_urls": {
        "Bug Tracker": "https://github.com/MaddyGuthridge/Jestspectation/issues",
        "Documentation": "https://maddyguthridge.github.io/Jestspectation",
        "Homepage": "https://maddyguthridge.github.io/Jestspectation",
        "Repository": "https://github.com/MaddyGuthridge/Jestspectation"
    },
    "split_keywords": [
        "jest",
        " pattern",
        " matching",
        " pytest",
        " equality"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "31092c856764d7901e00560c444534ee4307e389a3b372d259fe6d0c837b3dcb",
                "md5": "0edc2564132bef1b8b0bdb8ba37f9cef",
                "sha256": "22f86f6b7b103b4244018510027a9b453f677097d7dfd4580a6d89e782669f0a"
            },
            "downloads": -1,
            "filename": "jestspectation-1.4.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0edc2564132bef1b8b0bdb8ba37f9cef",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 23172,
            "upload_time": "2025-01-19T10:32:43",
            "upload_time_iso_8601": "2025-01-19T10:32:43.779632Z",
            "url": "https://files.pythonhosted.org/packages/31/09/2c856764d7901e00560c444534ee4307e389a3b372d259fe6d0c837b3dcb/jestspectation-1.4.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "85dbec9c86ee59bcd2cd9dc08d43579aad1a2977cfebb16d997d69fde4b1d440",
                "md5": "6f641fcf31fe6f756dca308c8b017e05",
                "sha256": "ef709fd51d2e72950fc093c34d1fc5eacec568a8756a4f7f649cd5f6ba949570"
            },
            "downloads": -1,
            "filename": "jestspectation-1.4.5.tar.gz",
            "has_sig": false,
            "md5_digest": "6f641fcf31fe6f756dca308c8b017e05",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 14224,
            "upload_time": "2025-01-19T10:32:45",
            "upload_time_iso_8601": "2025-01-19T10:32:45.540667Z",
            "url": "https://files.pythonhosted.org/packages/85/db/ec9c86ee59bcd2cd9dc08d43579aad1a2977cfebb16d997d69fde4b1d440/jestspectation-1.4.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-19 10:32:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MaddyGuthridge",
    "github_project": "Jestspectation",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "jestspectation"
}
        
Elapsed time: 0.38393s