https://github.com/lambdacasserole/exhaustion
A tiny library to help in exhaustive testing of Boolean functions in Python.
https://github.com/lambdacasserole/exhaustion
boolean-function exhaustive-search formal-verification python testing
Last synced: about 1 year ago
JSON representation
A tiny library to help in exhaustive testing of Boolean functions in Python.
- Host: GitHub
- URL: https://github.com/lambdacasserole/exhaustion
- Owner: lambdacasserole
- License: mit
- Created: 2022-08-15T10:04:53.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-15T19:00:12.000Z (almost 4 years ago)
- Last Synced: 2024-04-30T05:01:53.907Z (about 2 years ago)
- Topics: boolean-function, exhaustive-search, formal-verification, python, testing
- Language: Python
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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`:
```sh
pip install exhaustion
```
## Usage
Usage is very straightforward, `exhaustion` is compatible with any testing library that supports assertions.
```python
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](https://github.com/letmaik/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
[MIT](LICENSE) © [lambdacasserole](https://github.com/lambdacasserole).