Skip to content

Commit

Permalink
Turn a few verb-only pytest fixtures into standard functions
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
dralley committed Nov 21, 2023
1 parent f0569f4 commit 76133e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
26 changes: 8 additions & 18 deletions pulpcore/tests/functional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,6 @@ def _add_to_filesystem_cleanup(path):
pass


@pytest.fixture(scope="session")
def download_content_unit(bindings_cfg, pulp_domain_enabled):
def _download_content_unit(base_path, content_path, domain="default"):
async def _get_response(url):
Expand Down Expand Up @@ -1089,24 +1088,17 @@ async def _get_response(url):
return _download_content_unit


@pytest.fixture(scope="session")
def http_get():
def _http_get(url, **kwargs):
async def _send_request():
async with aiohttp.ClientSession(raise_for_status=True) as session:
async with session.get(url, **kwargs) as response:
return await response.content.read()

response = asyncio.run(_send_request())
return response
def http_get(url, **kwargs):
async def _send_request():
async with aiohttp.ClientSession(raise_for_status=True) as session:
async with session.get(url, **kwargs) as response:
return await response.content.read()

return _http_get
return asyncio.run(_send_request())


@pytest.fixture
def wget_recursive_download_on_host():
def _wget_recursive_download_on_host(url, destination):
subprocess.check_output(
def wget_recursive_download_on_host(url, destination):
return subprocess.check_output(
[
"wget",
"--recursive",
Expand All @@ -1118,8 +1110,6 @@ def _wget_recursive_download_on_host(url, destination):
]
)

return _wget_recursive_download_on_host


@pytest.fixture()
def domain_factory(domains_api_client, pulp_settings, gen_object_with_cleanup):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import pytest

from pulpcore.tests.functional.utils import http_get


@pytest.mark.parallel
def test_hidden_distros(file_distribution_factory, pulp_content_url, http_get):
def test_hidden_distros(file_distribution_factory, pulp_content_url):
visible = [file_distribution_factory() for _ in range(5)]
hidden = [file_distribution_factory(hidden=True) for _ in range(5)]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from urllib.parse import urljoin


from pulpcore.tests.functional.utils import get_from_url
from pulpcore.tests.functional.utils import get_from_url, http_get


@pytest.mark.parallel
Expand All @@ -14,7 +14,6 @@ def test_content_directory_listing(
gen_object_with_cleanup,
rbac_contentguard_api_client,
pulp_settings,
http_get,
pulp_status,
):
"""Checks that distributions are grouped by base-path when listing content directories."""
Expand Down

0 comments on commit 76133e0

Please sign in to comment.