From 4bc75c55bb49e3986548ddf4f3c2b5ed77842b38 Mon Sep 17 00:00:00 2001 From: Frank Hoffmann <15r10nk-git@polarbit.de> Date: Fri, 8 Nov 2024 09:12:43 +0100 Subject: [PATCH] fix: implemented fallback if inline-snapshot is used with pypy --- tests/requirements.txt | 2 +- tests/snapshot.py | 9 +++++++++ tests/validators/test_allow_partial.py | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tests/snapshot.py diff --git a/tests/requirements.txt b/tests/requirements.txt index 837128b5a..459605b71 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,7 +1,7 @@ backports.zoneinfo==0.2.1;python_version<"3.9" coverage==7.6.1 dirty-equals==0.8.0 -inline-snapshot==0.13.3 +inline-snapshot==0.13.3 ; implementation_name == "cpython" hypothesis==6.111.2 # pandas doesn't offer prebuilt wheels for all versions and platforms we test in CI e.g. aarch64 musllinux pandas==2.1.3; python_version >= "3.9" and python_version < "3.13" and implementation_name == "cpython" and platform_machine == 'x86_64' diff --git a/tests/snapshot.py b/tests/snapshot.py new file mode 100644 index 000000000..5a0b81361 --- /dev/null +++ b/tests/snapshot.py @@ -0,0 +1,9 @@ +import sys + +if sys.implementation.name == 'cpython': + from inline_snapshot import snapshot +else: + # inline-snapshot has currently no pypy support. + # This fallback allows snapshots to be used during pypy tests. + def snapshot(value): + return value diff --git a/tests/validators/test_allow_partial.py b/tests/validators/test_allow_partial.py index e147ff62d..2a1302e39 100644 --- a/tests/validators/test_allow_partial.py +++ b/tests/validators/test_allow_partial.py @@ -2,10 +2,11 @@ import pytest from dirty_equals import IsStrictDict -from inline_snapshot import snapshot from pydantic_core import SchemaValidator, ValidationError, core_schema +from ..snapshot import snapshot + def test_list(): v = SchemaValidator(