-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
38 lines (27 loc) · 759 Bytes
/
conftest.py
File metadata and controls
38 lines (27 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
from collections.abc import AsyncGenerator
import pytest
from natsrpy import Nats
from natsrpy.js import JetStream
@pytest.fixture(scope="session")
def anyio_backend() -> str:
"""
Anyio backend.
Backend for anyio pytest plugin.
:return: backend name.
"""
return "asyncio"
@pytest.fixture(scope="session")
def nats_url() -> str:
return os.environ.get("NATS_URL", "localhost:4222")
@pytest.fixture(scope="session")
async def nats(nats_url: str) -> AsyncGenerator[Nats, None]:
nats = Nats(addrs=[nats_url])
await nats.startup()
try:
yield nats
finally:
await nats.shutdown()
@pytest.fixture(scope="session")
async def js(nats: Nats) -> JetStream:
return await nats.jetstream()