A tiny library to help in exhaustive testing of Boolean functions in Python.
Project description
exhaustion
A tiny library to help in exhaustive testing of Boolean functions in Python.
Requirements
- Python 3.6 or newer
Installation
Exhaustion can be installed using pip:
pip install exhaustion
Usage
Usage is very straightforward, exhaustion is compatible with any testing library that supports assertions.
import unittest
from exhaustion import exhaust
def _and(a: bool, b: bool):
""" A simple wrapper over the Python `and` operator for demonstration purposes.
Args:
a (bool): The left-hand operand.
b (bool): The right-hand operand.
Returns:
bool: The Boolean conjunction of the arguments provided.
"""
return a and b
class TestAndAlgebraic(unittest.TestCase):
""" Tests the algebraic properties of the _and function.
"""
def test_and_commutative(self):
""" Proves by exhaustion that the _and function is commutative.
"""
# The lambda below will execute for every possible combination of Boolean arguments.
exhaust(lambda a, b: self.assertTrue(_and(a, b) == _and(b, a)))
Related Projects
This library is intentionally very minimal, and was designed to be so. If you're looking for a richer feature set, you might consider the following projects:
- exhaust - Not to be confused with this project, a library that supports exhastive enumeration of any finite set you can express using a generator function.
License
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file exhaustion-1.0.3.tar.gz.
File metadata
- Download URL: exhaustion-1.0.3.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.6.9 Linux/5.4.0-124-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
984fdbc5851f2d553600497377b6c5d7abda11c2f4cd3dc7758a0133c178697a
|
|
| MD5 |
98c8a52d2aa62c02fa1a88f71072a6bb
|
|
| BLAKE2b-256 |
fd1048b2de2c5e9624f146c7bcce0a7694d737cd67fc355c6716ae4f1c1da0af
|
File details
Details for the file exhaustion-1.0.3-py3-none-any.whl.
File metadata
- Download URL: exhaustion-1.0.3-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.6.9 Linux/5.4.0-124-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1576bafad69cb183b0f634aef006969fe0b5cf7d028f8a5d1a0c2dc462479d2
|
|
| MD5 |
069d05402068eb5fbd080b5abb9e73e7
|
|
| BLAKE2b-256 |
1cbe9223b8e617f32cfa9729e3c856ce24bac4bf49f3d5b6901ebc16b9e86ef4
|