Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn a few verb-only pytest fixtures into standard functions #4763

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 18 additions & 28 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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want this to stop being a fixture. It is using other fixtures.

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,36 +1088,27 @@ 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

return _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()

return asyncio.run(_send_request())

@pytest.fixture
def wget_recursive_download_on_host():
def _wget_recursive_download_on_host(url, destination):
subprocess.check_output(
[
"wget",
"--recursive",
"--no-parent",
"--no-host-directories",
"--directory-prefix",
destination,
url,
]
)

return _wget_recursive_download_on_host
def wget_recursive_download_on_host(url, destination):
return subprocess.check_output(
[
"wget",
"--recursive",
"--no-parent",
"--no-host-directories",
"--directory-prefix",
destination,
url,
]
)


@pytest.fixture()
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