Jestspectation


NameJestspectation JSON
Version 1.3.0 PyPI version JSON
download
home_pagehttps://github.com/MiguelGuthridge/Jestspectation
SummaryPattern matching tools to test complex data structures
upload_time2023-12-06 06:34:15
maintainer
docs_urlNone
authorMiguel Guthridge
requires_python>=3.9,<4.0
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)
}
```

## 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/MiguelGuthridge/Jestspectation",
    "name": "Jestspectation",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "jest,pattern,matching,pytest,equality",
    "author": "Miguel Guthridge",
    "author_email": "hdsq@outlook.com.au",
    "download_url": "https://files.pythonhosted.org/packages/07/f4/2b75be93781dd55e5fd9e559456a7f0cdda3b48d993540524b92695ede1b/jestspectation-1.3.0.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## 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.3.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/MiguelGuthridge/Jestspectation/issues",
        "Documentation": "https://miguelguthridge.github.io/Jestspectation",
        "Homepage": "https://github.com/MiguelGuthridge/Jestspectation",
        "Online Documentation": "https://miguelguthridge.github.io/Jestspectation",
        "Repository": "https://github.com/MiguelGuthridge/Jestspectation"
    },
    "split_keywords": [
        "jest",
        "pattern",
        "matching",
        "pytest",
        "equality"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7154464199a2ced6ce75bc8f9ac345421fea7341e969bcaf0ffcec137b1c010",
                "md5": "212ffeee22a5b2929f1406f02d989333",
                "sha256": "8245f4c0d76b9a3c5aa077003453ef40be33358cad17a1dde2707930b62d5083"
            },
            "downloads": -1,
            "filename": "jestspectation-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "212ffeee22a5b2929f1406f02d989333",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 22471,
            "upload_time": "2023-12-06T06:34:14",
            "upload_time_iso_8601": "2023-12-06T06:34:14.095650Z",
            "url": "https://files.pythonhosted.org/packages/d7/15/4464199a2ced6ce75bc8f9ac345421fea7341e969bcaf0ffcec137b1c010/jestspectation-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "07f42b75be93781dd55e5fd9e559456a7f0cdda3b48d993540524b92695ede1b",
                "md5": "ddd80f300f777c6e1715bb07e2ddd339",
                "sha256": "0113a67ffc9c855bac87d447f858e83a957397043a2adda06871e105e4a2acd3"
            },
            "downloads": -1,
            "filename": "jestspectation-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ddd80f300f777c6e1715bb07e2ddd339",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 14046,
            "upload_time": "2023-12-06T06:34:15",
            "upload_time_iso_8601": "2023-12-06T06:34:15.822553Z",
            "url": "https://files.pythonhosted.org/packages/07/f4/2b75be93781dd55e5fd9e559456a7f0cdda3b48d993540524b92695ede1b/jestspectation-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-06 06:34:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MiguelGuthridge",
    "github_project": "Jestspectation",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "jestspectation"
}
        
Elapsed time: 0.17866s