capa
capa copied to clipboard
Tried to fix the issue ( https://github.com/mandiant/capa/issues/1751 )
Fix IDA Test Script to Run with Pytest 7.4.0
Summary
This PR updates test_ida_features.py to be compatible with pytest 7.4.0 by removing the deprecated yield-based test cases. The changes ensure the test script runs correctly within IDA without being mistakenly collected by pytest.
Changes Made
- Replaced
yieldwith standardassertstatements to align with modernpytestbest practices. - Refactored error handling using
pytest.raises()where necessary. - Scoped imports for IDA compatibility, ensuring
capa.features.extractors.ida.extractoris only imported within functions. - Marked test functions with
@nocollectto prevent pytest from collecting them outside IDA. - Updated input file validation to handle different IDA versions'
GetInputFileMD5()behavior correctly. - Ensured proper logging and traceback handling for better debugging in case of failures.
- Maintained
--CAPA_AUTOEXIT=truefunctionality, ensuring the script exits IDA automatically when run from the command line.
Fixes Issue
Resolves [mandiant/capa#1751](https://github.com/mandiant/capa/issues/1751)
Testing
- Verified the script runs within IDA without pytest errors.
- Checked log outputs to ensure failures are reported correctly.
- Confirmed tests still function as expected after migrating from
yield.
[x] No CHANGELOG update needed
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
@maxprogrammer007 would you mind sharing a screenshot of these tests running and passing within IDA?
Sure , will share in few minutes.
On Mon, 17 Mar, 2025, 1:14 pm Willi Ballenthin, @.***> wrote:
@maxprogrammer007 https://github.com/maxprogrammer007 would you mind sharing a screenshot of these tests running and passing within IDA?
— Reply to this email directly, view it on GitHub https://github.com/mandiant/capa/pull/2628#issuecomment-2728469801, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQCHPG4CNQH4M3BVLP2UPID2UZ4MRAVCNFSM6AAAAABZER7KDGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRYGQ3DSOBQGE . You are receiving this because you were mentioned.Message ID: @.***> [image: williballenthin]williballenthin left a comment (mandiant/capa#2628) https://github.com/mandiant/capa/pull/2628#issuecomment-2728469801
@maxprogrammer007 https://github.com/maxprogrammer007 would you mind sharing a screenshot of these tests running and passing within IDA?
— Reply to this email directly, view it on GitHub https://github.com/mandiant/capa/pull/2628#issuecomment-2728469801, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQCHPG4CNQH4M3BVLP2UPID2UZ4MRAVCNFSM6AAAAABZER7KDGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRYGQ3DSOBQGE . You are receiving this because you were mentioned.Message ID: @.***>