Jestspectation


NameJestspectation JSON
Version 1.4.3 PyPI version JSON
download
home_pagehttps://github.com/MaddyGuthridge/Jestspectation
SummaryPattern matching tools to test complex data structures
upload_time2024-08-01 02:10:41
maintainerNone
docs_urlNone
authorMaddy Guthridge
requires_python<4.0,>=3.9
licenseMIT
keywords jest pattern matching pytest equality
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # 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://github.com/MaddyGuthridge/Jestspectation",
    "name": "Jestspectation",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=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/f6/f4/ec8b1562e64dd1f11168cf08e53c89d40651a9b78bb47114d544ac7e9200/jestspectation-1.4.3.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\nimport jestspectation as expect\n\nassert {\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## 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\nimport jestspectation\n\njestspectation.configure().pytest_all_diffs = True\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Pattern matching tools to test complex data structures",
    "version": "1.4.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/MaddyGuthridge/Jestspectation/issues",
        "Documentation": "https://maddyguthridge.github.io/Jestspectation",
        "Homepage": "https://github.com/MaddyGuthridge/Jestspectation",
        "Online Documentation": "https://maddyguthridge.github.io/Jestspectation",
        "Repository": "https://github.com/MaddyGuthridge/Jestspectation"
    },
    "split_keywords": [
        "jest",
        " pattern",
        " matching",
        " pytest",
        " equality"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "20cd9d8496fc4eab98431c818d45fe1a05fdaf47ea80a4da60802be56ef453b2",
                "md5": "284efe153297c90ffa3341b7d5526482",
                "sha256": "7883f81db9dd10199b67220f46067314c5562092ce12fd4e5002b10e2e188635"
            },
            "downloads": -1,
            "filename": "jestspectation-1.4.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "284efe153297c90ffa3341b7d5526482",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 23134,
            "upload_time": "2024-08-01T02:10:39",
            "upload_time_iso_8601": "2024-08-01T02:10:39.997883Z",
            "url": "https://files.pythonhosted.org/packages/20/cd/9d8496fc4eab98431c818d45fe1a05fdaf47ea80a4da60802be56ef453b2/jestspectation-1.4.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f6f4ec8b1562e64dd1f11168cf08e53c89d40651a9b78bb47114d544ac7e9200",
                "md5": "d83b3e16ee295992766a0d60ae434145",
                "sha256": "9a961ba0279753e76c33080bfe915ba6a63661a969e9aa62fb65b95ac211f32b"
            },
            "downloads": -1,
            "filename": "jestspectation-1.4.3.tar.gz",
            "has_sig": false,
            "md5_digest": "d83b3e16ee295992766a0d60ae434145",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 14583,
            "upload_time": "2024-08-01T02:10:41",
            "upload_time_iso_8601": "2024-08-01T02:10:41.781581Z",
            "url": "https://files.pythonhosted.org/packages/f6/f4/ec8b1562e64dd1f11168cf08e53c89d40651a9b78bb47114d544ac7e9200/jestspectation-1.4.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-01 02:10:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MaddyGuthridge",
    "github_project": "Jestspectation",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "jestspectation"
}
        
Elapsed time: 0.41587s