assertive


Nameassertive JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/peter-daly/assertive
SummaryA small assertion library for testing
upload_time2024-07-29 21:09:24
maintainerNone
docs_urlNone
authorPeter Daly
requires_python<4.0,>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Assertive

Assertive is a testing library that provides declarative assertions to you python tests.


## Core of assertive

Assertive is built on two core concepts:

 1. Criteria
 2. Assertions


### Criteria
Criteria are declarative statements that can be used with assert statements to give a richer test experience.

```python
assert 5 == is_greater_than(4)
assert 5 == is_odd()
assert 5 != is_even()
```

Criteria can also be composed with logical operators to give a richer experience in writing tests

```python
assert 5 == is_greater_than(4) & is_less_than(6) # Using AND
assert 5 == is_even() | is_less_than(6) # Using OR
assert 5 == is_even() ^ is_odd() # Using XOR
assert 5 == ~is_even()  # Using INVERT
```


### Assertions
`Criteria` can be used with python's inbuilt `assert` statement or you can also use `Assertions` from the assertive library.
The key difference between `assert` and `Assertions` is that `Assertions` give a more detailed Assertion Error when the test fails.

To use `Assertions` you simple use the `assert_that()` function

```python
assert_that(5).matches(is_greater_than(4))
assert_that(5).matches(is_odd())
assert_that(5).matches(is_greater_than(4) & is_odd())
assert_that(5).does_not_match(is_even())

assert 5 == is_greater_than(4)
assert 5 == is_odd()
assert 5 == is_greater_than(4) & is_odd()
assert 5 != is_even()
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/peter-daly/assertive",
    "name": "assertive",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Peter Daly",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/4f/d5/233a31e665d128fd7752616e1abe7692b5f6e5e4b11aeb7880d4d374012e/assertive-0.2.1.tar.gz",
    "platform": null,
    "description": "# Assertive\n\nAssertive is a testing library that provides declarative assertions to you python tests.\n\n\n## Core of assertive\n\nAssertive is built on two core concepts:\n\n 1. Criteria\n 2. Assertions\n\n\n### Criteria\nCriteria are declarative statements that can be used with assert statements to give a richer test experience.\n\n```python\nassert 5 == is_greater_than(4)\nassert 5 == is_odd()\nassert 5 != is_even()\n```\n\nCriteria can also be composed with logical operators to give a richer experience in writing tests\n\n```python\nassert 5 == is_greater_than(4) & is_less_than(6) # Using AND\nassert 5 == is_even() | is_less_than(6) # Using OR\nassert 5 == is_even() ^ is_odd() # Using XOR\nassert 5 == ~is_even()  # Using INVERT\n```\n\n\n### Assertions\n`Criteria` can be used with python's inbuilt `assert` statement or you can also use `Assertions` from the assertive library.\nThe key difference between `assert` and `Assertions` is that `Assertions` give a more detailed Assertion Error when the test fails.\n\nTo use `Assertions` you simple use the `assert_that()` function\n\n```python\nassert_that(5).matches(is_greater_than(4))\nassert_that(5).matches(is_odd())\nassert_that(5).matches(is_greater_than(4) & is_odd())\nassert_that(5).does_not_match(is_even())\n\nassert 5 == is_greater_than(4)\nassert 5 == is_odd()\nassert 5 == is_greater_than(4) & is_odd()\nassert 5 != is_even()\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A small assertion library for testing",
    "version": "0.2.1",
    "project_urls": {
        "Documentation": "https://peter-daly.github.io/assertive/",
        "Homepage": "https://github.com/peter-daly/assertive",
        "Repository": "https://github.com/peter-daly/assertive"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "65cff6c9092edd38a53687545bb5585f727fa00664da1456bbe0261da5279c20",
                "md5": "d42c6eff2c40c2b8b13b4cca03729ac5",
                "sha256": "f9986f53ebe91c8b329618fd7b66e64236c6645eb4e5a5b56c05ba24a58a4da6"
            },
            "downloads": -1,
            "filename": "assertive-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d42c6eff2c40c2b8b13b4cca03729ac5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 16564,
            "upload_time": "2024-07-29T21:09:22",
            "upload_time_iso_8601": "2024-07-29T21:09:22.698572Z",
            "url": "https://files.pythonhosted.org/packages/65/cf/f6c9092edd38a53687545bb5585f727fa00664da1456bbe0261da5279c20/assertive-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4fd5233a31e665d128fd7752616e1abe7692b5f6e5e4b11aeb7880d4d374012e",
                "md5": "a75be558740a0736d2aa01f0ca66d4c5",
                "sha256": "41038333f4c19919e7c0d4e378c3702e6d4c953513ef3c2628d6df458e67c976"
            },
            "downloads": -1,
            "filename": "assertive-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a75be558740a0736d2aa01f0ca66d4c5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 12243,
            "upload_time": "2024-07-29T21:09:24",
            "upload_time_iso_8601": "2024-07-29T21:09:24.126080Z",
            "url": "https://files.pythonhosted.org/packages/4f/d5/233a31e665d128fd7752616e1abe7692b5f6e5e4b11aeb7880d4d374012e/assertive-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-29 21:09:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "peter-daly",
    "github_project": "assertive",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "assertive"
}
        
Elapsed time: 0.32450s