Skip to content

Commit 5ad6414

Browse files
committed
fix(test-tools): Registry state is not properly cleared between tests
1 parent 328d1b3 commit 5ad6414

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/common/test_tools/plugin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ def assert_metric_impl() -> Generator[AssertMetricFixture, None, None]:
1111
registry = prometheus_client.REGISTRY
1212
collectors = [*registry._collector_to_names]
1313

14+
# Reset registry state
15+
for collector in collectors:
16+
if isinstance(collector, MetricWrapperBase):
17+
collector.clear()
18+
1419
def _assert_metric(
1520
*,
1621
name: str,
@@ -25,10 +30,5 @@ def _assert_metric(
2530

2631
yield _assert_metric
2732

28-
# Reset registry state
29-
for collector in collectors:
30-
if isinstance(collector, MetricWrapperBase):
31-
collector.clear()
32-
3333

3434
assert_metric = pytest.fixture(assert_metric_impl)

0 commit comments

Comments
 (0)