From dff0d4548fdf13f31c48477597f222455063beaa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Wed, 13 Aug 2025 10:46:01 +0200
Subject: [PATCH] test: Make valkey optional for testing
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Make it possible to run the test suite without `valkey` package,
by moving the relevant imports out of the global `conftest.py` scope
into the spot where it is used.  This is helpful for downstreams
that currently do not package `valkey`.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 test/conftest.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/conftest.py b/test/conftest.py
index b6868f79..4ac9934e 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -3,7 +3,6 @@
 import pytest
 import pytest_asyncio
 import redis
-import valkey
 
 import fakeredis
 from fakeredis._server import _create_version
@@ -119,6 +118,8 @@ def factory(**kwargs: Any) -> redis.Redis:
             return cls(decode_responses=decode_responses, server=fake_server, lua_modules=lua_modules, **kwargs)
         # Real
         if valkey_client_test:
+            import valkey
+
             cls = getattr(valkey, cls_name)
         else:
             cls = getattr(redis, cls_name)
