question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

One-liner in bandit config to skip B101 assert_used in files matching a filter

See original GitHub issue

Currently 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:closed
  • Created 5 years ago
  • Reactions:45
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
diegovalenzuelaiturracommented, Nov 17, 2021

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

0reactions
loikeincommented, Jun 24, 2020

Does this not work anymore?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found