Skip to content

Commit 35ded54

Browse files
caspervonbwallyqs
authored andcommitted
Changes import of testing server into nats.testing.server
Adds nkeys, aiohttp, aiofiles as development deps CI updates to handle some older versions Signed-off-by: Waldemar Quevedo <[email protected]>
1 parent 8540b72 commit 35ded54

File tree

16 files changed

+3133
-531
lines changed

16 files changed

+3133
-531
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Run tests
4444
run: |
4545
uv run flake8 --ignore="W391, W503, W504, E501" ./nats/src/nats/js/
46-
uv run pytest -x -vv -s --continue-on-collection-errors ./nats/tests
46+
uv run pytest -x -vv -s --continue-on-collection-errors ./nats/tests --ignore=nats/tests/testing_server
4747
env:
4848
PATH: $HOME/nats-server:$PATH
4949

@@ -55,7 +55,6 @@ jobs:
5555
python-version: ["3.11", "3.12", "3.13"]
5656
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
5757
nats-server-version: ["latest"]
58-
project: ["nats-server"]
5958
steps:
6059
- name: Checkout repository
6160
uses: actions/checkout@v5
@@ -80,8 +79,6 @@ jobs:
8079

8180
- name: Install dependencies
8281
run: uv sync --dev
83-
working-directory: ${{ matrix.project }}
8482

8583
- name: Run tests for ${{ matrix.project }}
86-
run: uv run pytest -v -n auto
87-
working-directory: ${{ matrix.project }}
84+
run: uv run pytest nats/tests/testing_server -x -s -v -n auto

nats-server/.DS_Store

-6 KB
Binary file not shown.

nats-server/README.md

Lines changed: 0 additions & 43 deletions
This file was deleted.

nats-server/pyproject.toml

Lines changed: 0 additions & 40 deletions
This file was deleted.

nats-server/tests/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

nats/src/nats/testing/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Testing utilities for NATS."""

nats-server/src/nats/server/__init__.py renamed to nats/src/nats/testing/server/__init__.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@
2424
import os
2525
import re
2626
import socket
27-
import tempfile
28-
from typing import Self
27+
import sys
28+
29+
if sys.version_info >= (3, 11):
30+
from typing import Self
31+
else:
32+
from typing_extensions import Self
2933

3034
# Set up logging
3135
logger = logging.getLogger(__name__)
@@ -122,13 +126,12 @@ def client_url(self) -> str:
122126
The connect URL as a string.
123127
"""
124128
# Replace bind-all addresses with loopback addresses
125-
match self._host:
126-
case "0.0.0.0":
127-
host = "127.0.0.1"
128-
case "::":
129-
host = "::1"
130-
case _:
131-
host = self._host
129+
if self._host == "0.0.0.0":
130+
host = "127.0.0.1"
131+
elif self._host == "::":
132+
host = "::1"
133+
else:
134+
host = self._host
132135

133136
# Wrap IPv6 addresses in brackets for URL formatting
134137
if ":" in host:
@@ -277,7 +280,8 @@ async def wait_ready() -> tuple[str, int]:
277280
assert port is not None
278281
return host, port
279282

280-
if match := LISTENING_PATTERN.search(stderr_line):
283+
match = LISTENING_PATTERN.search(stderr_line)
284+
if match:
281285
host_part = match.group(1)
282286
if host_part.startswith('[') and host_part.endswith(']'):
283287
host = host_part[1:-1]
@@ -288,7 +292,8 @@ async def wait_ready() -> tuple[str, int]:
288292
if INFO_PATTERN.search(stderr_line):
289293
continue
290294

291-
if match := FATAL_PATTERN.search(stderr_line):
295+
match = FATAL_PATTERN.search(stderr_line)
296+
if match:
292297
error_lines.append(match.group(1))
293298

294299
error_lines.append(stderr_line)

nats/tests/conf/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ COPY . /usr/src/nats.py
66
# Install uv
77
RUN pip install uv
88
RUN uv sync --dev
9+
910
RUN uv run pytest nats/tests/test_compatibility.py --collect-only -v
1011

1112
ENV NATS_URL=nats://localhost:4222
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Test package for NATS Server"""

0 commit comments

Comments
 (0)