{"id":20955,"library":"asserts","title":"asserts","description":"A standalone assertions library providing a rich set of assertion functions beyond unittest, with support for JSON subset checking, datetime assertions, regex, and context managers. Current version 0.14.0, requires Python >=3.10, released irregularly.","status":"active","version":"0.14.0","language":"python","source_language":"en","source_url":"https://github.com/srittau/python-asserts","tags":["testing","assertions","standalone","unittest","python3"],"install":[{"cmd":"pip install asserts","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"asserts is a flat namespace, not a package with submodules.","wrong":"from asserts.asserts import assert_equals","symbol":"assert_equals","correct":"from asserts import assert_equals"},{"note":"assert_raises is a context manager, not a function returning bool.","wrong":"from asserts import assert_raises as * or from unittest import assertRaises","symbol":"assert_raises","correct":"from asserts import assert_raises"},{"note":"Exists is deprecated since 0.13.0 in favor of Present and Absent.","wrong":"from asserts import Exists","symbol":"Present","correct":"from asserts import Present"},{"note":"for checking JSON objects are subsets.","symbol":"assert_json_subset","correct":"from asserts import assert_json_subset"}],"quickstart":{"code":"from asserts import assert_equals, assert_raises\n\ndef test_addition():\n    assert_equals(2 + 2, 4)\n\nwith assert_raises(ValueError):\n    int('abc')","lang":"python","description":"Basic usage: use assert_equals for equality, assert_raises as a context manager for exception testing."},"warnings":[{"fix":"Upgrade to Python 3.10+ or pin asserts<0.14.0.","message":"Python 3.8 and 3.9 support dropped in 0.14.0. Requires Python >=3.10.","severity":"breaking","affected_versions":">=0.14.0"},{"fix":"Replace Exists with Present for existence or Absent for non-existence.","message":"Exists is deprecated since 0.13.0; use Present or Absent instead.","severity":"deprecated","affected_versions":">=0.13.0"},{"fix":"Use 'with assert_raises(Exception):' pattern.","message":"assert_raises and assert_warns are context managers, not decorators. Must use 'with' statement.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure datetime arguments are naive or adjust exception handling.","message":"assert_datetime_about_now and assert_datetime_about_now_utc now raise AssertionError instead of TypeError for timezone-aware datetimes.","severity":"breaking","affected_versions":">=0.14.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'pip install asserts'.","cause":"Package not installed.","error":"ModuleNotFoundError: No module named 'asserts'"},{"fix":"Use with assert_raises(ExcType): ...","cause":"Using assert_raises as a decorator instead of context manager.","error":"TypeError: 'AssertRaisesContext' object is not callable"},{"fix":"Use 'from asserts import Present' and replace Exists with Present.","cause":"Exists was renamed to Present in 0.13.0.","error":"AttributeError: module 'asserts' has no attribute 'Exists'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}