Skip to content

snapshottest incompatible with Python 3.12 due to missing imp module #177

@Miskler

Description

@Miskler

Description:
When using pytest with Python 3.12, an error occurs due to the snapshottest package trying to import the deprecated imp module, which was removed in Python 3.12. This causes the following error:

ModuleNotFoundError: No module named 'imp'

Steps to Reproduce:

  1. Install Python 3.12.
  2. Install pytest and snapshottest.
  3. Run pytest with any tests that include snapshottest.

Expected Behavior:
pytest should run without errors related to the imp module.

Actual Behavior:
pytest fails with the error: ModuleNotFoundError: No module named 'imp'.

Possible Solution:

  • Replace imp with importlib as imp is deprecated and removed in Python 3.12.
  • Consider upgrading the snapshottest package to a version that is compatible with Python 3.12, or provide a patch to handle this issue.

Environment:

  • Python 3.12 / Python 3.13
  • pytest 8.3.5
  • snapshottest 0.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions