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

test/attr_tests: fix tests with setattr #482

Merged
merged 1 commit into from
Oct 5, 2023
Merged

Conversation

dlech
Copy link
Collaborator

@dlech dlech commented Oct 5, 2023

Description

Since Python objects will dynamically add an attribute if one does not exist when calling setattr(), we need to check that the attribute actually exists before setting it. Otherwise, tests will pass even if the attribute is not defined in the object being tested.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

While developing #474, I noticed that tests were passing when I had an obvious mistake. Applying this fix caught the mistake.

Documentation

If this is a new feature or example please mention or link any documentation. All new hardware interface classes require documentation.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have signed off all commits and they contain "Signed-off by: "
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Since Python objects will dynamically add an attribute if one does not
exist when calling setattr(), we need to check that the attribute
actually exists before setting it. Otherwise, tests will pass even if
the attribute is not defined in the object being tested.

Signed-off-by: David Lechner <[email protected]>
@github-actions
Copy link

github-actions bot commented Oct 5, 2023

Unit Test Results

1 249 tests  ±0      247 ✔️ ±0   5m 12s ⏱️ +8s
       1 suites ±0   1 002 💤 ±0 
       1 files   ±0          0 ±0 

Results for commit fa0404f. ± Comparison against base commit 301a5f5.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 5, 2023

Generated documentation for this PR is available at Link

@tfcollins tfcollins merged commit 93ce4fe into master Oct 5, 2023
@tfcollins tfcollins deleted the dlech/fix-attr-tests branch October 5, 2023 18:03
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