Skip to content

fix(test): stabilize Python provider pipdeptree tests - #579

Merged
ruromero merged 1 commit into
guacsec:mainfrom
ruromero:fix/python-provider-test-stability
Sep 1, 2026
Merged

fix(test): stabilize Python provider pipdeptree tests#579
ruromero merged 1 commit into
guacsec:mainfrom
ruromero:fix/python-provider-test-stability

Conversation

@ruromero

@ruromero ruromero commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Updates urllib3 fixture from 1.26.16 to 2.7.0 across all pip test resources (requirements.txt, expected SBOMs, pip-freeze-all.txt, pip-show.txt, pipdeptree.json)
  • Sets @SetSystemProperty(key = PROP_MATCH_MANIFEST_VERSIONS, value = "false") on test_the_provideStack_with_pipdeptree so the test is no longer sensitive to version drift between the fixture pins and the actual system Python environment

Why

Follow-up to #578. The pipdeptree test calls provideStack() before the pipdeptree mock is wired up, causing the real pipdeptree binary to run and compare installed versions against the fixture requirements.txt. With MATCH_MANIFEST_VERSIONS=true (default), any drift aborts the test before assertions run. The intent of this test is to verify pipdeptree output parsing, not version matching — version matching is already covered by the non-pipdeptree test variants.

Test plan

  • test_the_provideStack_with_pipdeptree passes regardless of locally installed Python package versions
  • Full IT suite shows 0 errors for Python provider tests

🤖 Generated with Claude Code

Summary by Sourcery

Make pipdeptree parsing tests deterministic across Python environments.

Bug Fixes:

  • Stabilize the pipdeptree provider test by ensuring mocked output is configured before stack generation, preventing unintended execution of the real pipdeptree binary.

Tests:

  • Update Python provider test fixtures to use urllib3 2.7.0 consistently across requirements, dependency snapshots, and expected SBOMs.
  • Disable manifest-version matching for the pipdeptree parsing test so results are independent of the host Python environment.

@sourcery-ai

sourcery-ai Bot commented Sep 1, 2026

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

Reviewer's Guide

Stabilizes Python pipdeptree integration tests by disabling environment-sensitive manifest version matching for parsing-focused coverage and updating all pip fixtures and expected SBOM data to urllib3 2.7.0.

File-Level Changes

Change Details Files
Decouple pipdeptree parsing coverage from host-environment package versions.
  • Disable manifest-version matching only for the pipdeptree provider test.
  • Preserve system-property restoration after the test.
src/test/java/io/github/guacsec/trustifyda/providers/Python_Provider_Test.java
Synchronize Python fixture data with the updated urllib3 version.
  • Replace urllib3 1.26.16 with 2.7.0 in both requirements fixtures.
  • Refresh freeze, show, pipdeptree, and expected component/stack SBOM fixture values.
src/test/resources/tst_manifests/pip/pip-freeze-all.txt
src/test/resources/tst_manifests/pip/pip-show.txt
src/test/resources/tst_manifests/pip/pip_requirements_txt_ignore/expected_component_sbom.json
src/test/resources/tst_manifests/pip/pip_requirements_txt_ignore/expected_stack_sbom.json
src/test/resources/tst_manifests/pip/pip_requirements_txt_ignore/requirements.txt
src/test/resources/tst_manifests/pip/pip_requirements_txt_no_ignore/expected_component_sbom.json
src/test/resources/tst_manifests/pip/pip_requirements_txt_no_ignore/expected_stack_sbom.json
src/test/resources/tst_manifests/pip/pip_requirements_txt_no_ignore/requirements.txt
src/test/resources/tst_manifests/pip/pipdeptree.json

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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/test/java/io/github/guacsec/trustifyda/providers/Python_Provider_Test.java" line_range="156" />
<code_context>
   @MethodSource("testFolders")
   @SetSystemProperty(key = PythonControllerBase.PROP_TRUSTIFY_DA_PYTHON_VIRTUAL_ENV, value = "true")
   @SetSystemProperty(key = PROP_TRUSTIFY_DA_PIP_USE_DEP_TREE, value = "true")
+  @SetSystemProperty(key = PROP_MATCH_MANIFEST_VERSIONS, value = "false")
   @RestoreSystemProperties
   void test_the_provideStack_with_pipdeptree(String testFolder) throws IOException {
</code_context>
<issue_to_address>
**issue (testing):** Setting `MATCH_MANIFEST_VERSIONS=false` suppresses only the version-mismatch exception; `provideStack()` still calls `getDependencyTreeJsonFromPipDepTree()` before `PIPDEPTREE` is populated, so the real local `pipdeptree` output is parsed and its environment-dependent versions and dependency tree are compared with the fixed expected SBOM. The test therefore still fails when the local environment differs from the fixture, or fails earlier when the real pipdeptree command is unavailable.

**Triggers:** When `RUN_PYTHON_BIN=true` and the installed Python environment differs from the pip fixtures.

**Suggested fix:** Populate `PROP_TRUSTIFY_DA_PIP_PIPDEPTREE` before calling `provideStack()` (or inject a controller configured with the fixture output), then retain the version-matching override only if the parsing test does not need that validation.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: src/test/java/io/github/guacsec/trustifyda/providers/Python_Provider_Test.java:156


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.

Comment thread src/test/java/io/github/guacsec/trustifyda/providers/Python_Provider_Test.java Outdated
@ruromero
ruromero force-pushed the fix/python-provider-test-stability branch from 6365aef to dd29945 Compare September 1, 2026 15:12

@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.

Sourcery assessment

Approved.

@ruromero
ruromero enabled auto-merge (squash) September 1, 2026 15:13
@ruromero
ruromero disabled auto-merge September 1, 2026 15:14
@ruromero
ruromero force-pushed the fix/python-provider-test-stability branch from dd29945 to 22f2caf Compare September 1, 2026 15:30
- Update urllib3 fixture from 1.26.16 to 2.7.0 across all pip test resources
- Set MATCH_MANIFEST_VERSIONS=false on test_the_provideStack_with_pipdeptree
  to decouple the pipdeptree parsing test from env version drift

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@ruromero
ruromero force-pushed the fix/python-provider-test-stability branch from 22f2caf to 163e673 Compare September 1, 2026 20:42
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@3642518). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #579   +/-   ##
=======================================
  Coverage        ?   69.34%           
  Complexity      ?     1040           
=======================================
  Files           ?       66           
  Lines           ?     4371           
  Branches        ?      774           
=======================================
  Hits            ?     3031           
  Misses          ?      993           
  Partials        ?      347           
Flag Coverage Δ
integration-tests 69.34% <ø> (?)

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

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

@ruromero
ruromero merged commit 6b99001 into guacsec:main Sep 1, 2026
42 of 44 checks passed
@ruromero
ruromero deleted the fix/python-provider-test-stability branch September 1, 2026 20:47
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.

2 participants