Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Order-insensitive unit test equality assertion for expected/actual with multiple nulls #10202

Merged
merged 5 commits into from
May 24, 2024

Conversation

MichelleArk
Copy link
Contributor

@MichelleArk MichelleArk commented May 21, 2024

resolves #10167

Problem

TableDiff.hasDifference unexpectedly returns True when comparing two input tables that have multiple identical rows with containing None, even if CompareFlags.orderis set toFalse`.

Solution

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

@cla-bot cla-bot bot added the cla:yes label May 21, 2024
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

Copy link

codecov bot commented May 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.68%. Comparing base (09243d1) to head (6058fa3).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10202      +/-   ##
==========================================
+ Coverage   88.63%   88.68%   +0.05%     
==========================================
  Files         180      180              
  Lines       22434    22449      +15     
==========================================
+ Hits        19885    19910      +25     
+ Misses       2549     2539      -10     
Flag Coverage Δ
integration 85.96% <100.00%> (-0.12%) ⬇️
unit 63.37% <60.00%> (+0.37%) ⬆️

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.

@MichelleArk MichelleArk changed the title ensure order-agnostic comparisons during unit testing independently o… Fix: Order-insensitive unit test equality assertion for expected/actual with multiple nulls May 22, 2024
@MichelleArk MichelleArk marked this pull request as ready for review May 23, 2024 22:50
@MichelleArk MichelleArk requested a review from a team as a code owner May 23, 2024 22:50
# Sort expected and actual inputs prior to creating daff diff to ensure order insensitivity
# https://github.com/paulfitz/daff/issues/200
expected_daff_table = daff.PythonTableView(list_rows_from_table(expected, sort=True))
actual_daff_table = daff.PythonTableView(list_rows_from_table(actual, sort=True))

flags = daff.CompareFlags()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved flags initialization higher up as they should also be used to create alignment. This doesn't fix the issue, but it makes sense to use the same flags for alignment and diff, assuming flags.order worked perfectly :)

@MichelleArk MichelleArk merged commit 84456f5 into main May 24, 2024
65 checks passed
@MichelleArk MichelleArk deleted the order-insensitive-unit-test-nulls branch May 24, 2024 14:12
github-actions bot pushed a commit that referenced this pull request May 24, 2024
…al with multiple nulls (#10202)

(cherry picked from commit 84456f5)
MichelleArk pushed a commit that referenced this pull request May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] unit tests' comparisons are sometimes sensitive to the order of records returned
2 participants