unittest-assertions 3.1

Creator: bradpython12

Last updated:

0 purchases

unittest-assertions 3.1 Image
unittest-assertions 3.1 Images

Languages

Categories

Add to Cart

Description:

unittestassertions 3.1

unittest_assertions
Thin wrapper around the python builtin unittest 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, documented, and tested makes it great for editor support and extension.
There is More!!!:

assertify: Simple, Flexible, and Extendable python3.6+ library to evaluate an expression and return True/False or raise an AssertionError or Exception.



Installation
pip install unittest-assertions

Examples
from unittest_assertions.identity import AssertIsInstance

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

from unittest_assertions import AssertEqual

assert_equal = AssertEqual()
assert_equal(1, 1)
assert_equal(first="hello", second="hello")

from unittest_assertions import AssertNotIn
assert_in = AssertNotIn()
assert_in(member=1, container=[5,2,3])

Asserters
Container



Asserter
Expression




AssertIn
assert member in container


AssertNotIn
assert member not in container



Control



Asserter
Expression




AssertRaises
assert function raises expected_exception


AssertWarns
assert function warns expected_warning


AssertLogs
assert logger(level)



Equality



Asserter
Expression




AssertEqual
assert first == second


AssertNotEqual
assert first != second


AssertAlmostEqual
assert first ~= second


AssertNotAlmostEqual
assert first !~= second


AssertCountEqual
assert Counter(list(first) == Counter(list(second))


AssertMultilineEqual
assert first.splitlines() == second.splitlines()


AssertSequenceEqual
assert seq1 == seq2


AssertListEqual
assert list1 == list2


AssertTupleEqual
assert tuple1 == tuple2


AssertSetEqual
assert set1 == set2


AssertDictEqual
assert dict1 == dict2


AssertLess
assert a < b


AssertLessEqual
assert a <= b


AssertGreater
assert a > b


AssertGreater
assert a >= b



Identity



Asserter
Expression




AssertTrue
assert expr is True


AssertFalse
assert expr is False


AssertIs
assert exp1 is exp2


AssertIsNot
assert exp1 is not exp2


AssertIsNone
assert obj is None


AssertIsNotNone
assert obj is not None


AssertIsInstance
assert isinstance(obj,class)


AssertIsNotInstance
assert not isinstance(obj,class)



Regex



Asserter
Expression




AssertRaisesRegex
assert expected_regex in expected_exception_message


AssertWarnsRegex
assert expected_regex in expected_warning_message


AssertRegex
assert text in expected_regex


AssertNotRegex
assert text not in expected_regex

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.