Giter Site home page Giter Site logo

stdlib-property-tests's Introduction

stdlib-property-tests

Property-based tests for the Python standard library (and builtins)

Goal

Find and fix bugs in Python, before they ship to users.

CPython's existing test suite is good, but bugs still slip through occasionally. We think that using property-based testing tools - i.e. Hypothesis - can help with this. They're no magic bullet, but computer-assisted testing techniques routinely try inputs that humans wouldn't think of (or bother trying), and turn up bugs that humans missed.

Specifically, we propose adding these tests to CPython's CI suite, and gave a talk at the 2020 Language Summit to that effect. Doing so would mean:

  • New code can be developed with property-based tests - some already is, but adding it to CPython CI would catch bugs.
  • Tests for existing code can be augumented with property-based tests where this seems particularly valuable - e.g. tests/test_source_code.py in this repo has discovered several bugs.
  • Property-based testing can be adopted incrementally. Replacing existing tests is an explicit non-goal of this project.

PyPy already uses Hypothesis, and sharing as much of the test suite as possible between implementations would be great. How this would work depends largely on CPython's decisions, though.

LICENSE

By contributing to this repository, you agree to license the contributed code under user's choice of the Mozilla Public License Version 2.0, and the Apache License 2.0.

This dual-licence is intended to make it as easy as possible for the tests in this repository to be used upstream by the CPython project, other implementations of Python, and the Hypothesis project and ecosystem.

Workflow

To run the tests against the current version of Python:

  • pip install -r requirements.txt (or hypothesis hypothesmith)
  • python -m unittest

For development, we use tox to manage an extensive suite of auto-formatters and linters, so:

  • pip install tox
  • tox

will set up a virtualenv for you, install everything, and finally run the formatters, linters, and test suite.

Contributors

Trophy Case

Bugs found via this specific project:

Further reading

stdlib-property-tests's People

Contributors

akash-suresh avatar cfbolz avatar cheukting avatar pganssle avatar zac-hd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.