Skip to main content

No project description provided

Project description

unittest_assertions

Made the unittest assertions standalone allowing developers to use the builtin assertions for non unittest use cases.

Key Features:

  • Easy: Designed to make it be simple allowing developers to use the builtin unittest assertions for their own use cases.
  • Great Developer Experience: Being fully typed makes it great for editor support.
  • There is More!!!:
    • assertify: Simple, Flexible, and Extendable python3.6+ library to evaulate an expression and return True/False or raise an AssertionError or Exception.
    • assertify_predicates: Is an extension of Assertify which allows for assertifying predicates. This is useful for validating variables or user input.
    • descriptify: Descriptify is a library that contians helpful python descriptors. It uses assertify_predicates to validate various descriptors.

Installation

pip install "git+https://github.com/tybruno/unittest_assertions.git#egg=unittest_assertions"

Example

from unittest_assertions.identity import AssertIsInstance

assert_is_instance = AssertIsInstance(msg="Raised a AssertionError")
assert_is_instance("example str", int) # raise TypeError("'example str' is not an instance of <class 'int'> : Raised a AssertionError")

Asserters

Comparison

Asserter Expression
AssertEqual first == second
AssertNotEqual first != Second
AssertAlmostEqual first ~ second
AssertNotAlmostEqual first !~ second
AssertCountEqual len(first) == len(second)
AssertMultilineEqual first.splitlines() == second.splitlines()
AsseritySequenceEqual seq1 == seq2
AssertListEqual list1 == list2
AssertTupleEqual tuple1 == tuple2
AssertSetEqual set1 == set2
AssertDictEqual dict1 == dict2
AssertLess a < b
AssertLessEqual a <= b
AssertGreater a > b
AssertGreater a >= b

Container

Asserter Expression
AssertIn member in container
AssertNotIn member not in container

Control

Asserter Expression
AssertRaises excpected_exception
AssertWarns excpected_warning
AssertLogs logger(level)

Identity

Asserter Expression
AssertIs exp1 is exp2
AssertIsNot exp1 is not exp2
AssertIsNone obj is None
AssertIsNotNone obj is not None
AssertIsInstance isinstance(obj,class)
AssertIsInstances isinstance(obj,cls) for cls in classes
AssertIsNotInstance not isinstance(obj,class)
AssertIsNotInstances not isinstance(obj,cls) for cls in classes

Logic

Asserter Expression
AssertTrue expr
AssertFalse not expr

Regex

Asserter Expression
AssertRaisesRegex expected_regex in expected_exception_message
AssertWarnsRegex expected_regex in expected_warning_message
AssertRegex text in expected_regex
AssertNotRegex text not in expected_regex

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unittest_assertions-1.0.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

unittest_assertions-1.0.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file unittest_assertions-1.0.0.tar.gz.

File metadata

  • Download URL: unittest_assertions-1.0.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for unittest_assertions-1.0.0.tar.gz
Algorithm Hash digest
SHA256 aa82015e8d1c53f7da718933db8ad0d874997a0653eed2259f8271b9fe6ab1f4
MD5 d325608248877dace43551fd7de3135f
BLAKE2b-256 028bd223ce9f3a736d09b574947c8ccafebeb780f6912788a3254d66740dfc63

See more details on using hashes here.

File details

Details for the file unittest_assertions-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: unittest_assertions-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for unittest_assertions-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d447aa4788beb22dee19fd4225edd72c9c7f1cf2128e074e505d121fa3d486e
MD5 b2ec542fcbf87fb57c58edcaf2cc422f
BLAKE2b-256 911811986f74906fa00b2396498e140a5db2c0fda125854662a915cb84802bbe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page