Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Conversation

@Swatinem
Copy link
Contributor

The etree API is a bit weird, because the iter() method will iterate over matching elements in the whole subtree, instead of only over child elements. Which we actually use extensively, as we are not fully traversing the xml structure of the various formats, but just iterate over the relevant elements, regardless of their nesting.

However for cobertura this might not be the right thing to do. As a class can have lines>line, but also a class>methods>method can have lines>line as well. We are only interested in the directly declared lines>line, not the ones nested within methods however.


Along with fixing this for the cobertura processor, this also changes some tests to use the proper class. We use the lxml library in production, but a ton of tests were using the xml library, which has a mostly compatible API, but differs in some small details. For example, lxml has the iterchildren method, while xml does not.

Along with changing to the proper lxml library, some tests also changed their inputs to bytes, as the lxml library is otherwise throwing an error when trying to parse an xml declaration that defines an encoding from a python str, which is utf-8 by definition.

The etree API is a bit weird, because the `iter()` method will iterate over matching elements in the whole subtree, instead of only over child elements.
Which we actually use extensively, as we are not fully traversing the xml structure of the various formats, but just iterate over the relevant elements, regardless of their nesting.

However for cobertura this might not be the right thing to do. As a `class` can have `lines>line`, but also a `class>methods>method` can have `lines>line` as well.
We are only interested in the directly declared `lines>line`, not the ones nested within `methods` however.

---

Along with fixing this for the cobertura processor, this also changes some tests to use the proper class. We use the `lxml` library in production, but a ton of tests were using the `xml` library, which has a mostly compatible API, but differs in some small details. For example, `lxml` has the `iterchildren` method, while `xml` does not.

Along with changing to the proper `lxml` library, some tests also changed their inputs to `bytes`, as the `lxml` library is otherwise throwing an error when trying to parse an xml declaration that defines an `encoding` from a python `str`, which is utf-8 by definition.
@Swatinem Swatinem requested a review from a team March 24, 2025 12:07
@Swatinem Swatinem self-assigned this Mar 24, 2025
@seer-by-sentry
Copy link
Contributor

✅ Sentry found no issues in your recent changes ✅

@codecov
Copy link

codecov bot commented Mar 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.72%. Comparing base (725a8d1) to head (cbc8484).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1170      +/-   ##
==========================================
- Coverage   97.72%   97.72%   -0.01%     
==========================================
  Files         449      449              
  Lines       36864    36866       +2     
==========================================
+ Hits        36026    36027       +1     
- Misses        838      839       +1     
Flag Coverage Δ
integration 42.89% <71.42%> (+<0.01%) ⬆️
unit 90.42% <100.00%> (-0.01%) ⬇️

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.

@codecov-notifications
Copy link

codecov-notifications bot commented Mar 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants