Skip to content

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

Merged
edgarrmondragon merged 1 commit into
v0.54from
fix/class-scoped-fixtures
Jun 16, 2026
Merged

fix: Convert class-scoped fixtures in built-in integration tests into @classmethods (#3676)#3677
edgarrmondragon merged 1 commit into
v0.54from
fix/class-scoped-fixtures

Conversation

@edgarrmondragon

@edgarrmondragon edgarrmondragon commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

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.

… `@classmethod`s (#3676)

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.

Signed-off-by: Edgar Ramírez Mondragón <[email protected]>
@edgarrmondragon
edgarrmondragon requested a review from a team as a code owner June 16, 2026 02:31
@edgarrmondragon edgarrmondragon self-assigned this Jun 16, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 16, 2026

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

Reviewer's Guide

Converts several class-scoped pytest fixtures in the built-in integration tests and dynamic test factory to classmethods to align with pytest 9.1 behavior, and bumps the pytest dependency accordingly, plus a small type hint / control-flow tweak in a CSV target config fixture.

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()
    test_runner-->>TestClass: test_runner
    TestClass-->>Pytest: test_runner
Loading

File-Level Changes

Change Details Files
Convert class-scoped fixtures in CSV/Parquet target tests to classmethods.
  • Update test_output_dir fixtures in target CSV and Parquet tests to be declared as @classmethods returning Path objects.
  • Update resource fixtures in target CSV and Parquet tests to be declared as @classmethods that accept a Path, manage directory creation, yield it, and then clean up with shutil.rmtree.
tests/packages/test_target_csv.py
tests/packages/test_target_parquet.py
Adjust pytest-based test runner fixture in the dynamic test factory to be a classmethod.
  • Change the runner fixture produced by the test factory to be a @classmethod returning a TapTestRunner or TargetTestRunner, ensuring compatibility with pytest class-scoped fixture resolution.
singer_sdk/testing/factory.py
Minor fixture and dependency updates to support newer pytest behavior.
  • Refine the config_file_path fixture for the CSV target to add a TargetCSV type annotation, move the path construction out of the try block, and leave file write/cleanup inside try/finally.
  • Bump the pytest testing extra dependency from >=9 to >=9.1 to match required behavior for the updated class-scoped fixtures.
  • Update uv.lock to reflect the dependency change.
tests/packages/test_target_csv.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

@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 the class-scoped fixtures to @classmethods is likely to break pytest’s fixture binding (pytest expects an instance self for class-level method fixtures, not cls), so consider keeping them as regular methods or moving them to module-level fixtures instead.
  • The new type annotation target: TargetCSV in config_file_path appears to use TargetCSV without a local import, which may cause runtime or type-checking issues unless TargetCSV is already imported or annotations are postponed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Converting the class-scoped fixtures to `@classmethod`s is likely to break pytest’s fixture binding (pytest expects an instance `self` for class-level method fixtures, not `cls`), so consider keeping them as regular methods or moving them to module-level fixtures instead.
- The new type annotation `target: TargetCSV` in `config_file_path` appears to use `TargetCSV` without a local import, which may cause runtime or type-checking issues unless `TargetCSV` is already imported or annotations are postponed.

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.

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.81%. Comparing base (8e40fea) to head (4c8428a).

Additional details and impacted files
@@            Coverage Diff             @@
##            v0.54    #3677      +/-   ##
==========================================
+ Coverage   92.33%   93.81%   +1.47%     
==========================================
  Files          73       73              
  Lines        5951     5952       +1     
  Branches      731      731              
==========================================
+ Hits         5495     5584      +89     
+ Misses        360      273      -87     
+ Partials       96       95       -1     
Flag Coverage Δ
core 82.40% <100.00%> (+<0.01%) ⬆️
end-to-end 75.20% <100.00%> (+2.67%) ⬆️
optional-components 42.72% <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 16, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 8 untouched benchmarks


Comparing fix/class-scoped-fixtures (4c8428a) with v0.54 (8e40fea)

Open in CodSpeed

@edgarrmondragon
edgarrmondragon merged commit 9dd5563 into v0.54 Jun 16, 2026
41 checks passed
@edgarrmondragon
edgarrmondragon deleted the fix/class-scoped-fixtures branch June 16, 2026 02:35
@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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant