Skip to content

Defer server side imports in functional tests - #1496

Open
daviddavis wants to merge 1 commit into
pulp:mainfrom
daviddavis:fix-functional-test-django-import
Open

Defer server side imports in functional tests#1496
daviddavis wants to merge 1 commit into
pulp:mainfrom
daviddavis:fix-functional-test-django-import

Conversation

@daviddavis

@daviddavis daviddavis commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

The package signing tests imported AptPackageSigningService at module scope, which requires django.setup() to have run. That only happened as a side effect of the pytest-django plugin, which is declared in unittest_requirements.txt, so collection failed for anyone installing only functest_requirements.txt.

Route the signature check through a session fixture depending on django.setup(), which is how pulpcore initializes Django for functional tests. Adding pytest-django to functest_requirements.txt would also work, but it drags database fixtures into an HTTP only suite and makes Django mandatory for every functional test run.

Assisted-by: GitHub Copilot

@quba42

quba42 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Note: Adding pulp_rpm to my oci-env had the side effect of fixing my local test runs.

@daviddavis

Copy link
Copy Markdown
Contributor Author

In pulp_rpm there's a pytest entry point here that loads the constants file and in that constants file, they are calling django.setup().

@daviddavis

Copy link
Copy Markdown
Contributor Author

A couple alternatives to this change: call django.setup() at the top of the functional conftest (which is what pulp_rpm does), giving us a one-line fix that keeps the natural module-scope import, at the cost of making Django setup mandatory for every functional test run rather than just the signing tests. Or I could drop the server-side import entirely and reimplement the signature check in the functional test utils using python-gnupg, which is already in functest_requirements — that's roughly 30 lines of duplicated logic, but it removes the Django dependency from these tests completely and avoids the circularity of verifying the server's signing with the server's own verifier.

@daviddavis
daviddavis force-pushed the fix-functional-test-django-import branch from 2b19403 to e0a0bb6 Compare July 30, 2026 12:47
The package signing tests imported AptPackageSigningService at module scope,
which requires django.setup() to have run. That only happened as a side effect
of the pytest-django plugin, which is declared in unittest_requirements.txt, so
collection failed for anyone installing only functest_requirements.txt.

Route the signature check through a session fixture depending on
django.setup(), which is how pulpcore initializes Django for functional
tests. Adding pytest-django to functest_requirements.txt would also
work, but it drags database fixtures into an HTTP only suite and makes
Django mandatory for every functional test run.

Assisted-by: GitHub Copilot
@daviddavis
daviddavis force-pushed the fix-functional-test-django-import branch from e0a0bb6 to 58bc71a Compare July 31, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants