Skip to main content

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.

Logo

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

MIT © lambdacasserole.

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

exhaustion-1.0.3.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

exhaustion-1.0.3-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

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