Skip to content

tests: Fix imprecise assert - #7391

Merged
echoix merged 24 commits into
OSGeo:mainfrom
echoix:fix-imprecise-assert
May 14, 2026
Merged

echoix merged 24 commits into
OSGeo:mainfrom
echoix:fix-imprecise-assert

Conversation

@echoix

@echoix echoix commented May 14, 2026

Copy link
Copy Markdown
Member

I tested out GitHub’s Code Quality tool based on CodeQL, from my second fork (an org) in order to enable it.
It also allowed some AI findings on changed files, and also was able to create the suggestions and open a PR, however, only one change per PR. So, I queued up most of the suggestions I agreed on for one single problem
(I wasn’t 100% sure for 3 of the 34-36 instances).

The PRs opened from the dashboard of issues essentially contained:

Use a specific comparison assertion instead of a boolean assertion for relational checks.

Best fix (no functionality change): in imagery/i.gensig/testsuite/test_i_gensig.py, replace line 142:

  • from: self.assertTrue(abs(Sn.sig[0].var[1][1] - 0.6) < 0.1)
  • to: self.assertLess(abs(Sn.sig[0].var[1][1] - 0.6), 0.1)

This preserves behavior while improving failure messages and aligns with nearby assertions already using assertLess. No imports, helpers, or additional definitions are needed.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

So, I’m noting that this was made with AI, but the usage was checked against the unittest docs by me, and the changes are trivial. I excluded the 3 suggestions where I wasn’t sure if it was the equality operation itself being tested.

echoix and others added 24 commits May 13, 2026 12:31
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* Apply suggested fix to lib/imagery/testsuite/test_imagery_signature_management.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to lib/imagery/testsuite/test_imagery_signature_management.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to lib/imagery/testsuite/test_imagery_signature_management.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to lib/imagery/testsuite/test_imagery_signature_management.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to lib/imagery/testsuite/test_imagery_signature_management.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggestion from @echoix

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…smooth_edgepreserve.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…smooth_edgepreserve.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…om Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…om Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-actions github-actions Bot added raster Related to raster data processing temporal Related to temporal data processing Python Related code is in Python libraries module imagery labels May 14, 2026
@github-actions github-actions Bot added the tests Related to Test Suite label May 14, 2026
@echoix
echoix enabled auto-merge (squash) May 14, 2026 15:45
@echoix
echoix merged commit 3301c12 into OSGeo:main May 14, 2026
26 of 28 checks passed
@echoix
echoix deleted the fix-imprecise-assert branch May 14, 2026 16:46
@github-actions github-actions Bot added this to the 8.6.0 milestone May 14, 2026
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Jul 7, 2026
Use a specific comparison assertion instead of a boolean assertion for relational checks.


* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fixes for 5 code quality findings

* Apply suggested fix to lib/imagery/testsuite/test_imagery_signature_management.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to lib/imagery/testsuite/test_imagery_signature_management.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to lib/imagery/testsuite/test_imagery_signature_management.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to lib/imagery/testsuite/test_imagery_signature_management.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to lib/imagery/testsuite/test_imagery_signature_management.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggestion from @echoix

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to raster/r.smooth.edgepreserve/testsuite/test_r_smooth_edgepreserve.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to raster/r.smooth.edgepreserve/testsuite/test_r_smooth_edgepreserve.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Apply suggested fix to imagery/i.gensig/testsuite/test_i_gensig.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to imagery/i.gensig/testsuite/test_i_gensig.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix for Imprecise assert

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

imagery libraries module Python Related code is in Python raster Related to raster data processing temporal Related to temporal data processing tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants