GitGuardian / ggshield

Find and fix 400+ types of hardcoded secrets and 70+ types of infrastructure-as-code misconfigurations.
https://gitguardian.com
MIT License
1.59k stars 139 forks source link

GGShield test suite fails with Python 3.12 #832

Open agateau-gg opened 6 months ago

agateau-gg commented 6 months ago

GGShield test suite currently does not pass with Python 3.12. It fails with that error message:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/site-packages/pytest/__main__.py", line 5, in <module>
    raise SystemExit(pytest.console_main())
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/site-packages/_pytest/config/__init__.py", line 190, in console_main
    code = main()
           ^^^^^^
[...]
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/site-packages/snapshottest/__init__.py", line 3, in <module>
    from .module import assert_match_snapshot
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/site-packages/_pytest/assertion/rewrite.py", line 168, in exec_module
    exec(co, module.__dict__)
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/site-packages/snapshottest/module.py", line 4, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'
[...]
Error: Process completed with exit code 1.

This is because the snapshottest package uses the deprecated-and-now-gone imp module. There is a PR to fix it here but it is not moving. It looks like snapshottest is unmaintained. We need to either use the code from the PR (ideally from our own fork) or replace snapshottest with a maintained Python package (https://github.com/joseph-roitman/pytest-snapshot could be a good candidate).