|
| 1 | +.. _upgrade: |
| 2 | + |
| 3 | +Upgrade guides |
| 4 | +============== |
| 5 | + |
| 6 | +The following document describes how to upgrade to a given version of the |
| 7 | +library which introduces breaking changes. |
| 8 | + |
| 9 | +Introducing breaking changes |
| 10 | +---------------------------- |
| 11 | +When a breaking change is about to be made in the library, an intermediate |
| 12 | +release is released which generates deprecation warnings when the functionality |
| 13 | +to be removed is used. This does not break any functionality but shows a |
| 14 | +warning instead. |
| 15 | + |
| 16 | +Together with this intermediate release, a new *pre-release* is released to |
| 17 | +*pypi*. This release removes the functionality described by the warning, but |
| 18 | +*pip* does not install this version unless you specify the *--pre* parameter to |
| 19 | +*pip install*. |
| 20 | + |
| 21 | +Once you made the required changes to make your code compatible with the new |
| 22 | +version, you can install the new version by *pip install --pre |
| 23 | +pytest-httpserver*. |
| 24 | + |
| 25 | +After a given time period, a new non-pre release is released, this will be |
| 26 | +installed by pip similar to other releases and it will break your code if you |
| 27 | +have not made the required changes. If this happens, you can still pin the |
| 28 | +version in requirements.txt or other places. Usually specifying the version with |
| 29 | +`==` operator fixes the version, but for more details please read the |
| 30 | +documentation of the tool you are using in manage dependencies. |
| 31 | + |
| 32 | + |
| 33 | +1.0.0 |
| 34 | +----- |
| 35 | + |
| 36 | +In pytest-httpserver 1.0.0 the following breaking changes were made. |
| 37 | + |
| 38 | +* The scope of ``httpserver_listen_address`` fixture changed from **function** to **session** |
| 39 | + |
| 40 | +In order to make your code compatible with the new version of pytest-httpserver, |
| 41 | +you need to specify the `session` scope explicitly. |
| 42 | + |
| 43 | +Example |
| 44 | +~~~~~~~ |
| 45 | + |
| 46 | +Old code: |
| 47 | + |
| 48 | +.. code-block:: python |
| 49 | +
|
| 50 | + import pytest |
| 51 | +
|
| 52 | + @pytest.fixture |
| 53 | + def httpserver_listen_address(): |
| 54 | + return ("127.0.0.1", 8888) |
| 55 | +
|
| 56 | +New code: |
| 57 | + |
| 58 | +.. code-block:: python |
| 59 | +
|
| 60 | + import pytest |
| 61 | +
|
| 62 | + @pytest.fixture(scope="session") |
| 63 | + def httpserver_listen_address(): |
| 64 | + return ("127.0.0.1", 8888) |
| 65 | +
|
| 66 | +
|
| 67 | +As this fixture is now defined with session scope, it will be called only once, |
| 68 | +when it is first referenced by a test or by another fixture. |
| 69 | + |
| 70 | +.. note:: |
| 71 | + |
| 72 | + There were other, non-breaking changes introduced to 1.0.0. For details, |
| 73 | + please read the :ref:`changes`. |
0 commit comments