Skip to content

Commit 59c1258

Browse files
committed
Move historical notes to their own doc
Fix #2512
1 parent d46006f commit 59c1258

File tree

12 files changed

+204
-168
lines changed

12 files changed

+204
-168
lines changed

doc/en/cache.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ Cache: working with cross-testrun state
55

66
.. versionadded:: 2.8
77

8-
.. warning::
9-
10-
The functionality of this core plugin was previously distributed
11-
as a third party plugin named ``pytest-cache``. The core plugin
12-
is compatible regarding command line options and API usage except that you
13-
can only store/receive data between test runs that is json-serializable.
14-
15-
168
Usage
179
---------
1810

doc/en/contents.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Full pytest documentation
3838
bash-completion
3939

4040
backwards-compatibility
41+
historical-notes
4142
license
4243
contributing
4344
talks

doc/en/example/markers.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,14 @@ Or to select "http" and "quick" tests::
173173

174174
.. note::
175175

176-
If you are using expressions such as "X and Y" then both X and Y
177-
need to be simple non-keyword names. For example, "pass" or "from"
178-
will result in SyntaxErrors because "-k" evaluates the expression.
179-
180-
However, if the "-k" argument is a simple string, no such restrictions
181-
apply. Also "-k 'not STRING'" has no restrictions. You can also
182-
specify numbers like "-k 1.3" to match tests which are parametrized
183-
with the float "1.3".
176+
If you are using expressions such as ``"X and Y"`` then both ``X`` and ``Y``
177+
need to be simple non-keyword names. For example, ``"pass"`` or ``"from"``
178+
will result in SyntaxErrors because ``"-k"`` evaluates the expression using Python's ``eval`` function.
179+
180+
However, if the ``"-k"`` argument is a simple string, no such restrictions
181+
apply. Also ``"-k 'not STRING'"`` has no restrictions. You can also
182+
specify numbers like ``"-k 1.3"`` to match tests which are parametrized
183+
with the float ``"1.3"``.
184184

185185
Registering markers
186186
-------------------------------------

doc/en/fixture.rst

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,14 @@ Note that if you misspell a function argument or want
109109
to use one that isn't available, you'll see an error
110110
with a list of available function arguments.
111111

112-
.. Note::
112+
.. note::
113113

114114
You can always issue::
115115

116116
pytest --fixtures test_simplefactory.py
117117

118118
to see available fixtures.
119119

120-
In versions prior to 2.3 there was no ``@pytest.fixture`` marker
121-
and you had to use a magic ``pytest_funcarg__NAME`` prefix
122-
for the fixture factory. This remains and will remain supported
123-
but is not anymore advertised as the primary means of declaring fixture
124-
functions.
125-
126120
Fixtures: a prime example of dependency injection
127121
---------------------------------------------------
128122

@@ -292,14 +286,6 @@ the ``with`` statement ends.
292286
Note that if an exception happens during the *setup* code (before the ``yield`` keyword), the
293287
*teardown* code (after the ``yield``) will not be called.
294288

295-
296-
.. note::
297-
Prior to version 2.10, in order to use a ``yield`` statement to execute teardown code one
298-
had to mark a fixture using the ``yield_fixture`` marker. From 2.10 onward, normal
299-
fixtures can use ``yield`` directly so the ``yield_fixture`` decorator is no longer needed
300-
and considered deprecated.
301-
302-
303289
An alternative option for executing *teardown* code is to
304290
make use of the ``addfinalizer`` method of the `request-context`_ object to register
305291
finalization functions.

doc/en/goodpractices.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,6 @@ by putting them into a ``[tool:pytest]`` section:
249249
python_files = testing/*/*.py
250250
251251
252-
.. note::
253-
Prior to 3.0, the supported section name was ``[pytest]``. Due to how
254-
this may collide with some distutils commands, the recommended
255-
section name for ``setup.cfg`` files is now ``[tool:pytest]``.
256-
257-
Note that for ``pytest.ini`` and ``tox.ini`` files the section
258-
name is ``[pytest]``.
259-
260-
261252
Manual Integration
262253
^^^^^^^^^^^^^^^^^^
263254

doc/en/historical-notes.rst

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
Historical Notes
2+
================
3+
4+
This page lists features or behavior from previous versions of pytest which have changed over the years. They are
5+
kept here as a historical note so users looking at old code can find documentation related to them.
6+
7+
cache plugin integrated into the core
8+
-------------------------------------
9+
10+
.. versionadded:: 2.8
11+
12+
The functionality of the :ref:`core cache <cache>` plugin was previously distributed
13+
as a third party plugin named ``pytest-cache``. The core plugin
14+
is compatible regarding command line options and API usage except that you
15+
can only store/receive data between test runs that is json-serializable.
16+
17+
18+
funcargs and ``pytest_funcarg__``
19+
---------------------------------
20+
21+
.. versionchanged:: 2.3
22+
23+
In versions prior to 2.3 there was no ``@pytest.fixture`` marker
24+
and you had to use a magic ``pytest_funcarg__NAME`` prefix
25+
for the fixture factory. This remains and will remain supported
26+
but is not anymore advertised as the primary means of declaring fixture
27+
functions.
28+
29+
30+
``@pytest.yield_fixture`` decorator
31+
-----------------------------------
32+
33+
.. versionchanged:: 2.10
34+
35+
Prior to version 2.10, in order to use a ``yield`` statement to execute teardown code one
36+
had to mark a fixture using the ``yield_fixture`` marker. From 2.10 onward, normal
37+
fixtures can use ``yield`` directly so the ``yield_fixture`` decorator is no longer needed
38+
and considered deprecated.
39+
40+
41+
``[pytest]`` header in ``setup.cfg``
42+
------------------------------------
43+
44+
.. versionchanged:: 3.0
45+
46+
Prior to 3.0, the supported section name was ``[pytest]``. Due to how
47+
this may collide with some distutils commands, the recommended
48+
section name for ``setup.cfg`` files is now ``[tool:pytest]``.
49+
50+
Note that for ``pytest.ini`` and ``tox.ini`` files the section
51+
name is ``[pytest]``.
52+
53+
54+
Applying marks to ``@pytest.mark.parametrize`` parameters
55+
---------------------------------------------------------
56+
57+
.. versionchanged:: 3.1
58+
59+
Prior to version 3.1 the supported mechanism for marking values
60+
used the syntax::
61+
62+
import pytest
63+
@pytest.mark.parametrize("test_input,expected", [
64+
("3+5", 8),
65+
("2+4", 6),
66+
pytest.mark.xfail(("6*9", 42),),
67+
])
68+
def test_eval(test_input, expected):
69+
assert eval(test_input) == expected
70+
71+
72+
This was an initial hack to support the feature but soon was demonstrated to be incomplete,
73+
broken for passing functions or applying multiple marks with the same name but different parameters.
74+
75+
The old syntax is planned to be removed in pytest-4.0.
76+
77+
78+
``@pytest.mark.parametrize`` argument names as a tuple
79+
------------------------------------------------------
80+
81+
.. versionchanged:: 2.4
82+
83+
In versions prior to 2.4 one needed to specify the argument
84+
names as a tuple. This remains valid but the simpler ``"name1,name2,..."``
85+
comma-separated-string syntax is now advertised first because
86+
it's easier to write and produces less line noise.
87+
88+
89+
setup: is now an "autouse fixture"
90+
----------------------------------
91+
92+
.. versionchanged:: 2.3
93+
94+
During development prior to the pytest-2.3 release the name
95+
``pytest.setup`` was used but before the release it was renamed
96+
and moved to become part of the general fixture mechanism,
97+
namely :ref:`autouse fixtures`
98+
99+
100+
.. _string conditions:
101+
102+
Conditions as strings instead of booleans
103+
-----------------------------------------
104+
105+
.. versionchanged:: 2.4
106+
107+
Prior to pytest-2.4 the only way to specify skipif/xfail conditions was
108+
to use strings::
109+
110+
import sys
111+
@pytest.mark.skipif("sys.version_info >= (3,3)")
112+
def test_function():
113+
...
114+
115+
During test function setup the skipif condition is evaluated by calling
116+
``eval('sys.version_info >= (3,0)', namespace)``. The namespace contains
117+
all the module globals, and ``os`` and ``sys`` as a minimum.
118+
119+
Since pytest-2.4 :ref:`boolean conditions <condition booleans>` are considered preferable
120+
because markers can then be freely imported between test modules.
121+
With strings you need to import not only the marker but all variables
122+
used by the marker, which violates encapsulation.
123+
124+
The reason for specifying the condition as a string was that ``pytest`` can
125+
report a summary of skip conditions based purely on the condition string.
126+
With conditions as booleans you are required to specify a ``reason`` string.
127+
128+
Note that string conditions will remain fully supported and you are free
129+
to use them if you have no need for cross-importing markers.
130+
131+
The evaluation of a condition string in ``pytest.mark.skipif(conditionstring)``
132+
or ``pytest.mark.xfail(conditionstring)`` takes place in a namespace
133+
dictionary which is constructed as follows:
134+
135+
* the namespace is initialized by putting the ``sys`` and ``os`` modules
136+
and the pytest ``config`` object into it.
137+
138+
* updated with the module globals of the test function for which the
139+
expression is applied.
140+
141+
The pytest ``config`` object allows you to skip based on a test
142+
configuration value which you might have added::
143+
144+
@pytest.mark.skipif("not config.getvalue('db')")
145+
def test_function(...):
146+
...
147+
148+
The equivalent with "boolean conditions" is::
149+
150+
@pytest.mark.skipif(not pytest.config.getvalue("db"),
151+
reason="--db was not specified")
152+
def test_function(...):
153+
pass
154+
155+
.. note::
156+
157+
You cannot use ``pytest.config.getvalue()`` in code
158+
imported before pytest's argument parsing takes place. For example,
159+
``conftest.py`` files are imported before command line parsing and thus
160+
``config.getvalue()`` will not execute correctly.
161+
162+
``pytest.set_trace()``
163+
----------------------
164+
165+
.. versionchanged:: 2.4
166+
167+
Previous to version 2.4 to set a break point in code one needed to use ``pytest.set_trace()``::
168+
169+
import pytest
170+
def test_function():
171+
...
172+
pytest.set_trace() # invoke PDB debugger and tracing
173+
174+
175+
This is no longer needed and one can use the native ``import pdb;pdb.set_trace()`` call directly.
176+
177+
For more details see :ref:`breakpoints`.

doc/en/parametrize.rst

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -99,26 +99,6 @@ for example with the builtin ``mark.xfail``::
9999
def test_eval(test_input, expected):
100100
assert eval(test_input) == expected
101101

102-
.. note::
103-
104-
prior to version 3.1 the supported mechanism for marking values
105-
used the syntax::
106-
107-
import pytest
108-
@pytest.mark.parametrize("test_input,expected", [
109-
("3+5", 8),
110-
("2+4", 6),
111-
pytest.mark.xfail(("6*9", 42),),
112-
])
113-
def test_eval(test_input, expected):
114-
assert eval(test_input) == expected
115-
116-
117-
This was an initial hack to support the feature but soon was demonstrated to be incomplete,
118-
broken for passing functions or applying multiple marks with the same name but different parameters.
119-
The old syntax will be removed in pytest-4.0.
120-
121-
122102
Let's run this::
123103

124104
$ pytest
@@ -143,15 +123,8 @@ To get all combinations of multiple parametrized arguments you can stack
143123
def test_foo(x, y):
144124
pass
145125

146-
This will run the test with the arguments set to x=0/y=2, x=0/y=3, x=1/y=2 and
147-
x=1/y=3.
148-
149-
.. note::
150-
151-
In versions prior to 2.4 one needed to specify the argument
152-
names as a tuple. This remains valid but the simpler ``"name1,name2,..."``
153-
comma-separated-string syntax is now advertised first because
154-
it's easier to write and produces less line noise.
126+
This will run the test with the arguments set to ``x=0/y=2``, ``x=0/y=3``, ``x=1/y=2`` and
127+
``x=1/y=3``.
155128

156129
.. _`pytest_generate_tests`:
157130

doc/en/setup.rst

Lines changed: 0 additions & 10 deletions
This file was deleted.

doc/en/skipping.rst

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -347,64 +347,3 @@ test instances when using parametrize:
347347
assert n + 1 == expected
348348
349349
350-
.. _string conditions:
351-
352-
Conditions as strings instead of booleans
353-
-----------------------------------------
354-
355-
Prior to pytest-2.4 the only way to specify skipif/xfail conditions was
356-
to use strings::
357-
358-
import sys
359-
@pytest.mark.skipif("sys.version_info >= (3,3)")
360-
def test_function():
361-
...
362-
363-
During test function setup the skipif condition is evaluated by calling
364-
``eval('sys.version_info >= (3,0)', namespace)``. The namespace contains
365-
all the module globals, and ``os`` and ``sys`` as a minimum.
366-
367-
Since pytest-2.4 `condition booleans`_ are considered preferable
368-
because markers can then be freely imported between test modules.
369-
With strings you need to import not only the marker but all variables
370-
used by the marker, which violates encapsulation.
371-
372-
The reason for specifying the condition as a string was that ``pytest`` can
373-
report a summary of skip conditions based purely on the condition string.
374-
With conditions as booleans you are required to specify a ``reason`` string.
375-
376-
Note that string conditions will remain fully supported and you are free
377-
to use them if you have no need for cross-importing markers.
378-
379-
The evaluation of a condition string in ``pytest.mark.skipif(conditionstring)``
380-
or ``pytest.mark.xfail(conditionstring)`` takes place in a namespace
381-
dictionary which is constructed as follows:
382-
383-
* the namespace is initialized by putting the ``sys`` and ``os`` modules
384-
and the pytest ``config`` object into it.
385-
386-
* updated with the module globals of the test function for which the
387-
expression is applied.
388-
389-
The pytest ``config`` object allows you to skip based on a test
390-
configuration value which you might have added::
391-
392-
@pytest.mark.skipif("not config.getvalue('db')")
393-
def test_function(...):
394-
...
395-
396-
The equivalent with "boolean conditions" is::
397-
398-
@pytest.mark.skipif(not pytest.config.getvalue("db"),
399-
reason="--db was not specified")
400-
def test_function(...):
401-
pass
402-
403-
.. note::
404-
405-
You cannot use ``pytest.config.getvalue()`` in code
406-
imported before pytest's argument parsing takes place. For example,
407-
``conftest.py`` files are imported before command line parsing and thus
408-
``config.getvalue()`` will not execute correctly.
409-
410-

0 commit comments

Comments
 (0)