summaryrefslogtreecommitdiffstats
path: root/tests/roots/test-ext-doctest-skipif/skipif.txt
blob: c5bd3982180c56d7b86812761ba41e88b6a16649 (plain)
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
Testing the doctest extension's `:skipif:` option
=================================================

testsetup
---------

.. testsetup:: group-skipif
   :skipif: record('testsetup', ':skipif:', True) != 'this will be True'

   record('testsetup', 'body', True)

.. testsetup:: group-skipif
   :skipif: record('testsetup', ':skipif:', False) == 'this will be False'

   record('testsetup', 'body', False)


doctest
-------
.. doctest:: group-skipif
   :skipif: record('doctest', ':skipif:', True) != 'this will be True'

   >>> print(record('doctest', 'body', True))
   The test is skipped, and this expected text is ignored


.. doctest::
   :skipif: record('doctest', ':skipif:', False) == 'this will be False'

   >>> print(record('doctest', 'body', False))
   Recorded doctest body False


testcode and testoutput
-----------------------

testcode skipped
~~~~~~~~~~~~~~~~

.. testcode:: group-skipif
   :skipif: record('testcode', ':skipif:', True) != 'this will be True'

   print(record('testcode', 'body', True))

.. testoutput:: group-skipif
   :skipif: record('testoutput-1', ':skipif:', True) != 'this will be True'

   The previous testcode is skipped, and the :skipif: condition is True,
   so this testoutput is ignored

testcode executed
~~~~~~~~~~~~~~~~~

.. testcode:: group-skipif
   :skipif: record('testcode', ':skipif:', False) == 'this will be False'

   print(record('testcode', 'body', False))

.. testoutput:: group-skipif
   :skipif: record('testoutput-2', ':skipif:', False) == 'this will be False'

   Recorded testcode body False

.. testoutput:: group-skipif
   :skipif: record('testoutput-2', ':skipif:', True) != 'this will be True'

   The :skipif: condition is False, so this testoutput is ignored


testcleanup
-----------

.. testcleanup:: group-skipif
   :skipif: record('testcleanup', ':skipif:', True) != 'this will be True'

   record('testcleanup', 'body', True)

.. testcleanup:: group-skipif
   :skipif: record('testcleanup', ':skipif:', False) == 'this will be False'

   record('testcleanup', 'body', False)