Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce7530b

Browse files
committed
New testing tool: Hypothesis
Based on README athttps://github.com/HypothesisWorks/hypothesis-python
1 parent39b0911 commitce7530b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

‎docs/writing/tests.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,40 @@ the unittest module!
190190
`py.test<https://docs.pytest.org/en/latest/>`_
191191

192192

193+
Hypothesis
194+
----------
195+
196+
Hypothesis is a library which lets you write tests that are parametrized by
197+
a source of examples. It then generates simple and comprehensible examples
198+
that make your tests fail, letting you find more bugs with less work.
199+
200+
..code-block::console
201+
202+
$ pip install hypothesis
203+
204+
For example, testing lists of floats will try many examples, but report the
205+
minimal example of each bug (distinguished exception type and location):
206+
207+
..code-block::python
208+
209+
@given(lists(floats(allow_nan=False,allow_infinity=False),min_size=1))
210+
deftest_mean(xs):
211+
mean=sum(xs)/len(xs)
212+
assertmin(xs)<= mean(xs)<=max(xs)
213+
214+
..code-block::
215+
216+
Falsifying example: test_mean(
217+
xs=[1.7976321109618856e+308, 6.102390043022755e+303]
218+
)
219+
220+
Hypothesis is practical as well as very powerful, and will often find bugs
221+
that escaped all other forms of testing. It integrates well with py.test,
222+
and has a strong focus on usability in both simple and advanced scenarios.
223+
224+
`hypothesis<https://hypothesis.readthedocs.io/en/latest/>`_
225+
226+
193227
tox
194228
---
195229

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp