Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding unit test fixes to improve compatibility with MacOS. #3486

Merged
merged 4 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ services:
- all

redis-stack:
image: ${REDIS_STACK_IMAGE:-redis/redis-stack-server:edge}
image: ${REDIS_STACK_IMAGE:-redis/redis-stack-server:latest}
container_name: redis-stack
ports:
- 6479:6379
Expand All @@ -112,6 +112,7 @@ services:
profiles:
- standalone
- all-stack
- all

redis-stack-graph:
image: redis/redis-stack-server:6.2.6-v15
Expand Down
4 changes: 3 additions & 1 deletion tests/test_asyncio/test_connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import socket
import types
from errno import ECONNREFUSED
from unittest.mock import patch

import pytest
Expand Down Expand Up @@ -534,7 +535,8 @@ async def test_network_connection_failure():
with pytest.raises(ConnectionError) as e:
redis = Redis(host="127.0.0.1", port=9999)
await redis.set("a", "b")
assert str(e.value).startswith("Error 111 connecting to 127.0.0.1:9999. Connect")
expected_err = f"Error {ECONNREFUSED} connecting to 127.0.0.1:9999. Connect"
assert str(e.value).startswith(expected_err)
petyaslavova marked this conversation as resolved.
Show resolved Hide resolved


async def test_unix_socket_connection_failure():
Expand Down
7 changes: 6 additions & 1 deletion tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys
import threading
import types
from errno import ECONNREFUSED
from typing import Any
from unittest import mock
from unittest.mock import call, patch
Expand Down Expand Up @@ -352,7 +353,11 @@ def test_network_connection_failure():
with pytest.raises(ConnectionError) as e:
redis = Redis(port=9999)
redis.set("a", "b")
assert str(e.value) == "Error 111 connecting to localhost:9999. Connection refused."

assert (
str(e.value)
== f"Error {ECONNREFUSED} connecting to localhost:9999. Connection refused."
)


def test_unix_socket_connection_failure():
Expand Down
4 changes: 4 additions & 0 deletions tests/test_multiprocessing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import contextlib
import multiprocessing
import sys

import pytest
import redis
Expand All @@ -8,6 +9,9 @@

from .conftest import _get_client

if sys.platform == "darwin":
multiprocessing.set_start_method("fork", force=True)


@contextlib.contextmanager
def exit_callback(callback, *args):
Expand Down
Loading