Skip to content

Commit a624ebd

Browse files
committed
docs(tests): add detailed docstrings to _worker_schema_name and _build_worker_url unit tests
1 parent 6beedbd commit a624ebd

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

tests/test_conftest_helpers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
"""Unit tests for private helpers in tests/conftest.py."""
22

3-
import pytest
4-
53
from tests.conftest import _build_worker_url, _worker_schema_name
64

75

86
class TestWorkerSchemaName:
97
def test_valid_gw0(self):
8+
"""Return a schema name for the first xdist worker."""
109
assert _worker_schema_name("gw0") == "test_worker_0"
1110

1211
def test_valid_gw99(self):
12+
"""Return a schema name for multi-digit xdist workers."""
1313
assert _worker_schema_name("gw99") == "test_worker_99"
1414

1515
def test_master_returns_none(self):
16+
"""Return ``None`` when pytest is not running under xdist."""
1617
assert _worker_schema_name("master") is None
1718

1819
def test_non_gw_id_returns_none(self):
20+
"""Ignore worker IDs that do not match the xdist pattern."""
1921
assert _worker_schema_name("worker1") is None
2022

2123
def test_partial_match_returns_none(self):
24+
"""Require a full worker ID match before creating a schema name."""
2225
# "gw0extra" should not match the fullmatch pattern
2326
assert _worker_schema_name("gw0extra") is None
2427

2528

2629
class TestBuildWorkerUrl:
2730
def test_url_without_options(self):
31+
"""Add a search path option when the URL has no existing options."""
2832
url = "postgresql://user:pass@localhost/testdb"
2933
result = _build_worker_url(url, "test_worker_0")
3034
assert "options" in result
3135
assert "search_path%3Dtest_worker_0" in result or "search_path=test_worker_0" in result
3236

3337
def test_url_with_existing_options_appends(self):
38+
"""Append the worker search path to existing connection options."""
3439
url = "postgresql://user:pass@localhost/testdb?options=-cstatement_timeout%3D5000"
3540
result = _build_worker_url(url, "test_worker_1")
3641
# The new search_path must be present

0 commit comments

Comments
 (0)