File: index.rst

package info (click to toggle)
python-hypothesis 6.138.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,272 kB
  • sloc: python: 62,853; ruby: 1,107; sh: 253; makefile: 41; javascript: 6
file content (118 lines) | stat: -rw-r--r-- 2,949 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
.. raw:: html

     <!-- adapted from https://docs.django-cms.org/en/release-4.1.x/, with thanks -->

    <style>
        .row {
           clear: both;
        }

        .column img {border: 1px solid gray;}

        @media only screen and (min-width: 1000px) {

            .column {
                padding-left: 5px;
                padding-right: 5px;
                float: left;
            }

            .column2  {
                width: calc(50% - 11px);
                position: relative;
            }
            .column2:before {
                padding-top: 61.8%;
                content: "";
                display: block;
                float: left;
            }
            .top-left {
                border-right: 1px solid var(--color-background-border);
                border-bottom: 1px solid var(--color-background-border);
            }
            .top-right {
                border-bottom: 1px solid var(--color-background-border);
            }
            .bottom-left {
                border-right: 1px solid var(--color-background-border);
            }
        }
    </style>

Welcome to Hypothesis!
======================

Hypothesis is the property-based testing library for Python. With Hypothesis, you write tests which should pass for all inputs in whatever range you describe, and let Hypothesis randomly choose which of those inputs to check - including edge cases you might not have thought about. For example:

.. code-block:: python

    from hypothesis import given, strategies as st

    @given(st.lists(st.integers() | st.floats()))
    def test_sort_correct(lst):
        # lst is a random list of numbers
        assert my_sort(lst) == sorted(lst)

    test_sort_correct()

You should start with the :doc:`tutorial <tutorial/index>`, or the more condensed :doc:`quickstart <quickstart>`.

.. rst-class:: row

.. rst-class:: column column2 top-left

:doc:`Tutorial <tutorial/index>`
---------------------------------

An introduction to Hypothesis.

New users should start here, or with the more condensed :doc:`quickstart <quickstart>`.

.. rst-class:: column column2 top-right

:doc:`How-to guides <how-to/index>`
-----------------------------------

Practical guides for applying Hypothesis in specific scenarios.

.. rst-class:: column column2 bottom-left

:doc:`Explanations <explanation/index>`
---------------------------------------

Commentary oriented towards deepening your understanding of Hypothesis.

.. rst-class:: column column2 bottom-right

:doc:`API Reference <reference/index>`
--------------------------------------

Technical API reference.

.. rst-class:: row

.. toctree::
  :maxdepth: 1
  :hidden:

  quickstart
  tutorial/index
  how-to/index
  explanation/index
  reference/index
  stateful
  Extras <extras>
  changelog

.. toctree::
  :maxdepth: 1
  :hidden:
  :caption: About Hypothesis

  development
  compatibility
  usage
  extensions
  packaging
  community