From 92f141f04fa89e445416714cdc6c97950b7e1dff Mon Sep 17 00:00:00 2001 From: Colby Mchenry Date: Thu, 1 Oct 2026 01:35:48 +0000 Subject: [PATCH] fix(python): a pytest test's parameter is the class its fixture returns (#2228) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A receiver that is the test's own parameter takes the type its in-reach fixture returns (`return Cls(…)` or a local assigned `Cls(…)`), so calls on it resolve on that class, or on nothing when it is a library's; fixtures a conftest.py star-imports or lists in pytest_plugins are in reach. Co-authored-by: Claude Opus 5.5 --- CHANGELOG.md | 1 + __tests__/pytest-fixture-receiver.test.ts | 81 +++++++++++++++++++++++ src/resolution/name-matcher.ts | 76 ++++++++++++++++++++- 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 __tests__/pytest-fixture-receiver.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 063393a22..ae2efec2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixes +- In pytest tests, a parameter now takes the class its fixture returns, so a call on it reaches that class's method. If the class comes from a library, the call no longer reaches the project's only method of that name. Fixtures a `conftest.py` pulls in with `from … import *` or `pytest_plugins` now count as in reach. Before, flask's `runner.invoke(…)` on click's `CliRunner()` linked to the project's `FlaskCliRunner.invoke`, and `@app.get(…)` on a `Flask(…)` fixture linked to an unrelated `get`. - What a Svelte component's instance `