22 :target: https://assertionlib.readthedocs.io/en/latest/
33.. image :: https://badge.fury.io/py/AssertionLib.svg
44 :target: https://badge.fury.io/py/AssertionLib
5- .. image :: https://travis-ci.org/nlesc-nano/AssertionLib.svg?branch=master
6- :target: https://travis-ci.org/nlesc-nano/AssertionLib
75.. image :: https://github.com/nlesc-nano/AssertionLib/workflows/Python%20package/badge.svg
86 :target: https://github.com/nlesc-nano/AssertionLib/actions
97.. image :: https://codecov.io/gh/nlesc-nano/AssertionLib/branch/master/graph/badge.svg
2220
2321
2422##################
25- AssertionLib 2.3.2
23+ AssertionLib 3.0.0
2624##################
27-
2825A package for performing assertions and providing informative exception messages.
2926
3027
3128Installation
3229************
33-
34- AssertionLib has no external dependencies and can be installed as following:
35-
3630* PyPi: ``pip install AssertionLib ``
3731* GitHub: ``pip install git+https://github.com/nlesc-nano/AssertionLib ``
3832
3933
4034Usage
4135*****
42-
4336A comprehensive overview of all available assertion methods is
4437provided in the documentation _.
4538A few examples of some basic assertion:
4639
4740.. code :: python
4841
49- >> > from assertionlib import assertion
5042 >> > import numpy as np
43+ >> > from assertionlib import assertion
5144
5245 # Assert the output of specific callables
5346 >> > assertion.eq(5 , 5 ) # 5 == 5
@@ -65,7 +58,7 @@ A few examples of some basic assertion:
6558 # Apply post-processing before conducting the assertion
6659 >> > ar_large = np.ones(10 )
6760 >> > ar_small = np.zeros(10 )
68- >> > assertion.gt(ar_large, ar_small, post_process = all ) # all(ar_large > ar_small)
61+ >> > assertion.gt(ar_large, ar_small, post_process = np. all) # all(ar_large > ar_small)
6962
7063 # Perform an assertion which will raise an AssertionError
7164 >> > assertion.eq(5 , 6 , message = ' Fancy custom error message' ) # 5 == 6
@@ -126,6 +119,11 @@ during/before the assertion process:
126119 ...
127120 TypeError : object of type ' int' has no len ()
128121
122+
123+ .. code :: python
124+
125+ >> > from assertionlib import assertion
126+
129127 >> > assertion.len(5 , exception = TypeError ) # i.e. len(5) should raise a TypeError
130128 >> > assertion.len([5 ], exception = TypeError )
131129 Traceback (most recent call last):
@@ -143,10 +141,9 @@ method and adding it to an instance with ``AssertionManager.add_to_instance()``:
143141
144142.. code :: python
145143
146- >> > from typing import Any
147144 >> > from assertionlib import assertion
148145
149- >> > def my_fancy_func (a : Any ) -> bool :
146+ >> > def my_fancy_func (a : object ) -> bool :
150147 ... return False
151148
152149 # Approach #1, supply to-be asserted callable to assertion.assert_()
@@ -160,6 +157,11 @@ method and adding it to an instance with ``AssertionManager.add_to_instance()``:
160157 output: bool = False
161158 a: int = 5
162159
160+
161+ .. code :: python
162+
163+ >> > from assertionlib import assertion
164+
163165 # Approach #2, permanantly add a new bound method using assertion.add_to_instance()
164166 >> > assertion.add_to_instance(my_fancy_func)
165167 >> > assertion.my_fancy_func(5 )
0 commit comments