diff options
-rw-r--r-- | tests/conftest.py | 2 | ||||
-rw-r--r-- | tests/test_asyncio/conftest.py | 4 | ||||
-rw-r--r-- | tests/test_asyncio/test_timeseries.py | 2 | ||||
-rw-r--r-- | tests/test_timeseries.py | 3 |
4 files changed, 7 insertions, 4 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index e83c866..8a907cc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -139,6 +139,8 @@ def pytest_sessionstart(session): REDIS_INFO["arch_bits"] = arch_bits REDIS_INFO["cluster_enabled"] = cluster_enabled REDIS_INFO["enterprise"] = info["enterprise"] + # store REDIS_INFO in config so that it is available from "condition strings" + session.config.REDIS_INFO = REDIS_INFO # module info, if the second redis is running try: diff --git a/tests/test_asyncio/conftest.py b/tests/test_asyncio/conftest.py index b8b5583..52ff26b 100644 --- a/tests/test_asyncio/conftest.py +++ b/tests/test_asyncio/conftest.py @@ -39,14 +39,14 @@ async def _get_info(redis_url): pytest.param( (True, PythonParser), marks=pytest.mark.skipif( - REDIS_INFO["cluster_enabled"], reason="cluster mode enabled" + 'config.REDIS_INFO["cluster_enabled"]', reason="cluster mode enabled" ), ), (False, PythonParser), pytest.param( (True, HiredisParser), marks=pytest.mark.skipif( - not HIREDIS_AVAILABLE or REDIS_INFO["cluster_enabled"], + not HIREDIS_AVAILABLE or 'config.REDIS_INFO["cluster_enabled"]', reason="hiredis is not installed or cluster mode enabled", ), ), diff --git a/tests/test_asyncio/test_timeseries.py b/tests/test_asyncio/test_timeseries.py index 70ca6fd..ac2807f 100644 --- a/tests/test_asyncio/test_timeseries.py +++ b/tests/test_asyncio/test_timeseries.py @@ -73,7 +73,7 @@ async def test_add(modclient: redis.Redis): 4, 4, 2, retention_msecs=10, labels={"Redis": "Labs", "Time": "Series"} ) res = await modclient.ts().add(5, "*", 1) - assert round(time.time()) == round(float(res) / 1000) + assert abs(time.time() - round(float(res) / 1000)) < 1.0 info = await modclient.ts().info(4) assert 10 == info.retention_msecs diff --git a/tests/test_timeseries.py b/tests/test_timeseries.py index 421c9d5..7d42147 100644 --- a/tests/test_timeseries.py +++ b/tests/test_timeseries.py @@ -70,7 +70,8 @@ def test_add(client): assert 4 == client.ts().add( 4, 4, 2, retention_msecs=10, labels={"Redis": "Labs", "Time": "Series"} ) - assert round(time.time()) == round(float(client.ts().add(5, "*", 1)) / 1000) + + assert abs(time.time() - float(client.ts().add(5, "*", 1)) / 1000) < 1.0 info = client.ts().info(4) assert 10 == info.retention_msecs |