All Projects → msoedov → quick.py

msoedov / quick.py

Licence: other
Property-based testing library for Python

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to quick.py

Fast Check
Property based testing framework for JavaScript (like QuickCheck) written in TypeScript
Stars: ✭ 2,604 (+17260%)
Mutual labels:  quickcheck, property-based-testing
Fsharp Hedgehog
Release with confidence, state-of-the-art property testing for .NET.
Stars: ✭ 219 (+1360%)
Mutual labels:  quickcheck, property-based-testing
pbt-frameworks
An overview of property-based testing functionality
Stars: ✭ 29 (+93.33%)
Mutual labels:  quickcheck, property-based-testing
Stream data
Data generation and property-based testing for Elixir. 🔮
Stars: ✭ 597 (+3880%)
Mutual labels:  quickcheck, property-based-testing
Quick check.js
A JS implementation of quick_check
Stars: ✭ 48 (+220%)
Mutual labels:  quickcheck, property-based-testing
Rantly
Ruby Imperative Random Data Generator and Quickcheck
Stars: ✭ 241 (+1506.67%)
Mutual labels:  quickcheck, property-based-testing
Jqf
JQF + Zest: Coverage-guided semantic fuzzing for Java.
Stars: ✭ 340 (+2166.67%)
Mutual labels:  quickcheck, property-based-testing
efftester
Effect-Driven Compiler Tester for OCaml
Stars: ✭ 37 (+146.67%)
Mutual labels:  quickcheck, property-based-testing
Qcstm
A simple state-machine framework for OCaml based on QCheck
Stars: ✭ 50 (+233.33%)
Mutual labels:  quickcheck, property-based-testing
Rapid
Rapid is a Go library for property-based testing that supports state machine ("stateful" or "model-based") testing and fully automatic test case minimization ("shrinking")
Stars: ✭ 213 (+1320%)
Mutual labels:  quickcheck, property-based-testing
Junit Quickcheck
Property-based testing, JUnit-style
Stars: ✭ 821 (+5373.33%)
Mutual labels:  quickcheck, property-based-testing
quickcheck
Randomized testing for Prolog à la QuickCheck
Stars: ✭ 18 (+20%)
Mutual labels:  quickcheck, property-based-testing
Quickcheck State Machine
Test monadic programs using state machine based models
Stars: ✭ 192 (+1180%)
Mutual labels:  quickcheck, property-based-testing
Haskell Hedgehog
Release with confidence, state-of-the-art property testing for Haskell.
Stars: ✭ 584 (+3793.33%)
Mutual labels:  quickcheck, property-based-testing
kitimat
A library for generative, property-based testing in TypeScript and Jest.
Stars: ✭ 68 (+353.33%)
Mutual labels:  quickcheck, property-based-testing
Quicktheories
Property based testing for Java 8
Stars: ✭ 483 (+3120%)
Mutual labels:  quickcheck, property-based-testing
fuzz-rest-api
Derive property based testing fast-check into a fuzzer for REST APIs
Stars: ✭ 38 (+153.33%)
Mutual labels:  quickcheck, property-based-testing
ava-fast-check
Property based testing for AVA based on fast-check
Stars: ✭ 44 (+193.33%)
Mutual labels:  quickcheck, property-based-testing
edd
Erlang Declarative Debugger
Stars: ✭ 20 (+33.33%)
Mutual labels:  quickcheck, property-based-testing
Swiftcheck
QuickCheck for Swift
Stars: ✭ 1,319 (+8693.33%)
Mutual labels:  quickcheck, property-based-testing

quick.py

Build Status PyPI Supported versions Code Issues Join the chat at https://gitter.im/msoedov/quick.py

Quick.py is a property-based testing library for Python inspired by the Haskell library QuickCheck. The core idea of QuickCheck is that instead of enumerating expected input and output for unit tests, you write properties about your function that should hold true for all inputs. This lets you write concise, powerful tests.

Installation

pip install quick.py

Examples

Basic example:

# example.py
from quick.features import QuickCheck

qc = QuickCheck(max_count=100)


@qc.forall('Associative property of addition for integers')
def prop(x: int, y: int):
    return (x + y) == (y + x)


TestAddtion = qc.as_testcase()
>>> nosetests example.py
....................................................................................................
----------------------------------------------------------------------
Ran 100 tests in 0.061s

OK

Custom generators:

# example.py
from quick.features import QuickCheck
from quick.generators import number
from quick.arbitrary import A

qc = QuickCheck(max_count=100)


def non_empty_list(el: number, ls: [number]):
    """
    Generator which always returns non empty list
    """
    ls.append(el)
    return ls


@qc.forall('The first element of a sorted list should be always lesser or eq than the last')
def prop(x: non_empty_list):
    sorted_x = sorted(x)
    first = sorted_x[0]
    last = sorted_x[-1]
    return first <= last


TestSort = qc.as_testcase()
>>> nosetests example.py
....................................................................................................
----------------------------------------------------------------------
Ran 100 tests in 0.070s

OK

Features

  • Integration with unittests library
  • Custom generators
  • Simplification/Shrinking of failure input (in progress)

Controlled Randomness

def working_time(a: A):
    day = a.choose_one('Monday', 'Tuesday', 'Wednesday', 'Thursday')
    hour = a.choose(8, 17)
    return {'day': day, 'hour': hour}

Custom object generators

class User(object):

    def __init__(self, name, age):
        self.name = name
        self.age = age


def user_gen(name: str, a: A):
    age = a.choose(18, 100)
    return User(name, age)


@forall('Valid users')
def prop(user: user_gen):
    return ...

Shrinking

TBD, It's a trial implementation, and has limited functionalities yet.

Python 2 support?

Oups, sorry

Getting Help

For feature requests and bug reports submit an issue to the GitHub issue tracker for quick.py.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].