bandit
bandit copied to clipboard
One test fails
Describe the bug
========================================================================================== ERRORS ===========================================================================================
_________________________________________________________________________________ ERROR at setup of test_id _________________________________________________________________________________
file /usr/ports/devel/py-bandit/work-py39/bandit-1.7.6/bandit/core/test_properties.py, line 49
def test_id(id_val):
E fixture 'id_val' not found
> available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, testrun_uid, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory, worker_id
> use 'pytest --fixtures [testpath]' for help on them.
/usr/ports/devel/py-bandit/work-py39/bandit-1.7.6/bandit/core/test_properties.py:49
========================================================================================= FAILURES ==========================================================================================
____________________________________________________________________ BanditBaselineToolTests.test_main_subprocess_error _____________________________________________________________________
'NoneType' object is not iterable
During handling of the above exception, another exception occurred:
NOTE: Incompatible Exception Representation, displaying natively:
testtools.testresult.real._StringException: SystemExit: 2
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/ports/devel/py-bandit/work-py39/bandit-1.7.6/tests/unit/cli/test_baseline.py", line 189, in test_main_subprocess_error
self.assertRaisesRegex(SystemExit, "3", baseline.main)
File "/usr/local/lib/python3.9/unittest/case.py", line 1282, in assertRaisesRegex
return context.handle('assertRaisesRegex', args, kwargs)
File "/usr/local/lib/python3.9/unittest/case.py", line 201, in handle
callable_obj(*args, **kwargs)
File "/usr/local/lib/python3.9/unittest/case.py", line 239, in __exit__
self._raiseFailure('"{}" does not match "{}"'.format(
File "/usr/local/lib/python3.9/unittest/case.py", line 163, in _raiseFailure
raise self.test_case.failureException(msg)
AssertionError: "3" does not match "2"
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
[ INFO ] No output format specified, using terminal
[ ERROR ] Bandit baseline must not be called with the -o option
------------------------------------------------------------------------------------- Captured log call -------------------------------------------------------------------------------------
INFO bandit.cli.baseline:baseline.py:195 No output format specified, using terminal
ERROR bandit.cli.baseline:baseline.py:234 Bandit baseline must not be called with the -o option
===================================================================================== warnings summary ======================================================================================
tests/unit/core/test_test_set.py::test_plugin
Expected None, but tests/unit/core/test_test_set.py::test_plugin returned {'Import': [{'name': 'telnet', 'id': 'B401', 'cwe': 319, 'message': 'A telnet-related module is being imported. Telnet is considered insecure. Use SSH or some other encrypted protocol.', 'qualnames': ['telnetlib'], 'level': 'HIGH'}, {'name': 'marshal', 'id': 'B302', 'cwe': 502, 'message': 'Deserialization with the marshal module is possibly dangerous.', 'qualnames': ['marshal.load', 'marshal.loads'], 'level': 'MEDIUM'}], 'ImportFrom': [{'name': 'telnet', 'id': 'B401', 'cwe': 319, 'message': 'A telnet-related module is being imported. Telnet is considered insecure. Use SSH or some other encrypted protocol.', 'qualnames': ['telnetlib'], 'level': 'HIGH'}, {'name': 'marshal', 'id': 'B302', 'cwe': 502, 'message': 'Deserialization with the marshal module is possibly dangerous.', 'qualnames': ['marshal.load', 'marshal.loads'], 'level': 'MEDIUM'}], 'Call': [{'name': 'telnet', 'id': 'B401', 'cwe': 319, 'message': 'A telnet-related module is being imported. Telnet is considered insecure. Use SSH or some other encrypted protocol.', 'qualnames': ['telnetlib'], 'level': 'HIGH'}, {'name': 'marshal', 'id': 'B302', 'cwe': 502, 'message': 'Deserialization with the marshal module is possibly dangerous.', 'qualnames': ['marshal.load', 'marshal.loads'], 'level': 'MEDIUM'}]}, which will be an error in a future version of pytest. Did you mean to use `assert` instead of `return`?
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==================================================================== 1 failed, 267 passed, 1 warning, 1 error in 33.86s =====================================================================
Reproduction steps
pytest
Expected behavior
n/a
Bandit version
1.7.6 (Default)
Python version
3.12 (Default)
Additional context
Python-3.9 FreeBSD 13.2
I am not seeing this, do you know which version of python the failure happened against?
See if you can narrow it down to a version tox run -e py3.12
Bandit uses stestr with tox to run unit tests. The issue is probably because you're attempting to run with pytest. Also note that with every PR we run the unit tests, so I don't think there is a current issue there.
However, if you're trying to do something else, please add some more details to this issue. Thanks