One-liner in bandit config to skip B101 assert_used in files matching a filter
See original GitHub issueCurrently you can exclude a directory and you can skip certain tests across all scanned files. It would be very handy to be able to exclude test_* pytest files from the B101 assert test with a simple one liner in the .bandit config file.
This is a feature request for something like:
In .bandit
[bandit]
pytest_filter: test_* #excludes B101 in files matching test_*
Excluding all B101 is not a good solution, because I want to know about B101 in non-test modules.
Also, I’d like to be able to exclude on file filter like test_* rather than directory test/ because that filter works better across projects I have seen where test directory might not be named consistently, but all the pytests are generally named a special way e.g. test_*
This will allow a more general (across projects) config file to be set up.
Issue Analytics
- State:
 - Created 5 years ago
 - Reactions:45
 - Comments:5 (1 by maintainers)
 
Top Results From Across the Web
How can I make bandit skip B101 within tests? - Stack Overflow
You can configure files that skip this check. This is often useful when you use assert statements in test cases. bandit --configfile bandit....
Read more >Bandit Documentation - Read the Docs
Config Options: You can configure files that skip this check. This is often useful when you use assert statements in test cases. assert_used:....
Read more >Configuration — Bandit documentation - Read the Docs
To use this, put an INI file named .bandit in your project's directory. ... skips: ['B101', 'B601'] ### override settings - used to...
Read more >Code Issues - Embold Help Center
Moreover, you can configure separate log files for different purposes. ... Using this algorithm, lines of code that are split are counted as...
Read more >Configuring code patterns - Codacy Quality docs
To enable all code patterns matching a specific category, use the filter to select the ... To use a configuration file for your...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi, the following may be helpful to configure
banditto avoid raisingB101 assert_usedwarnings on python tests.Does this not work anymore?