Skip to content

Commit 90ed9a2

Browse files
authored
Removed pytest-lazy-fixture dependency (#200)
1 parent 8547e71 commit 90ed9a2

17 files changed

+180
-202
lines changed

poetry.lock

Lines changed: 1 addition & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ optional = true
119119
pytest = "^7.4.4"
120120
coverage = "^7.0.0"
121121
pytest-sugar = { version = "^1.0.0", python = ">=3.8,<4.0" }
122-
pytest-lazy-fixture = "^0.6.3"
123122
pytest-cov = "^4.0.0"
124123
pytest-xdist = "^3.1.0"
125124
pytest-subtests = "^0.11.0"
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
from __future__ import annotations
22

33
import pytest
4-
from pytest_lazyfixture import lazy_fixture
54

6-
from pytest_celery import CELERY_BACKEND
7-
from pytest_celery import CELERY_BACKEND_CLUSTER
85
from pytest_celery import CeleryBackendCluster
96
from pytest_celery import CeleryTestBackend
7+
from pytest_celery import CeleryTestCluster
8+
from pytest_celery import CeleryTestNode
9+
from tests.integration.api.test_base import BaseCluster
10+
from tests.integration.api.test_base import BaseNodes
1011

1112

12-
@pytest.mark.parametrize("backend", [lazy_fixture(CELERY_BACKEND)])
13-
class test_celey_test_backend:
14-
def test_app(self, backend: CeleryTestBackend):
15-
assert backend.app is None
13+
class test_celey_test_backend(BaseNodes):
14+
@pytest.fixture
15+
def node(self, celery_backend: CeleryTestBackend) -> CeleryTestNode:
16+
return celery_backend
1617

1718

18-
@pytest.mark.parametrize("cluster", [lazy_fixture(CELERY_BACKEND_CLUSTER)])
19-
class test_celery_backend_cluster:
20-
def test_app(self, cluster: CeleryBackendCluster):
21-
backend: CeleryTestBackend
22-
for backend in cluster:
23-
assert backend.app is None
24-
25-
def test_config(self, cluster: CeleryBackendCluster):
26-
expected_keys = {"urls", "host_urls"}
27-
assert set(cluster.config().keys()) == expected_keys
19+
class test_celery_backend_cluster(BaseCluster):
20+
@pytest.fixture
21+
def cluster(self, celery_backend_cluster: CeleryBackendCluster) -> CeleryTestCluster:
22+
return celery_backend_cluster

tests/integration/api/test_base.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
from __future__ import annotations
22

33
import pytest
4-
from pytest_lazyfixture import lazy_fixture
54

65
from pytest_celery import CeleryTestCluster
76
from pytest_celery import CeleryTestNode
87
from pytest_celery import RedisTestBackend
9-
from tests.defaults import ALL_CLUSTERS_FIXTURES
10-
from tests.defaults import ALL_NODES_FIXTURES
118

129

13-
@pytest.mark.parametrize("node", lazy_fixture(ALL_NODES_FIXTURES))
14-
class test_celery_test_node:
10+
class BaseNodes:
1511
def test_ready(self, node: CeleryTestNode):
1612
assert node.ready()
1713

14+
def test_app(self, node: CeleryTestNode):
15+
assert node.app is None
16+
1817
def test_logs(self, node: CeleryTestNode):
1918
node.logs()
2019

@@ -62,10 +61,18 @@ def test_assert_log_does_not_exist(self, node: CeleryTestNode):
6261
pass
6362

6463

65-
@pytest.mark.parametrize("cluster", lazy_fixture(ALL_CLUSTERS_FIXTURES))
66-
class test_celery_test_cluster:
64+
class BaseCluster:
6765
def test_ready(self, cluster: CeleryTestCluster):
6866
assert cluster.ready()
6967

7068
def test_teardown(self, cluster: CeleryTestCluster):
7169
cluster.teardown()
70+
71+
def test_app(self, cluster: CeleryTestCluster):
72+
node: CeleryTestNode
73+
for node in cluster:
74+
assert node.app is None
75+
76+
def test_config(self, cluster: CeleryTestCluster):
77+
expected_keys = {"urls", "host_urls"}
78+
assert set(cluster.config().keys()) == expected_keys
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
from __future__ import annotations
22

33
import pytest
4-
from pytest_lazyfixture import lazy_fixture
54

6-
from pytest_celery import CELERY_BROKER
7-
from pytest_celery import CELERY_BROKER_CLUSTER
85
from pytest_celery import CeleryBrokerCluster
96
from pytest_celery import CeleryTestBroker
7+
from pytest_celery import CeleryTestCluster
8+
from pytest_celery import CeleryTestNode
9+
from tests.integration.api.test_base import BaseCluster
10+
from tests.integration.api.test_base import BaseNodes
1011

1112

12-
@pytest.mark.parametrize("broker", [lazy_fixture(CELERY_BROKER)])
13-
class test_celery_test_broker:
14-
def test_app(self, broker: CeleryTestBroker):
15-
assert broker.app is None
13+
class test_celery_test_broker(BaseNodes):
14+
@pytest.fixture
15+
def node(self, celery_broker: CeleryTestBroker) -> CeleryTestNode:
16+
return celery_broker
1617

1718

18-
@pytest.mark.parametrize("cluster", [lazy_fixture(CELERY_BROKER_CLUSTER)])
19-
class test_celery_broker_cluster:
20-
def test_app(self, cluster: CeleryBrokerCluster):
21-
broker: CeleryTestBroker
22-
for broker in cluster:
23-
assert broker.app is None
24-
25-
def test_config(self, cluster: CeleryBrokerCluster):
26-
expected_keys = {"urls", "host_urls"}
27-
assert set(cluster.config().keys()) == expected_keys
19+
class test_celery_broker_cluster(BaseCluster):
20+
@pytest.fixture
21+
def cluster(self, celery_broker_cluster: CeleryBrokerCluster) -> CeleryTestCluster:
22+
return celery_broker_cluster

tests/integration/api/test_container.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
from __future__ import annotations
22

33
import pytest
4-
from pytest_lazyfixture import lazy_fixture
54

65
from pytest_celery import CeleryTestContainer
76
from tests.defaults import ALL_COMPONENTS_FIXTURES
87

98

10-
@pytest.mark.parametrize("container", lazy_fixture(ALL_COMPONENTS_FIXTURES))
9+
@pytest.fixture
10+
def container(request):
11+
return request.getfixturevalue(request.param)
12+
13+
14+
@pytest.mark.parametrize("container", ALL_COMPONENTS_FIXTURES, indirect=["container"])
1115
class test_celery_test_container:
1216
def test_client(self, container: CeleryTestContainer):
1317
assert container.client

tests/integration/api/test_worker.py

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,55 @@
22

33
import pytest
44
from celery import Celery
5-
from pytest_lazyfixture import lazy_fixture
65

7-
from pytest_celery import CELERY_WORKER
8-
from pytest_celery import CELERY_WORKER_CLUSTER
6+
from pytest_celery import CeleryTestCluster
7+
from pytest_celery import CeleryTestNode
98
from pytest_celery import CeleryTestWorker
109
from pytest_celery import CeleryWorkerCluster
1110
from pytest_celery import CeleryWorkerContainer
11+
from tests.integration.api.test_base import BaseCluster
12+
from tests.integration.api.test_base import BaseNodes
1213

1314

14-
@pytest.mark.parametrize("worker", [lazy_fixture(CELERY_WORKER)])
15-
class test_celey_test_worker:
16-
def test_app(self, worker: CeleryTestWorker, celery_setup_app: Celery):
17-
assert worker.app is celery_setup_app
15+
class test_celey_test_worker(BaseNodes):
16+
@pytest.fixture
17+
def node(self, celery_worker: CeleryTestWorker) -> CeleryTestNode:
18+
return celery_worker
1819

19-
def test_version(self, worker: CeleryTestWorker):
20-
assert worker.version == CeleryWorkerContainer.version()
20+
def test_app(self, celery_worker: CeleryTestWorker, celery_setup_app: Celery):
21+
assert celery_worker.app is celery_setup_app
2122

22-
def test_hostname(self, worker: CeleryTestWorker):
23-
hostname = worker.hostname()
23+
def test_version(self, celery_worker: CeleryTestWorker):
24+
assert celery_worker.version == CeleryWorkerContainer.version()
25+
26+
def test_hostname(self, celery_worker: CeleryTestWorker):
27+
hostname = celery_worker.hostname()
2428
assert "@" in hostname
25-
assert worker.worker_name in hostname.split("@")[0]
26-
assert worker.container.id[:12] in hostname.split("@")[1]
29+
assert celery_worker.worker_name in hostname.split("@")[0]
30+
assert celery_worker.container.id[:12] in hostname.split("@")[1]
31+
32+
def test_wait_for_log(self, celery_worker: CeleryTestWorker):
33+
log = f"{celery_worker.hostname()} v{celery_worker.version}"
34+
celery_worker.wait_for_log(log, "test_celey_test_worker.test_wait_for_log")
2735

28-
def test_wait_for_log(self, worker: CeleryTestWorker):
29-
log = f"{worker.hostname()} v{worker.version}"
30-
worker.wait_for_log(log, "test_celey_test_worker.test_wait_for_log")
36+
def test_assert_log_exists(self, celery_worker: CeleryTestWorker):
37+
log = f"{celery_worker.hostname()} v{celery_worker.version}"
38+
celery_worker.assert_log_exists(log, "test_celey_test_worker.test_assert_log_exists")
3139

32-
def test_assert_log_exists(self, worker: CeleryTestWorker):
33-
log = f"{worker.hostname()} v{worker.version}"
34-
worker.assert_log_exists(log, "test_celey_test_worker.test_assert_log_exists")
3540

41+
class test_celery_worker_cluster(BaseCluster):
42+
@pytest.fixture
43+
def cluster(self, celery_worker_cluster: CeleryWorkerCluster) -> CeleryTestCluster:
44+
return celery_worker_cluster
3645

37-
@pytest.mark.parametrize("cluster", [lazy_fixture(CELERY_WORKER_CLUSTER)])
38-
class test_celery_worker_cluster:
39-
def test_app(self, cluster: CeleryWorkerCluster, celery_setup_app: Celery):
46+
def test_app(self, celery_worker_cluster: CeleryWorkerCluster, celery_setup_app: Celery):
4047
worker: CeleryTestWorker
41-
for worker in cluster:
48+
for worker in celery_worker_cluster:
4249
assert worker.app is celery_setup_app
4350

44-
def test_config(self, cluster: CeleryWorkerCluster):
51+
def test_config(self, celery_worker_cluster: CeleryWorkerCluster):
4552
with pytest.raises(NotImplementedError):
46-
cluster.config()
53+
celery_worker_cluster.config()
4754

48-
def test_versions(self, cluster: CeleryWorkerCluster):
49-
assert cluster.versions == {CeleryWorkerContainer.version()}
55+
def test_versions(self, celery_worker_cluster: CeleryWorkerCluster):
56+
assert celery_worker_cluster.versions == {CeleryWorkerContainer.version()}

tests/integration/vendors/test_memcached.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
from __future__ import annotations
22

33
import pytest
4-
from pytest_lazyfixture import lazy_fixture
54

6-
from pytest_celery import CELERY_MEMCACHED_BACKEND
75
from pytest_celery import MemcachedContainer
86
from pytest_celery import MemcachedTestBackend
97
from tests.defaults import ALL_MEMCACHED_FIXTURES
108

119

12-
@pytest.mark.parametrize("container", lazy_fixture(ALL_MEMCACHED_FIXTURES))
10+
@pytest.fixture
11+
def container(request):
12+
return request.getfixturevalue(request.param)
13+
14+
15+
@pytest.mark.parametrize("container", ALL_MEMCACHED_FIXTURES, indirect=["container"])
1316
class test_memcached_container:
1417
def test_client(self, container: MemcachedContainer):
1518
assert container.client
@@ -26,10 +29,9 @@ def test_celeryconfig(self, container: MemcachedContainer):
2629
assert container.prefix() in config["host_url"]
2730

2831

29-
@pytest.mark.parametrize("backend", [lazy_fixture(CELERY_MEMCACHED_BACKEND)])
3032
class test_memcached_test_backend:
31-
def test_config(self, backend: MemcachedTestBackend):
33+
def test_config(self, celery_memcached_backend: MemcachedTestBackend):
3234
expected_keys = {"url", "host_url", "hostname", "port"}
33-
assert set(backend.config().keys()) == expected_keys
34-
assert backend.container.prefix() in backend.config()["url"]
35-
assert backend.container.prefix() in backend.config()["host_url"]
35+
assert set(celery_memcached_backend.config().keys()) == expected_keys
36+
assert celery_memcached_backend.container.prefix() in celery_memcached_backend.config()["url"]
37+
assert celery_memcached_backend.container.prefix() in celery_memcached_backend.config()["host_url"]

tests/integration/vendors/test_rabbitmq.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
import pytest
44
from kombu import Connection
5-
from pytest_lazyfixture import lazy_fixture
65

7-
from pytest_celery import CELERY_RABBITMQ_BROKER
86
from pytest_celery import RabbitMQContainer
97
from pytest_celery import RabbitMQTestBroker
108
from tests.defaults import ALL_RABBITMQ_FIXTURES
119

1210

13-
@pytest.mark.parametrize("container", lazy_fixture(ALL_RABBITMQ_FIXTURES))
11+
@pytest.fixture
12+
def container(request):
13+
return request.getfixturevalue(request.param)
14+
15+
16+
@pytest.mark.parametrize("container", ALL_RABBITMQ_FIXTURES, indirect=["container"])
1417
class test_rabbitmq_container:
1518
def test_client(self, container: RabbitMQContainer):
1619
c: Connection = container.client
@@ -28,10 +31,9 @@ def test_celeryconfig(self, container: RabbitMQContainer):
2831
assert container.prefix() in config["host_url"]
2932

3033

31-
@pytest.mark.parametrize("broker", [lazy_fixture(CELERY_RABBITMQ_BROKER)])
3234
class test_rabbitmq_test_broker:
33-
def test_config(self, broker: RabbitMQTestBroker):
35+
def test_config(self, celery_rabbitmq_broker: RabbitMQTestBroker):
3436
expected_keys = {"url", "host_url", "hostname", "port", "vhost"}
35-
assert set(broker.config().keys()) == expected_keys
36-
assert broker.container.prefix() in broker.config()["url"]
37-
assert broker.container.prefix() in broker.config()["host_url"]
37+
assert set(celery_rabbitmq_broker.config().keys()) == expected_keys
38+
assert celery_rabbitmq_broker.container.prefix() in celery_rabbitmq_broker.config()["url"]
39+
assert celery_rabbitmq_broker.container.prefix() in celery_rabbitmq_broker.config()["host_url"]
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
from __future__ import annotations
22

33
import pytest
4-
from pytest_lazyfixture import lazy_fixture
54

6-
from pytest_celery import CELERY_REDIS_BACKEND
7-
from pytest_celery import CELERY_REDIS_BROKER
85
from pytest_celery import RedisContainer
96
from pytest_celery import RedisTestBackend
107
from pytest_celery import RedisTestBroker
118
from tests.defaults import ALL_REDIS_FIXTURES
129

1310

14-
@pytest.mark.parametrize("container", lazy_fixture(ALL_REDIS_FIXTURES))
11+
@pytest.fixture
12+
def container(request):
13+
return request.getfixturevalue(request.param)
14+
15+
16+
@pytest.mark.parametrize("container", ALL_REDIS_FIXTURES, indirect=["container"])
1517
class test_redis_container:
1618
def test_client(self, container: RedisContainer):
1719
assert container.client
@@ -28,19 +30,17 @@ def test_celeryconfig(self, container: RedisContainer):
2830
assert container.prefix() in config["host_url"]
2931

3032

31-
@pytest.mark.parametrize("backend", [lazy_fixture(CELERY_REDIS_BACKEND)])
3233
class test_redis_test_backend:
33-
def test_config(self, backend: RedisTestBackend):
34+
def test_config(self, celery_redis_backend: RedisTestBackend):
3435
expected_keys = {"url", "host_url", "hostname", "port", "vhost"}
35-
assert set(backend.config().keys()) == expected_keys
36-
assert backend.container.prefix() in backend.config()["url"]
37-
assert backend.container.prefix() in backend.config()["host_url"]
36+
assert set(celery_redis_backend.config().keys()) == expected_keys
37+
assert celery_redis_backend.container.prefix() in celery_redis_backend.config()["url"]
38+
assert celery_redis_backend.container.prefix() in celery_redis_backend.config()["host_url"]
3839

3940

40-
@pytest.mark.parametrize("broker", [lazy_fixture(CELERY_REDIS_BROKER)])
4141
class test_redis_test_broker:
42-
def test_config(self, broker: RedisTestBroker):
42+
def test_config(self, celery_redis_broker: RedisTestBroker):
4343
expected_keys = {"url", "host_url", "hostname", "port", "vhost"}
44-
assert set(broker.config().keys()) == expected_keys
45-
assert broker.container.prefix() in broker.config()["url"]
46-
assert broker.container.prefix() in broker.config()["host_url"]
44+
assert set(celery_redis_broker.config().keys()) == expected_keys
45+
assert celery_redis_broker.container.prefix() in celery_redis_broker.config()["url"]
46+
assert celery_redis_broker.container.prefix() in celery_redis_broker.config()["host_url"]

0 commit comments

Comments
 (0)