In pyqcy, the test properties are defined as regular Python functions
but they are all adorned with the
Here’s an example:
from pyqcy import * @qc def sorting_preserves_length( l=list_(of=int, min_length=1, max_length=128) ): before_sort = l after_sort = list(sorted(l)) assert len(before_set) == len(after_sort)
Inside the function, we use its parameters as a sort of quantified variables. As you can see, their defaults are somewhat unusual: they specify how to obtain arbitrary (random) values for those variables. pyqcy will take those specifications, use them to automatically generate test data and then invoke your property’s code.
For more information about different way of running tests for your properties, check the documentation on that.
Decorator for Python functions that define properties to be tested by pyqcy.
It is expected that default values for function arguments define generators that will be used to generate data for test cases. See the section about using generators for more information.
Example of using
@qcto define a test property:
@qc def len_behaves_correctly( l=list_(int, min_length=1, max_length=64) ): assert len(l) == l.__len__()
Parameters: tests – Number of tests to execute for this property. If omitted, the default number of 100 tests will be executed.