Skip to main content

About

inputgen is a Python package that provides automated input generation, useful for bounded exhaustive testing and the generation of complex data structures for test inputs.

This tool was originally created as a class project—Verification and Validation of Software with professor Sarfraz Khurshid—and is largely modeled after Korat and its related research. Korat is an input generation tool for Java programs.

Official documentation, other than this readme, is currently lacking; however, the associated class paper provides a detailed description the implementation and related research.

Features

  • Uses multiple processes to speed input generation.

  • Search space pruning:

    • Backtracking - The generated objects are instrumented to record the order of their field accesses, which occurs while checking the well-formedness of their structure in the defined predicate. Upon rejection of an input combination, alternative values are first tried on the last-accessed field(s).

      This feature is enabled by default, and can be disabled by setting enable_backtracking=False when instantiating a Factory object.

    • Non-isomorphic generation - Only objects with unique structure are generated. Two inputs are isomorphic, or identical in structure, if their object graphs reachable from the root object are isomorphic.

      For example, if building a binary tree of size two, using five possible node objects, then there are only two possible valid, non-isomorphic structures—a root node and left child, or a root node and right child.

      This feature is enabled by default, and can be disabled by setting enable_iso_breaking=False when instantiating a Factory object.

Requirements and Installation

inputgen requires Python 2.5 or later. If using Python 2.6, inputgen will install and make use of the stand-alone ordereddict package. If using Python 2.5, inputgen will additionally install and make use of the stand-alone multiprocessing package.

To install inputgen and required dependencies, run:

pip install inputgen

The source can be found here: https://bitbucket.org/gdub/python-inputgen/

Example

Below is a simple example. For more examples, see the inputgen/examples/ directory.

Given the following code:

import inputgen

class SquareTest(inputgen.TestCase):

    @staticmethod
    def repOK(factory):
        return True

    @staticmethod
    def fin(min=0, max=10):
        f = inputgen.Factory(enable_backtracking=False,
                             enable_iso_breaking=False)
        f.set('number', range(min, max))
        return f

    def run_method(self, factory):
        num = factory.number
        self.assertEqual(num * num, num ** 2)

if __name__ == "__main__":
    import unittest
    unittest.main()

Save the code to a file named square.py and then run the unit test:

python square.py

When run, inputgen will generate all possible combinations of the finitized fields. In the example above this will produce ten combinations, with a single field (number) ranging from 0 to 9.

Release files for inputgen 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inputgen 0.7.1
File Size Uploaded
inputgen-0.7.1.tar.gz 224.8 kB Details

Release files / inputgen-0.7.1.tar.gz

Download URL inputgen-0.7.1.tar.gz
Size 224.8 kB
Tags Source
SHA-256 checksum
How to use checksums
782265845babd1560fe5469a8d635bd304262ff7c37372d2c079f3e4dc8d0c58
BLAKE2b-256 checksum
How to use checksums
529f4de57c0a82fad47563c8a14e4c1dae3f75935a105f555d8fae31829d9c9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.7.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page