Contains main functions and facilities you will need when using pyquchk. They all can be imported with from pyquchk import ..., no need to specify exact modules.
Decorator for a test function.
For usage examples see Writing and running tests.
Parameters: | ntests – number of tests |
---|
Test the function func on _ntests tests.
For usage examples see Property checking.
Parameters: |
|
---|---|
Returns: | information about the tests run |
Return type: |
Represent the result of performed testing (returned by for_all()).
Data on which the tested function failed (as a dict), or None if passed
Exception raised by the function, or ReturnedFalse if function returned False, or None if passed
Exception traceback, or None if passed
'OK' if passed and 'FAIL' if not
Automatically raised when the tested function returns a value which evaluates to a bool False.
Exact value returned by the function (evaluates to a False bool value)
Raised when a test which uses qc() decorator fails.
It contains the original test data for which the test has failed, and the exception raised by the tested function. Actually, a CheckError instance is always also an instance of the exception raised by the tested function, so you can except it as usually.
Exception raised by the function, or ReturnedFalse if function returned False
Data which caused the function to raise an exception
Contains all the built-in Arbitrary instances. They all can be imported with from pyquchk.arbitraries import ..., no need to specify exact modules.
Choice from a list of constant values.
alias of float_fraction
Float with significand, exponent and sign taken according to the parameters.
Uniformly distributed float from the specified range, representing a fraction with a denominator taken according to denom.
Uniformly distributed float from the specified range.
Uniformly distributed integer from the specified range.
Check if x could’ve been generated by self.
You can override this method, but it’s not used now in any way.
Contain utility functions and decorators useful when defining custom Arbitrary instances. Usually they haven’t much use otherwise.
Yield items from the given iterables in a round-robin fashion.
What it does exactly is better explained with a simple example:
>>> list(roundrobin(['ABC', 'D', 'EF']))
['A', 'D', 'E', 'B', 'F', 'C']
Parameters: | iterables – List of finite or infinite iterables. |
---|
Like random.choice(), but the probability an item is chosen is proportional to its weight.
For convenience, this function is available as random.choice_weighted if you imported utils.
Parameters: | elements – list of tuples (item, weight), weight is any numeric value |
---|
Decorator, when applied to a generator method (e.g. gen_serial()) filters generated values to keep only those for which could_generate() returns True.
Decorator, when applied to a method returning different values each time (e.g. next_random()) runs this method multiple times until a value for which could_generate() returns True is returned, and finally returns this value.
Decorator, when applied to a generator method (e.g. gen_serial(), shrink()) filters generated values to keep only unique values. For the shrink() method the value passed to the method is also considered.