bandit icon indicating copy to clipboard operation
bandit copied to clipboard

Skip configuration for certain paths only

Open andreas-h opened this issue 5 years ago • 5 comments

Is your feature request related to a problem? Please describe. I'm a bit annoyed by the B101 assert_used warnings in my testing code, as pytest recommends (and I follow) using assert statements. It's confusing that bandit complains about them. On the other hand, I want to be warned about using assert in my non-test code.

Describe the solution you'd like I'd like to be able to ignore pattern B101 for the /tests folder only.

andreas-h avatar Feb 28 '19 07:02 andreas-h

sounds rationale to me @andreas-h , is this a patch you would like to work on?

lukehinds avatar Feb 28 '19 09:02 lukehinds

Alternatively, can we make Bandit a bit smarter in a way that it recognizes when assert is used in a test module, and not warn about it?

bittner avatar Mar 14 '19 14:03 bittner

See also #346 - B101 in tests is a big pain.

cc-stjm avatar Apr 30 '20 15:04 cc-stjm

Hi, the following may be helpful to configure bandit to avoid raising B101 assert_used warnings on python tests.

  • https://github.com/PyCQA/bandit/issues/603#issuecomment-971057519

diegovalenzuelaiturra avatar Nov 17 '21 01:11 diegovalenzuelaiturra

I am facing the same issue, is there a way to exclude B101 in the /tests folder? I tried to use the assert_used but this does not seem to work.

mpas avatar Nov 03 '22 05:11 mpas