Repository navigation
Conversation
The s3 nightly unit suite began failing with ``AttributeError: 'S3Storage' object has no attribute 'location'``. ``test_fresh_namespace_rebuilds_incompatible_profile`` does ``monkeypatch.setattr(domain.get_storage(), "location", ...)`` on the default domain, which mutates Django's process-global ``default_storage`` (a ``LazyObject``). ``location`` lives in the wrapped ``S3Storage.__dict__`` but not in the ``LazyObject``'s own ``__dict__``, so pytest 9.2 (pytest-dev/pytest#10644) undoes the patch with ``delattr`` instead of restoring the value, deleting ``location`` from the shared storage. Since unit tests run sequentially, the next tests that call ``artifact.save()`` fail -- a collection-order dependent failure. Add ``pulp_maven/tests/unit/conftest.py`` with an autouse fixture that rebuilds ``default_storage`` before each test so storage state cannot leak between tests. Closes: pulp#566 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Defense-in-depth on top of the unit conftest reset: rather than mutating ``location`` on the shared ``default_storage`` instance (which the default domain returns and which pytest 9.2 fails to restore), patch ``Domain.get_storage`` to return a relocated read-only view of the storage. The patch is restored cleanly on teardown and never corrupts the shared instance, so the test no longer depends on collection order even without the conftest safety net. Ref: pulp#566 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
Author
|
Added a second commit with defense-in-depth on the root-cause test itself.
Verified against the real suite (moto-backed S3
The conftest reset stays as a general safety net so a future test can't reintroduce this class of leak. |
ggainey
approved these changes
Oct 30, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The nightly
test (s3)job started failing on 2026-10-28 (run 40624725849):Only the transitive dependency pytest changed between the last green run and the first red one (9.1.1 → 9.2.0); pulpcore, django and django-storages were identical.
Root cause
pytest 9.2.0 includes pytest#10644:
monkeypatch.setattr()now undoes a patch of an attribute that is not in the target instance's own__dict__withdelattrinstead of restoring the original value.test_fresh_namespace_rebuilds_incompatible_profiledoesmonkeypatch.setattr(domain.get_storage(), "location", ...)on thedefaultdomain.Domain.get_storage()fordefaultreturns Django's process-globaldefault_storage— aLazyObject.locationis stored in the wrappedS3Storage.__dict__(set in__init__), but not in theLazyObject's own__dict__, so pytest 9.2 tears the patch down withdelattr, which proxies through and permanently deleteslocationfrom the sharedS3Storage. Unit tests run sequentially, so the next tests that callartifact.save()raise inS3Storage._normalize_name. The failure is collection-order dependent, which is why only a subset of tests fail.Fix
Add
pulp_maven/tests/unit/conftest.pywith an autouse fixture that rebuildsdefault_storagebefore (and after) each test, so no test can inherit process-global storage state mutated by another. Resetting at setup is what makes it order-independent:monkeypatch's finalizer runs after an autouse fixture's, so a teardown-only reset would be masked.Verification
Reproduced and fixed against the real suite with a moto-backed S3
default_storage:Closes #566
🤖 Generated with Claude Code