@@ -1136,8 +1136,8 @@ and teared down after every test that used it.
11361136
11371137.. _`usefixtures` :
11381138
1139- Using fixtures from classes, modules or projects
1140- ----------------------------------------------------------------------
1139+ Use fixtures in classes and modules with `` usefixtures ``
1140+ --------------------------------------------------------
11411141
11421142.. regendoc:wipe
11431143
@@ -1531,3 +1531,37 @@ Given the tests file structure is:
15311531In the example above, a parametrized fixture is overridden with a non-parametrized version, and
15321532a non-parametrized fixture is overridden with a parametrized version for certain test module.
15331533The same applies for the test folder level obviously.
1534+
1535+
1536+ Using fixtures from other projects
1537+ ----------------------------------
1538+
1539+ Usually projects that provide pytest support will use :ref: `entry points <setuptools entry points >`,
1540+ so just installing those projects into an environment will make those fixtures available for use.
1541+
1542+ In case you want to use fixtures from a project that does not use entry points, you can
1543+ define :globalvar: `pytest_plugins ` in your top ``conftest.py `` file to register that module
1544+ as a plugin.
1545+
1546+ Suppose you have some fixtures in ``mylibrary.fixtures `` and you want to reuse them into your
1547+ ``app/tests `` directory.
1548+
1549+ All you need to do is to define :globalvar: `pytest_plugins ` in ``app/tests/conftest.py ``
1550+ pointing to that module.
1551+
1552+ .. code-block :: python
1553+
1554+ pytest_plugins = " mylibrary.fixtures"
1555+
1556+ This effectively registers ``mylibrary.fixtures `` as a plugin, making all its fixtures and
1557+ hooks available to tests in ``app/tests ``.
1558+
1559+ .. note ::
1560+
1561+ Sometimes users will *import * fixtures from other projects for use, however this is not
1562+ recommended: importing fixtures into a module will register them in pytest
1563+ as *defined * in that module.
1564+
1565+ This has minor consequences, such as appearing multiple times in ``pytest --help ``,
1566+ but it is not **recommended ** because this behavior might change/stop working
1567+ in future versions.
0 commit comments