Skip to content

Commit 7f04ce3

Browse files
committed
Add blacken-docs and use autodoc
1 parent ad5468b commit 7f04ce3

File tree

4 files changed

+17
-35
lines changed

4 files changed

+17
-35
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repos:
88
rev: v1.12.0
99
hooks:
1010
- id: blacken-docs
11-
additional_dependencies: [black==22.1.0]
11+
additional_dependencies: [black==20.8b1]
1212
- repo: https://github.com/pre-commit/pre-commit-hooks
1313
rev: v4.1.0
1414
hooks:

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# ones.
3131
extensions = [
3232
"sphinx_rtd_theme",
33+
"sphinx.ext.autodoc",
3334
]
3435

3536
# Add any paths that contain templates here, relative to this directory.

docs/distribution.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The test distribution algorithm is configured with the ``--dist`` command-line o
4545
def test1():
4646
pass
4747
48+
4849
class TestA:
4950
@pytest.mark.xdist_group("group1")
5051
def test2():

docs/how-to.rst

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,11 @@ well, under the ``worker_id`` attribute.
3737

3838
Since version 2.0, the following functions are also available in the ``xdist`` module:
3939

40-
.. code-block:: python
41-
42-
def is_xdist_worker(request_or_session) -> bool:
43-
"""Return `True` if this is an xdist worker, `False` otherwise
44-
45-
:param request_or_session: the `pytest` `request` or `session` object
46-
"""
47-
48-
def is_xdist_controller(request_or_session) -> bool:
49-
"""Return `True` if this is the xdist controller, `False` otherwise
50-
51-
Note: this method also returns `False` when distribution has not been
52-
activated at all.
53-
54-
:param request_or_session: the `pytest` `request` or `session` object
55-
"""
56-
57-
def is_xdist_master(request_or_session) -> bool:
58-
"""Deprecated alias for is_xdist_controller."""
59-
60-
def get_xdist_worker_id(request_or_session) -> str:
61-
"""Return the id of the current worker ('gw0', 'gw1', etc) or 'master'
62-
if running on the controller node.
63-
64-
If not distributing tests (for example passing `-n0` or not passing `-n` at all)
65-
also return 'master'.
66-
67-
:param request_or_session: the `pytest` `request` or `session` object
68-
"""
6940

41+
.. autofunction:: xdist.is_xdist_worker
42+
.. autofunction:: xdist.is_xdist_controller
43+
.. autofunction:: xdist.is_xdist_master
44+
.. autofunction:: xdist.get_xdist_worker_id
7045

7146
Identifying workers from the system environment
7247
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -102,6 +77,7 @@ wanted to create a separate database for each test run:
10277
import pytest
10378
from posix_ipc import Semaphore, O_CREAT
10479
80+
10581
@pytest.fixture(scope="session", autouse=True)
10682
def create_unique_database(testrun_uid):
10783
""" create a unique database for this particular test run """
@@ -111,6 +87,7 @@ wanted to create a separate database for each test run:
11187
if not database_exists(database_url):
11288
create_database(database_url)
11389
90+
11491
@pytest.fixture()
11592
def db(testrun_uid):
11693
""" retrieve unique database """
@@ -252,17 +229,20 @@ Example:
252229
253230
# content of conftest.py
254231
def pytest_addoption(parser):
255-
parser.addini('worker_log_file', help='Similar to log_file, but %w will be replaced with a worker identifier.')
232+
parser.addini(
233+
"worker_log_file",
234+
help="Similar to log_file, but %w will be replaced with a worker identifier.",
235+
)
256236
257237
258238
def pytest_configure(config):
259-
worker_id = os.environ.get('PYTEST_XDIST_WORKER')
239+
worker_id = os.environ.get("PYTEST_XDIST_WORKER")
260240
if worker_id is not None:
261-
log_file = config.getini('worker_log_file')
241+
log_file = config.getini("worker_log_file")
262242
logging.basicConfig(
263-
format=config.getini('log_file_format'),
243+
format=config.getini("log_file_format"),
264244
filename=log_file.format(worker_id=worker_id),
265-
level=config.getini('log_file_level')
245+
level=config.getini("log_file_level"),
266246
)
267247
268248

0 commit comments

Comments
 (0)