Skip to content

Comments

This PR addresses improves test coverage for get() and getall():#333

Closed
IkramKhanNiazi wants to merge 2 commits intoscrapy:masterfrom
IkramKhanNiazi:consolidate-tests-and-add-get-getall-edge-cases
Closed

This PR addresses improves test coverage for get() and getall():#333
IkramKhanNiazi wants to merge 2 commits intoscrapy:masterfrom
IkramKhanNiazi:consolidate-tests-and-add-get-getall-edge-cases

Conversation

@IkramKhanNiazi
Copy link
Contributor

Adds comprehensive edge case tests for get() and getall() methods in test_selector.py:

  • Empty SelectorList handling
  • Default value behavior
  • Different node types (element, text, attribute)
  • Consistency between methods
  • Order preservation
  • CSS selector compatibility

@codecov
Copy link

codecov bot commented Dec 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.18%. Comparing base (612e605) to head (b4324a2).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #333   +/-   ##
=======================================
  Coverage   95.18%   95.18%           
=======================================
  Files           5        5           
  Lines         436      436           
  Branches       76       76           
=======================================
  Hits          415      415           
  Misses         13       13           
  Partials        8        8           

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

@IkramKhanNiazi IkramKhanNiazi changed the title This PR addresses reviewer feedback and improves test coverage: This PR addresses improves test coverage: Dec 27, 2025
@IkramKhanNiazi IkramKhanNiazi changed the title This PR addresses improves test coverage: This PR addresses improves test coverage for get() and getall(): Dec 27, 2025
@wRAR
Copy link
Member

wRAR commented Dec 27, 2025

improves test coverage

It doesn't look like the test coverage is affected though (just like in your previous PRs).

assert sel.xpath("//div").getall() == []
assert sel.css("div").getall() == []
assert sel.xpath("//nonexistent").getall() == []
assert isinstance(sel.xpath("//div").getall(), list)
Copy link
Member

Choose a reason for hiding this comment

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

I haven't looked at all tests but it looks likely to me that these tests are repetitive and test things already tested.

As one example, can you please explain why do you need to have similar checks for div and nonexistent and to have an isinstance check for the value already checked for equality before?

assert sel.css("nonexistent").get() is None

def test_getall_on_css_selector(self) -> None:
"""Test getall() works with CSS selectors"""
Copy link
Member

Choose a reason for hiding this comment

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

As another example, are you sure it's not already tested?

@IkramKhanNiazi IkramKhanNiazi deleted the consolidate-tests-and-add-get-getall-edge-cases branch December 27, 2025 13:41
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