Debian Codegraph @

hypothesis-python/docs/index.rst

raw
1 .. raw:: html
2
3 <!-- adapted from https://docs.django-cms.org/en/release-4.1.x/, with thanks -->
4
5 <style>
6 .row {
7 clear: both;
8 }
9
10 .column img {border: 1px solid gray;}
11
12 @media only screen and (min-width: 1000px) {
13
14 .column {
15 padding-left: 5px;
16 padding-right: 5px;
17 float: left;
18 }
19
20 .column2 {
21 width: calc(50% - 11px);
22 position: relative;
23 }
24 .column2:before {
25 padding-top: 61.8%;
26 content: "";
27 display: block;
28 float: left;
29 }
30 .top-left {
31 border-right: 1px solid var(--color-background-border);
32 border-bottom: 1px solid var(--color-background-border);
33 }
34 .top-right {
35 border-bottom: 1px solid var(--color-background-border);
36 }
37 .bottom-left {
38 border-right: 1px solid var(--color-background-border);
39 }
40 }
41 </style>
42
43 Welcome to Hypothesis!
44 ======================
45
46 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:
47
48 .. code-block:: python
49
50 from hypothesis import given, strategies as st
51
52 @given(st.lists(st.integers() | st.floats()))
53 def test_sort_correctness_using_properties(lst):
54 result = my_sort(lst)
55 assert set(lst) == set(result)
56 assert all(a <= b for a, b in zip(result, result[1:]))
57
58 You should start with the :doc:`tutorial <tutorial/index>`, or alternatively the more condensed :doc:`quickstart <quickstart>`.
59
60 .. rst-class:: row
61
62 .. rst-class:: column column2 top-left
63
64 :doc:`Tutorial <tutorial/index>`
65 ---------------------------------
66
67 An introduction to Hypothesis.
68
69 New users should start here, or with the more condensed :doc:`quickstart <quickstart>`.
70
71 .. rst-class:: column column2 top-right
72
73 :doc:`How-to guides <how-to/index>`
74 -----------------------------------
75
76 Practical guides for applying Hypothesis in specific scenarios.
77
78 .. rst-class:: column column2 bottom-left
79
80 :doc:`Explanations <explanation/index>`
81 ---------------------------------------
82
83 Commentary oriented towards deepening your understanding of Hypothesis.
84
85 .. rst-class:: column column2 bottom-right
86
87 :doc:`API Reference <reference/index>`
88 --------------------------------------
89
90 Technical API reference.
91
92 .. rst-class:: row
93
94 .. toctree::
95 :maxdepth: 1
96 :hidden:
97
98 quickstart
99 tutorial/index
100 how-to/index
101 explanation/index
102 reference/index
103 stateful
104 Extras <extras>
105 changelog
106
107 .. toctree::
108 :maxdepth: 1
109 :hidden:
110 :caption: About Hypothesis
111
112 development
113 compatibility
114 usage
115 extensions
116 packaging
117 community