Skip to content

Commit

Permalink
Ensure separate contexts for nameserver tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Jan 31, 2025
1 parent a93020c commit ab3b186
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions posttroll/tests/test_nameserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from unittest import mock

import pytest
import zmq

import posttroll.backends.zmq
from posttroll import config
from posttroll.backends.zmq.ns import create_nameserver_address
from posttroll.message import Message
Expand All @@ -18,6 +20,15 @@
from posttroll.subscriber import Subscribe


@pytest.fixture(autouse=True)
def new_context(monkeypatch):
"""Create a new context for each test."""
context = zmq.Context()
def get_context():
return context
monkeypatch.setattr(posttroll.backends.zmq, "get_context", get_context)


def free_port() -> int:
"""Get a free port.
Expand Down

0 comments on commit ab3b186

Please sign in to comment.