Skip to content

Fix/issue 418 windows pytest bdd path#419

Merged
HardNorth merged 6 commits intodevelopfrom
fix/issue-418-windows-pytest-bdd-path
Apr 8, 2026
Merged

Fix/issue 418 windows pytest bdd path#419
HardNorth merged 6 commits intodevelopfrom
fix/issue-418-windows-pytest-bdd-path

Conversation

@drcrazy
Copy link
Copy Markdown
Contributor

@drcrazy drcrazy commented Apr 7, 2026

Problem

On Windows, Item.location[0] uses backslashes, so the check for pytest_bdd/scenario.py never matched. ReportPortal then got both the generic pytest item and the BDD scenario/steps (duplicate executions).

Change

  • Add _is_pytest_bdd_scenario_location() with path separator normalization.
  • Use it in start_pytest_item, process_results, and finish_pytest_item.

Tests

  • Unit tests for POSIX path, Windows path, and a non-scenario module.

Fixes #418

Summary by CodeRabbit

  • Bug Fixes

    • Improved cross-platform detection of pytest-bdd scenarios so BDD tests are correctly identified across platforms, preventing misclassification and ensuring proper handling during test start, result processing, and finish.
  • Tests

    • Added unit tests validating correct recognition of BDD scenario paths and confirming non-BDD test paths are not misidentified.

drcrazy added 2 commits April 7, 2026 22:09
Item.location[0] uses backslashes on Windows, so the suffix check for
pytest_bdd/scenario.py never matched and RP received duplicate items.

Normalize path separators before comparing the suffix.

Closes #418

Made-with: Cursor
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7f56ee96-8b86-4b0e-998b-0cf36e1cce94

📥 Commits

Reviewing files that changed from the base of the PR and between f419251 and 7527f7f.

📒 Files selected for processing (1)
  • tests/unit/test_service.py
✅ Files skipped from review due to trivial changes (1)
  • tests/unit/test_service.py

Walkthrough

Added a portable helper _is_pytest_bdd_scenario(location_path: str) -> bool and replaced three hardcoded Unix-style suffix checks with this helper in start_pytest_item, process_results, and finish_pytest_item to correctly detect pytest-bdd scenario modules across OS path separators.

Changes

Cohort / File(s) Summary
BDD Scenario Detection Helper
pytest_reportportal/service.py
Added _is_pytest_bdd_scenario(location_path: str) -> bool (normalizes path separators and checks suffix). Replaced direct endswith("/pytest_bdd/scenario.py") checks in start_pytest_item, process_results, and finish_pytest_item to route BDD detection through the helper and adjust BDD-item storage/cleanup logic.
Unit Tests
tests/unit/test_service.py
Imported os and the new helper; added two tests asserting _is_pytest_bdd_scenario() returns True for an os.path.join(..., "pytest_bdd", "scenario.py") path and False for a non-BDD path (/project/tests/test_foo.py).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through slashes, backslashes too,
I stitched the path so tests stay true.
No doubled stories, no echoes at night,
One clear report — I set it right. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix/issue 418 windows pytest bdd path' clearly summarizes the main change: fixing a Windows-specific path separator issue with pytest-bdd scenario detection to prevent duplicate ReportPortal items.
Linked Issues check ✅ Passed The pull request fully addresses issue #418 by introducing a path-separator-agnostic detection helper function that correctly identifies pytest-bdd scenarios across Windows and POSIX systems with comprehensive unit tests.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the Windows pytest-bdd path separator issue: the helper function, its integration into three detection points, and corresponding unit tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-418-windows-pytest-bdd-path

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Member

@HardNorth HardNorth left a comment

Choose a reason for hiding this comment

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

LGTM

@HardNorth HardNorth merged commit 7ff9c61 into develop Apr 8, 2026
13 checks passed
@HardNorth HardNorth deleted the fix/issue-418-windows-pytest-bdd-path branch April 8, 2026 10:51
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 69.66%. Comparing base (d3d2e2b) to head (7527f7f).
⚠️ Report is 18 commits behind head on develop.

Files with missing lines Patch % Lines
pytest_reportportal/service.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #419      +/-   ##
===========================================
- Coverage    69.73%   69.66%   -0.08%     
===========================================
  Files            6        6              
  Lines         1411     1411              
===========================================
- Hits           984      983       -1     
- Misses         427      428       +1     
Flag Coverage Δ
unittests 69.66% <80.00%> (-0.08%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

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.

Windows: duplicate ReportPortal items for pytest-bdd scenarios (path separator in scenario.py check)

3 participants