Skip to content

Commit 4816a6f

Browse files
Explicitly scope the fixtures
Contravenes PT003 but "Explicit is better than implicit." Co-authored-by: Paddy Roddy <[email protected]>
1 parent 1df49a4 commit 4816a6f

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

tests/conftest.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88

99

10-
@pytest.fixture
10+
@pytest.fixture(scope="function") # noqa: PT003
1111
def default_config() -> dict[str, str]:
1212
"""
1313
Get the minimal default configuration for cutting a cookie in tests.
@@ -22,19 +22,19 @@ def default_config() -> dict[str, str]:
2222
}
2323

2424

25-
@pytest.fixture
25+
@pytest.fixture(scope="function") # noqa: PT003
2626
def default_config_with(default_config: dict[str, str]) -> typing.Callable:
2727
"""Extend or modify the default configuration with one additional value."""
2828

29-
def _wrapped_with(**kwargs: str) -> dict[str, str]:
30-
return default_config | kwargs
29+
def _wrapped_with(key: str, value: str) -> dict[str, str]:
30+
default_config[key] = value
31+
return default_config
3132

3233
return _wrapped_with
3334

3435

3536
def _generate_package(
36-
config: dict[str, str],
37-
path: pathlib.Path,
37+
config: dict[str, str], path: pathlib.Path
3838
) -> tuple[subprocess.CompletedProcess[str], pathlib.Path]:
3939
"""
4040
Generate a project from the cookiecutter template.
@@ -66,8 +66,7 @@ def _generate_package(
6666

6767
@pytest.fixture
6868
def generate_package(
69-
default_config: dict[str, str],
70-
tmp_path: pathlib.Path,
69+
default_config: dict[str, str], tmp_path: pathlib.Path
7170
) -> typing.Callable:
7271
"""Generate project from cookiecutter template."""
7372

0 commit comments

Comments
 (0)