asserts


Nameasserts JSON
Version 0.13.1 PyPI version JSON
download
home_pagehttps://github.com/srittau/python-asserts
SummaryStand-alone Assertions
upload_time2024-04-29 18:50:12
maintainerNone
docs_urlNone
authorSebastian Rittau
requires_python>=3.8.1
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Asserts

[![License](https://img.shields.io/pypi/l/asserts.svg)](https://pypi.python.org/pypi/asserts/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/asserts)](https://pypi.python.org/pypi/asserts/)
[![GitHub](https://img.shields.io/github/release/srittau/python-asserts/all.svg)](https://github.com/srittau/python-asserts/releases/)
[![pypi](https://img.shields.io/pypi/v/asserts.svg)](https://pypi.python.org/pypi/asserts/)
[![GitHub Actions](https://img.shields.io/github/workflow/status/srittau/python-asserts/Test%20and%20lint)](https://github.com/srittau/python-asserts/actions/workflows/test-and-lint.yml)

Stand-alone Assertions for Python

This package provides a few advantages over the assertions provided by
unittest.TestCase:

- Can be used stand-alone, for example:
  - In test cases, not derived from TestCase.
  - In fake and mock classes.
  - In implementations as rich alternative to the assert statement.
- PEP 8 compliance.
- Custom stand-alone assertions can be written easily.
- Arguably a better separation of concerns, since TestCase is responsible
  for test running only, if assertion functions are used exclusively.

There are a few regressions compared to assertions from TestCase:

- The default assertion class (`AssertionError`) can not be overwritten. This
  is rarely a problem in practice.
- asserts does not support the `addTypeEqualityFunc()` functionality.

Usage:

```python
>>> from asserts import assert_true, assert_equal, assert_raises
>>> my_var = 13
>>> assert_equal(13, my_var)
>>> assert_true(True, msg="custom failure message")
>>> with assert_raises(KeyError):
...     raise KeyError()
```

Failure messages can be customized:

```python
>>> assert_equal(13, 14, msg_fmt="{got} is wrong, expected {expected}")
Traceback (most recent call last):
  ...
AssertionError: 14 is wrong, expected 13
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/srittau/python-asserts",
    "name": "asserts",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8.1",
    "maintainer_email": null,
    "keywords": null,
    "author": "Sebastian Rittau",
    "author_email": "srittau@rittau.biz",
    "download_url": "https://files.pythonhosted.org/packages/aa/a1/4ebe27df4fee2e09c972d9789adb89eb3199cd8ae577a3907ab2a852becf/asserts-0.13.1.tar.gz",
    "platform": null,
    "description": "# Python Asserts\n\n[![License](https://img.shields.io/pypi/l/asserts.svg)](https://pypi.python.org/pypi/asserts/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/asserts)](https://pypi.python.org/pypi/asserts/)\n[![GitHub](https://img.shields.io/github/release/srittau/python-asserts/all.svg)](https://github.com/srittau/python-asserts/releases/)\n[![pypi](https://img.shields.io/pypi/v/asserts.svg)](https://pypi.python.org/pypi/asserts/)\n[![GitHub Actions](https://img.shields.io/github/workflow/status/srittau/python-asserts/Test%20and%20lint)](https://github.com/srittau/python-asserts/actions/workflows/test-and-lint.yml)\n\nStand-alone Assertions for Python\n\nThis package provides a few advantages over the assertions provided by\nunittest.TestCase:\n\n- Can be used stand-alone, for example:\n  - In test cases, not derived from TestCase.\n  - In fake and mock classes.\n  - In implementations as rich alternative to the assert statement.\n- PEP 8 compliance.\n- Custom stand-alone assertions can be written easily.\n- Arguably a better separation of concerns, since TestCase is responsible\n  for test running only, if assertion functions are used exclusively.\n\nThere are a few regressions compared to assertions from TestCase:\n\n- The default assertion class (`AssertionError`) can not be overwritten. This\n  is rarely a problem in practice.\n- asserts does not support the `addTypeEqualityFunc()` functionality.\n\nUsage:\n\n```python\n>>> from asserts import assert_true, assert_equal, assert_raises\n>>> my_var = 13\n>>> assert_equal(13, my_var)\n>>> assert_true(True, msg=\"custom failure message\")\n>>> with assert_raises(KeyError):\n...     raise KeyError()\n```\n\nFailure messages can be customized:\n\n```python\n>>> assert_equal(13, 14, msg_fmt=\"{got} is wrong, expected {expected}\")\nTraceback (most recent call last):\n  ...\nAssertionError: 14 is wrong, expected 13\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Stand-alone Assertions",
    "version": "0.13.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/srittau/python-asserts/issues",
        "Changes": "https://github.com/srittau/python-asserts/blob/main/CHANGELOG.md",
        "GitHub": "https://github.com/srittau/python-asserts",
        "Homepage": "https://github.com/srittau/python-asserts",
        "Repository": "https://github.com/srittau/python-asserts"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8fec1dd038c82f1dbe28daa0c9e7cffdf85bdc5b8161d23896f62da87754e834",
                "md5": "b4658e72c574b1da3f0449f129a3fbaf",
                "sha256": "f76aa6cc9950326801a4c0ecc2fcc57af2e604effe8fb7136d2802aec0b8f7b3"
            },
            "downloads": -1,
            "filename": "asserts-0.13.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b4658e72c574b1da3f0449f129a3fbaf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1",
            "size": 12801,
            "upload_time": "2024-04-29T18:50:10",
            "upload_time_iso_8601": "2024-04-29T18:50:10.495894Z",
            "url": "https://files.pythonhosted.org/packages/8f/ec/1dd038c82f1dbe28daa0c9e7cffdf85bdc5b8161d23896f62da87754e834/asserts-0.13.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aaa14ebe27df4fee2e09c972d9789adb89eb3199cd8ae577a3907ab2a852becf",
                "md5": "b4b3c8b24dcb9b2b601f0d9ab8ca2aef",
                "sha256": "958a69024f9c95905d1391bfede613e9fef987dbf74a399ef3952836c2c2a3bd"
            },
            "downloads": -1,
            "filename": "asserts-0.13.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b4b3c8b24dcb9b2b601f0d9ab8ca2aef",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1",
            "size": 12842,
            "upload_time": "2024-04-29T18:50:12",
            "upload_time_iso_8601": "2024-04-29T18:50:12.830431Z",
            "url": "https://files.pythonhosted.org/packages/aa/a1/4ebe27df4fee2e09c972d9789adb89eb3199cd8ae577a3907ab2a852becf/asserts-0.13.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-29 18:50:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "srittau",
    "github_project": "python-asserts",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "asserts"
}
        
Elapsed time: 0.22855s