Skip to content

Commit d8965da

Browse files
committed
Run regendoc on usage.rst
1 parent b143366 commit d8965da

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed

doc/en/how-to/usage.rst

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,51 @@ Executing pytest normally gives us this output (we are skipping the header to fo
204204
.. code-block:: pytest
205205
206206
$ pytest --no-header
207+
=========================== test session starts ===========================
208+
collected 4 items
209+
210+
test_verbosity_example.py .FFF [100%]
211+
212+
================================ FAILURES =================================
213+
_____________________________ test_words_fail _____________________________
214+
215+
def test_words_fail():
216+
fruits1 = ["banana", "apple", "grapes", "melon", "kiwi"]
217+
fruits2 = ["banana", "apple", "orange", "melon", "kiwi"]
218+
> assert fruits1 == fruits2
219+
E AssertionError: assert ['banana', 'a...elon', 'kiwi'] == ['banana', 'a...elon', 'kiwi']
220+
E At index 2 diff: 'grapes' != 'orange'
221+
E Use -v to get the full diff
222+
223+
test_verbosity_example.py:8: AssertionError
224+
____________________________ test_numbers_fail ____________________________
225+
226+
def test_numbers_fail():
227+
number_to_text1 = {str(x): x for x in range(5)}
228+
number_to_text2 = {str(x * 10): x * 10 for x in range(5)}
229+
> assert number_to_text1 == number_to_text2
230+
E AssertionError: assert {'0': 0, '1':..., '3': 3, ...} == {'0': 0, '10'...'30': 30, ...}
231+
E Omitting 1 identical items, use -vv to show
232+
E Left contains 4 more items:
233+
E {'1': 1, '2': 2, '3': 3, '4': 4}
234+
E Right contains 4 more items:
235+
E {'10': 10, '20': 20, '30': 30, '40': 40}
236+
E Use -v to get the full diff
237+
238+
test_verbosity_example.py:14: AssertionError
239+
___________________________ test_long_text_fail ___________________________
240+
241+
def test_long_text_fail():
242+
long_text = "Lorem ipsum dolor sit amet " * 10
243+
> assert "hello world" in long_text
244+
E AssertionError: assert 'hello world' in 'Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ips... sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet '
245+
246+
test_verbosity_example.py:19: AssertionError
247+
========================= short test summary info =========================
248+
FAILED test_verbosity_example.py::test_words_fail - AssertionError: asser...
249+
FAILED test_verbosity_example.py::test_numbers_fail - AssertionError: ass...
250+
FAILED test_verbosity_example.py::test_long_text_fail - AssertionError: a...
251+
======================= 3 failed, 1 passed in 0.08s =======================
207252
208253
Notice that:
209254

@@ -218,6 +263,61 @@ Now we can increase pytest's verbosity:
218263
.. code-block:: pytest
219264
220265
$ pytest --no-header -v
266+
=========================== test session starts ===========================
267+
collecting ... collected 4 items
268+
269+
test_verbosity_example.py::test_ok PASSED [ 25%]
270+
test_verbosity_example.py::test_words_fail FAILED [ 50%]
271+
test_verbosity_example.py::test_numbers_fail FAILED [ 75%]
272+
test_verbosity_example.py::test_long_text_fail FAILED [100%]
273+
274+
================================ FAILURES =================================
275+
_____________________________ test_words_fail _____________________________
276+
277+
def test_words_fail():
278+
fruits1 = ["banana", "apple", "grapes", "melon", "kiwi"]
279+
fruits2 = ["banana", "apple", "orange", "melon", "kiwi"]
280+
> assert fruits1 == fruits2
281+
E AssertionError: assert ['banana', 'a...elon', 'kiwi'] == ['banana', 'a...elon', 'kiwi']
282+
E At index 2 diff: 'grapes' != 'orange'
283+
E Full diff:
284+
E - ['banana', 'apple', 'orange', 'melon', 'kiwi']
285+
E ? ^ ^^
286+
E + ['banana', 'apple', 'grapes', 'melon', 'kiwi']
287+
E ? ^ ^ +
288+
289+
test_verbosity_example.py:8: AssertionError
290+
____________________________ test_numbers_fail ____________________________
291+
292+
def test_numbers_fail():
293+
number_to_text1 = {str(x): x for x in range(5)}
294+
number_to_text2 = {str(x * 10): x * 10 for x in range(5)}
295+
> assert number_to_text1 == number_to_text2
296+
E AssertionError: assert {'0': 0, '1':..., '3': 3, ...} == {'0': 0, '10'...'30': 30, ...}
297+
E Omitting 1 identical items, use -vv to show
298+
E Left contains 4 more items:
299+
E {'1': 1, '2': 2, '3': 3, '4': 4}
300+
E Right contains 4 more items:
301+
E {'10': 10, '20': 20, '30': 30, '40': 40}
302+
E Full diff:
303+
E - {'0': 0, '10': 10, '20': 20, '30': 30, '40': 40}...
304+
E
305+
E ...Full output truncated (3 lines hidden), use '-vv' to show
306+
307+
test_verbosity_example.py:14: AssertionError
308+
___________________________ test_long_text_fail ___________________________
309+
310+
def test_long_text_fail():
311+
long_text = "Lorem ipsum dolor sit amet " * 10
312+
> assert "hello world" in long_text
313+
E AssertionError: assert 'hello world' in 'Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet '
314+
315+
test_verbosity_example.py:19: AssertionError
316+
========================= short test summary info =========================
317+
FAILED test_verbosity_example.py::test_words_fail - AssertionError: asser...
318+
FAILED test_verbosity_example.py::test_numbers_fail - AssertionError: ass...
319+
FAILED test_verbosity_example.py::test_long_text_fail - AssertionError: a...
320+
======================= 3 failed, 1 passed in 0.07s =======================
221321
222322
Notice now that:
223323

@@ -232,6 +332,62 @@ Now if increase verbosity even more:
232332
.. code-block:: pytest
233333
234334
$ pytest --no-header -vv
335+
=========================== test session starts ===========================
336+
collecting ... collected 4 items
337+
338+
test_verbosity_example.py::test_ok PASSED [ 25%]
339+
test_verbosity_example.py::test_words_fail FAILED [ 50%]
340+
test_verbosity_example.py::test_numbers_fail FAILED [ 75%]
341+
test_verbosity_example.py::test_long_text_fail FAILED [100%]
342+
343+
================================ FAILURES =================================
344+
_____________________________ test_words_fail _____________________________
345+
346+
def test_words_fail():
347+
fruits1 = ["banana", "apple", "grapes", "melon", "kiwi"]
348+
fruits2 = ["banana", "apple", "orange", "melon", "kiwi"]
349+
> assert fruits1 == fruits2
350+
E AssertionError: assert ['banana', 'apple', 'grapes', 'melon', 'kiwi'] == ['banana', 'apple', 'orange', 'melon', 'kiwi']
351+
E At index 2 diff: 'grapes' != 'orange'
352+
E Full diff:
353+
E - ['banana', 'apple', 'orange', 'melon', 'kiwi']
354+
E ? ^ ^^
355+
E + ['banana', 'apple', 'grapes', 'melon', 'kiwi']
356+
E ? ^ ^ +
357+
358+
test_verbosity_example.py:8: AssertionError
359+
____________________________ test_numbers_fail ____________________________
360+
361+
def test_numbers_fail():
362+
number_to_text1 = {str(x): x for x in range(5)}
363+
number_to_text2 = {str(x * 10): x * 10 for x in range(5)}
364+
> assert number_to_text1 == number_to_text2
365+
E AssertionError: assert {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4} == {'0': 0, '10': 10, '20': 20, '30': 30, '40': 40}
366+
E Common items:
367+
E {'0': 0}
368+
E Left contains 4 more items:
369+
E {'1': 1, '2': 2, '3': 3, '4': 4}
370+
E Right contains 4 more items:
371+
E {'10': 10, '20': 20, '30': 30, '40': 40}
372+
E Full diff:
373+
E - {'0': 0, '10': 10, '20': 20, '30': 30, '40': 40}
374+
E ? - - - - - - - -
375+
E + {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4}
376+
377+
test_verbosity_example.py:14: AssertionError
378+
___________________________ test_long_text_fail ___________________________
379+
380+
def test_long_text_fail():
381+
long_text = "Lorem ipsum dolor sit amet " * 10
382+
> assert "hello world" in long_text
383+
E AssertionError: assert 'hello world' in 'Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet '
384+
385+
test_verbosity_example.py:19: AssertionError
386+
========================= short test summary info =========================
387+
FAILED test_verbosity_example.py::test_words_fail - AssertionError: asser...
388+
FAILED test_verbosity_example.py::test_numbers_fail - AssertionError: ass...
389+
FAILED test_verbosity_example.py::test_long_text_fail - AssertionError: a...
390+
======================= 3 failed, 1 passed in 0.07s =======================
235391
236392
Notice now that:
237393

0 commit comments

Comments
 (0)