Skip to content

Commit 3f75212

Browse files
committed
Make pytest-django fixture fix optional
1 parent 8fe89ec commit 3f75212

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

pulpcore/tests/functional/api/using_plugin/test_pagination.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,6 @@
33
import pytest
44

55

6-
@pytest.mark.parallel
7-
def test_debugging(
8-
file_bindings,
9-
file_content_unit_with_name_factory,
10-
file_repo,
11-
monitor_task,
12-
):
13-
i = 0
14-
content_unit = file_content_unit_with_name_factory(f"{i}.iso")
15-
file_bindings.RepositoriesFileApi.modify(
16-
file_repo.pulp_href, {"add_content_units": [content_unit.pulp_href]}
17-
).task
18-
19-
206
@pytest.mark.parallel
217
def test_repo_version_pagination(
228
file_bindings,

pulpcore/tests/functional/test_pubsub.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,26 @@
1313

1414

1515
@pytest.fixture(autouse=True)
16-
def django_connection_reset(django_db_blocker):
16+
def django_connection_reset(request):
1717
# django_db_blocker is from pytest-django. We don't want it to try to safeguard
1818
# us from using our functional Pulp instance.
1919
# https://pytest-django.readthedocs.io/en/latest/database.html#django-db-blocker
20-
django_db_blocker.unblock()
20+
pytest_django_installed = False
21+
try:
22+
django_db_blocker = request.getfixturevalue("django_db_blocker")
23+
django_db_blocker.unblock()
24+
pytest_django_installed = True
25+
except pytest.FixtureLookupError:
26+
pass
2127

2228
# If we dont' reset the connections we'll get interference between tests,
2329
# as listen/notify is connection based.
2430
from django.db import connections
2531

2632
connections.close_all()
2733
yield
28-
django_db_blocker.block()
34+
if pytest_django_installed:
35+
django_db_blocker.block()
2936

3037

3138
def test_postgres_pubsub():
@@ -61,7 +68,7 @@ class PubsubMessage(NamedTuple):
6168

6269

6370
@pytest.fixture
64-
def pubsub_backend(django_db_blocker):
71+
def pubsub_backend():
6572
from pulpcore.tasking import pubsub
6673

6774
return pubsub.PostgresPubSub

0 commit comments

Comments
 (0)