Skip to content

fix: Convert class-scoped fixtures in built-in integration tests into @classmethods#3676

Merged
edgarrmondragon merged 1 commit into
mainfrom
fix/class-scoped-fixtures
Jun 16, 2026
Merged

fix: Convert class-scoped fixtures in built-in integration tests into @classmethods#3676
edgarrmondragon merged 1 commit into
mainfrom
fix/class-scoped-fixtures

Conversation

@edgarrmondragon

@edgarrmondragon edgarrmondragon commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

SSIA, pytest-dev/pytest#14071

Summary by Sourcery

Update built-in integration tests and related configuration to comply with pytest 9.1 class-scoped fixture requirements.

Build:

  • Bump pytest testing dependency to >=9.1 and remove obsolete filterwarning for deprecated instance-method class-scoped fixtures.

Tests:

  • Convert class-scoped fixtures in target CSV and Parquet integration tests to class methods and add type annotations for better compatibility with newer pytest versions.

@edgarrmondragon edgarrmondragon self-assigned this Jun 15, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Converts deprecated class-scoped instance fixtures in CSV/Parquet integration tests and the shared test runner to class methods compatible with newer pytest versions, refines a config-path fixture with typing and clearer flow, and updates pytest version and warning filters accordingly.

Sequence diagram for class-scoped runner fixture as classmethod

sequenceDiagram
    participant Pytest
    participant TestClass
    participant test_runner

    Pytest->>TestClass: runner()
    TestClass->>test_runner: sync_all()
    TestClass-->>Pytest: test_runner
    Pytest->>test_runner: execute tap/target tests
Loading

File-Level Changes

Change Details Files
Convert class-scoped fixtures in CSV target integration tests from instance methods to classmethods and improve config file path fixture.
  • Change test_output_dir fixture to a classmethod returning TEST_OUTPUT_DIR with a Path return type annotation.
  • Change resource fixture to a classmethod that accepts a typed Path, manages directory lifecycle, and yields the test output directory.
  • Annotate the config_file_path fixture parameter with TargetCSV and compute the config path before the try/except, simplifying control flow while preserving file creation and cleanup behavior.
tests/packages/test_target_csv.py
Convert class-scoped fixtures in Parquet target integration tests from instance methods to classmethods.
  • Change test_output_dir fixture to a classmethod returning SAMPLE_FILEPATH with a Path return type annotation.
  • Change resource fixture to a classmethod that accepts a typed Path, manages directory lifecycle, and yields the test output directory.
tests/packages/test_target_parquet.py
Align shared test runner fixture with new classmethod fixture style and update pytest configuration to match.
  • Change the runner fixture in the testing factory to a classmethod while keeping its behavior of pre-populating and returning the test runner instance.
  • Bump the testing extra requirement from pytest>=9 to pytest>=9.1 to rely on newer fixture semantics.
  • Remove the filterwarnings entry that suppressed the deprecation warning about class-scoped fixtures defined as instance methods, since these fixtures have been updated.
singer_sdk/testing/factory.py
pyproject.toml
uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@edgarrmondragon
edgarrmondragon marked this pull request as draft June 15, 2026 16:26
@edgarrmondragon edgarrmondragon added this to the v0.55 milestone Jun 15, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Converting @pytest.fixture(scope="class") methods to @classmethods is unlikely to work as intended with pytest’s fixture mechanism (fixtures are plain callables with injected dependencies, not classmethods); consider keeping them as instance methods or switching to xunit-style setup_class/teardown_class if you need true classmethods.
  • The new classmethod fixtures still declare parameters like test_output_dir: Path, but pytest won’t inject fixture arguments into a classmethod in the usual way, so either revert them to standard fixtures or adjust the design so dependencies are obtained via request.cls/shared state instead of parameters.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Converting `@pytest.fixture(scope="class")` methods to `@classmethod`s is unlikely to work as intended with pytest’s fixture mechanism (fixtures are plain callables with injected dependencies, not `classmethod`s); consider keeping them as instance methods or switching to xunit-style `setup_class`/`teardown_class` if you need true classmethods.
- The new classmethod fixtures still declare parameters like `test_output_dir: Path`, but pytest won’t inject fixture arguments into a `classmethod` in the usual way, so either revert them to standard fixtures or adjust the design so dependencies are obtained via `request.cls`/shared state instead of parameters.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@edgarrmondragon
edgarrmondragon force-pushed the fix/class-scoped-fixtures branch from 276e5f1 to 8985d60 Compare June 15, 2026 16:27
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.12%. Comparing base (55738c3) to head (cdfcd3d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3676   +/-   ##
=======================================
  Coverage   94.12%   94.12%           
=======================================
  Files          73       73           
  Lines        6199     6200    +1     
  Branches      762      762           
=======================================
+ Hits         5835     5836    +1     
  Misses        270      270           
  Partials       94       94           
Flag Coverage Δ
core 82.95% <100.00%> (+<0.01%) ⬆️
end-to-end 76.03% <100.00%> (+<0.01%) ⬆️
optional-components 44.82% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq

codspeed-hq Bot commented Jun 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 8 untouched benchmarks


Comparing fix/class-scoped-fixtures (cdfcd3d) with main (55738c3)

Open in CodSpeed

@edgarrmondragon
edgarrmondragon force-pushed the fix/class-scoped-fixtures branch from 8985d60 to bdfb571 Compare June 15, 2026 16:32
… `@classmethod`s

Signed-off-by: Edgar Ramírez Mondragón <[email protected]>
@edgarrmondragon
edgarrmondragon force-pushed the fix/class-scoped-fixtures branch from bdfb571 to cdfcd3d Compare June 15, 2026 16:39
@edgarrmondragon
edgarrmondragon marked this pull request as ready for review June 16, 2026 01:24
@edgarrmondragon
edgarrmondragon requested a review from a team as a code owner June 16, 2026 01:24

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Using @classmethod together with @pytest.fixture(scope="class") is an unusual pattern that may be brittle; consider converting these to plain function-level fixtures (outside the test classes) or class-scoped fixtures that take request instead of cls to align with pytest’s recommended usage and make future maintenance clearer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Using `@classmethod` together with `@pytest.fixture(scope="class")` is an unusual pattern that may be brittle; consider converting these to plain function-level fixtures (outside the test classes) or class-scoped fixtures that take `request` instead of `cls` to align with pytest’s recommended usage and make future maintenance clearer.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@edgarrmondragon
edgarrmondragon added this pull request to the merge queue Jun 16, 2026
Merged via the queue into main with commit 787800b Jun 16, 2026
40 checks passed
@edgarrmondragon
edgarrmondragon deleted the fix/class-scoped-fixtures branch June 16, 2026 01:27
edgarrmondragon added a commit that referenced this pull request Jun 16, 2026
… `@classmethod`s (#3676) (#3677)

SSIA, backport of #3676

## Summary by Sourcery

Convert class-scoped pytest fixtures in built-in integration tests to
class methods and update pytest version constraint for testing.

Enhancements:
- Refactor test_target_csv and test_target_parquet to define
class-scoped fixtures as @classmethods for better compatibility with
newer pytest versions.

Build:
- Bump pytest testing dependency to >=9.1 in pyproject.toml.

Tests:
- Adjust factory-based runner fixture to be a class method to align with
updated fixture patterns in generated tests.

Signed-off-by: Edgar Ramírez Mondragón <[email protected]>
@sourcery-ai sourcery-ai Bot mentioned this pull request Jun 16, 2026
3 tasks
daria-hrabar pushed a commit to daria-hrabar/sdk that referenced this pull request Jun 16, 2026
- **fix: Ensure stream name is include in log message when
ACTIVATE_VERSION forces _sdc metadata columns (meltano#3650)**
- **chore: Release v0.54.3 (meltano#3651)**
- **fix: Emitted `ACTIVATE_VERSION` now honor the stream aliases
configured with stream maps (meltano#3654)**
- **chore: Release v0.54.4 (meltano#3655)**
- **chore: Lock file maintenance**
- **fix: Convert class-scoped fixtures in built-in integration tests
into `@classmethod`s (meltano#3676) (meltano#3677)**
- **chore: Release v0.54.5 (meltano#3678)**

## Summary by Sourcery

Release version v0.54.5 and align templates, docs, and tooling with the
new version.

Bug Fixes:
- Document the fix converting class-scoped fixtures in built-in
integration tests to use @classmethods in the changelog.

Enhancements:
- Update cookiecutter tap/target/mapper templates to depend on
singer-sdk v0.54.5.

Build:
- Update project version metadata to 0.54.5 in pyproject and related
tooling configuration.

Documentation:
- Bump documented release version to 0.54.5 in the Sphinx configuration
and GitHub bug report template.

---------

Signed-off-by: Edgar Ramírez Mondragón <[email protected]>
Co-authored-by: MeltyBot <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dependencies kind/Bug Something isn't working testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant