Skip to content

Commit a0fe6d2

Browse files
committed
Fixing deprecation warning in tests: @pytest.yield_fixture -> @pytest.fixture
1 parent 2464571 commit a0fe6d2

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

tests/client/internal_messaging/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from lightbus.utilities.internal_queue import InternalQueue
88

99

10-
@pytest.yield_fixture
10+
@pytest.fixture
1111
async def consumer():
1212
def _on_exception(e):
1313
raise e
@@ -17,7 +17,7 @@ def _on_exception(e):
1717
await consumer.close()
1818

1919

20-
@pytest.yield_fixture
20+
@pytest.fixture
2121
async def producer():
2222
def _on_exception(e):
2323
raise e

tests/client/test_validator_unit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
pytestmark = pytest.mark.unit
1414

1515

16-
@pytest.yield_fixture()
16+
@pytest.fixture()
1717
def create_bus_client_with_unhappy_schema(mocker, dummy_bus):
1818
"""Schema which always fails to validate"""
1919

tests/conftest.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async def redis_pool(create_redis_pool, loop):
176176
return await create_redis_pool()
177177

178178

179-
@pytest.yield_fixture
179+
@pytest.fixture
180180
async def redis_client(create_redis_client, loop):
181181
"""Returns Redis client instance."""
182182
redis = await create_redis_client()
@@ -206,7 +206,7 @@ async def _get_total_redis_connections():
206206
return _get_total_redis_connections
207207

208208

209-
@pytest.yield_fixture
209+
@pytest.fixture
210210
def _closable(loop):
211211
conns = []
212212

@@ -225,7 +225,7 @@ def _closable(loop):
225225
# Lightbus fixtures
226226

227227

228-
@pytest.yield_fixture
228+
@pytest.fixture
229229
def dummy_bus(loop, redis_server_url):
230230
# fmt: off
231231
dummy_bus = lightbus.creation.create(
@@ -255,7 +255,7 @@ def dummy_bus(loop, redis_server_url):
255255
pass
256256

257257

258-
@pytest.yield_fixture
258+
@pytest.fixture
259259
async def dummy_listener(dummy_bus: BusPath, loop):
260260
"""Start the dummy bus consuming events"""
261261
# TODO: Remove. Barely used any more
@@ -375,7 +375,7 @@ def dummy_api():
375375
return DummyApi()
376376

377377

378-
@pytest.yield_fixture
378+
@pytest.fixture
379379
def tmp_file():
380380
f = NamedTemporaryFile("r+", encoding="utf8")
381381
yield f
@@ -385,7 +385,7 @@ def tmp_file():
385385
pass
386386

387387

388-
@pytest.yield_fixture
388+
@pytest.fixture
389389
def tmp_directory():
390390
f = TemporaryDirectory()
391391
yield Path(f.name)
@@ -410,7 +410,7 @@ def _set_env(**environ):
410410
return _set_env
411411

412412

413-
@pytest.yield_fixture
413+
@pytest.fixture
414414
def make_test_bus_module():
415415
"""Create a python module on disk which contains a bus, and put it on the python path"""
416416
created_modules = []
@@ -554,7 +554,7 @@ class Meta:
554554
"""
555555

556556

557-
@pytest.yield_fixture()
557+
@pytest.fixture()
558558
async def redis_config_file(loop, redis_server_url, redis_client):
559559
config = REDIS_BUS_CONFIG.format(redis_url=redis_server_url)
560560
with NamedTemporaryFile() as f:
@@ -564,15 +564,15 @@ async def redis_config_file(loop, redis_server_url, redis_client):
564564
await redis_client.execute(b"CLIENT", b"KILL", b"TYPE", b"NORMAL")
565565

566566

567-
@pytest.yield_fixture()
567+
@pytest.fixture()
568568
def debug_config_file():
569569
with NamedTemporaryFile() as f:
570570
f.write(DEBUG_BUS_CONFIG.encode("utf8"))
571571
f.flush()
572572
yield f.name
573573

574574

575-
@pytest.yield_fixture()
575+
@pytest.fixture()
576576
def run_lightbus_command(make_test_bus_module, redis_config_file):
577577
processes = []
578578

@@ -658,7 +658,7 @@ def queue_mocker() -> Type[BusQueueMockerContext]:
658658
return BusQueueMockerContext
659659

660660

661-
@pytest.yield_fixture()
661+
@pytest.fixture()
662662
def error_queue():
663663
queue = InternalQueue()
664664
yield queue
@@ -705,7 +705,7 @@ async def worker_context(bus):
705705
return worker_context(bus)
706706

707707

708-
@pytest.yield_fixture
708+
@pytest.fixture
709709
async def worker(new_bus):
710710
yield Worker(bus_factory=new_bus)
711711

@@ -803,7 +803,7 @@ def _docker_available():
803803
return docker_cmd.returncode == 0
804804

805805

806-
@pytest.yield_fixture
806+
@pytest.fixture
807807
def standalone_redis_server():
808808
if not _docker_available():
809809
raise pytest.skip("Docker not available")

tests/test_testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
pytestmark = pytest.mark.unit
99

1010

11-
@pytest.yield_fixture
11+
@pytest.fixture
1212
def mock_result(dummy_bus):
1313
with BusQueueMockerContext(dummy_bus) as mocker_context:
1414
yield testing.MockResult(mocker_context, mock_responses={}, mock_events=set())

tests/transports/redis/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def redis_result_transport(new_redis_pool, loop):
2929
)
3030

3131

32-
@pytest.yield_fixture
32+
@pytest.fixture
3333
async def redis_event_transport(new_redis_pool, loop):
3434
transport = lightbus.transports.redis.event.RedisEventTransport(
3535
redis_pool=await new_redis_pool(maxsize=10000),
@@ -49,7 +49,7 @@ async def redis_schema_transport(new_redis_pool, loop):
4949
)
5050

5151

52-
@pytest.yield_fixture
52+
@pytest.fixture
5353
async def bus(new_bus):
5454
bus = new_bus()
5555

tests/transports/test_pool.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
pytestmark = pytest.mark.unit
2323

2424

25-
@pytest.yield_fixture()
25+
@pytest.fixture()
2626
async def dummy_pool():
2727
pool = TransportPool(
2828
transport_class=DebugEventTransport,
@@ -33,7 +33,7 @@ async def dummy_pool():
3333
await pool.close()
3434

3535

36-
@pytest.yield_fixture()
36+
@pytest.fixture()
3737
async def redis_pool(redis_server_url):
3838
pool = TransportPool(
3939
transport_class=RedisEventTransport,
@@ -44,7 +44,7 @@ async def redis_pool(redis_server_url):
4444
await pool.close()
4545

4646

47-
@pytest.yield_fixture()
47+
@pytest.fixture()
4848
async def attr_test_pool(redis_server_url):
4949
"""Used for testing attribute access only"""
5050

@@ -69,7 +69,7 @@ async def _async_private_method(self):
6969
await pool.close()
7070

7171

72-
@pytest.yield_fixture()
72+
@pytest.fixture()
7373
def run_in_many_threads():
7474
def run_in_many_threads_(async_fn, max_workers=50, executions=200, *args, **kwargs):
7575
with ThreadPoolExecutor(max_workers=max_workers) as e:

0 commit comments

Comments
 (0)