Skip to content

Commit 7891327

Browse files
committed
refactor(tests): split the golden v2 dummy executor into a narrower inline stub and update baseline
1 parent ac322ba commit 7891327

2 files changed

Lines changed: 20 additions & 27 deletions

File tree

codeclone.baseline.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"meta": {
33
"generator": {
44
"name": "codeclone",
5-
"version": "2.0.0b3"
5+
"version": "2.0.0b4"
66
},
77
"schema_version": "2.0",
88
"fingerprint_version": "1",
99
"python_tag": "cp313",
10-
"created_at": "2026-03-29T16:19:22Z",
10+
"created_at": "2026-04-04T18:57:08Z",
1111
"payload_sha256": "691c6cedd10e2a51d6038780f3ae9dffe763356dd2aba742b3980f131b79f217",
12-
"metrics_payload_sha256": "878d5169c9ffd6d73eb0ce3ce55166df3d080b85ed835091f33ff53d2779b9ac"
12+
"metrics_payload_sha256": "07e216e9a158e4dc56ad2ee6ca8069896cd17d39bdb0b8a3745ebd98627d0d25"
1313
},
1414
"clones": {
1515
"functions": [
@@ -30,14 +30,12 @@
3030
"high_risk_functions": [],
3131
"max_coupling": 10,
3232
"high_coupling_classes": [],
33-
"max_cohesion": 4,
34-
"low_cohesion_classes": [
35-
"tests.test_golden_v2:_DummyExecutor"
36-
],
33+
"max_cohesion": 3,
34+
"low_cohesion_classes": [],
3735
"dependency_cycles": [],
38-
"dependency_max_depth": 11,
36+
"dependency_max_depth": 10,
3937
"dead_code_items": [],
40-
"health_score": 85,
38+
"health_score": 87,
4139
"health_grade": "B"
4240
}
4341
}

tests/test_golden_v2.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
import json
1010
import shutil
1111
import sys
12+
from collections.abc import Callable
13+
from contextlib import nullcontext
1214
from dataclasses import asdict, dataclass
1315
from pathlib import Path
14-
from typing import Literal
1516

1617
import pytest
1718

@@ -38,33 +39,27 @@ def result(self) -> object:
3839
return self.value
3940

4041

41-
class _DummyExecutor:
42-
def __init__(self, max_workers: int | None = None) -> None:
43-
self.max_workers = max_workers
44-
45-
def __enter__(self) -> _DummyExecutor:
46-
return self
47-
48-
def __exit__(
49-
self,
50-
exc_type: type[BaseException] | None,
51-
exc: BaseException | None,
52-
tb: object | None,
53-
) -> Literal[False]:
54-
return False
42+
@dataclass(slots=True)
43+
class _InlineExecutor:
44+
max_workers: int | None = None
5545

5646
def submit(
5747
self,
58-
fn: object,
48+
fn: Callable[..., object],
5949
*args: object,
6050
**kwargs: object,
6151
) -> _DummyFuture:
62-
assert callable(fn)
6352
return _DummyFuture(fn(*args, **kwargs))
6453

6554

55+
def _dummy_process_pool_executor(
56+
max_workers: int | None = None,
57+
) -> object:
58+
return nullcontext(_InlineExecutor(max_workers=max_workers))
59+
60+
6661
def _patch_parallel(monkeypatch: pytest.MonkeyPatch) -> None:
67-
monkeypatch.setattr(pipeline, "ProcessPoolExecutor", _DummyExecutor)
62+
monkeypatch.setattr(pipeline, "ProcessPoolExecutor", _dummy_process_pool_executor)
6863
monkeypatch.setattr(pipeline, "as_completed", lambda futures: futures)
6964

7065

0 commit comments

Comments
 (0)