File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -514,3 +514,24 @@ def test_injection_config_validation_raises_pydantic_validation_error() -> None:
514514 with pytest .raises (ValidationError ):
515515 # Both required fields missing — pydantic must reject the construction.
516516 InjectedError () # type: ignore[call-arg]
517+
518+
519+ def test_packages_distributions_not_mocked_to_empty () -> None :
520+ """packages_distributions must return installed packages, not an empty mock."""
521+ distributions = importlib .metadata .packages_distributions ()
522+ assert 'pytest' in distributions , (
523+ 'packages_distributions() returned an empty mapping because it was'
524+ ' mocked globally in conftest.py.'
525+ )
526+
527+
528+ def test_vizier_service_not_prepopulated_with_mock_in_sys_modules () -> None :
529+ """sys.modules must not be prepopulated with MagicMock for vizier services."""
530+ import sys
531+ from unittest .mock import MagicMock
532+
533+ module = sys .modules .get ('google.cloud.aiplatform_v1.services.vizier_service' )
534+ assert module is None or not isinstance (module , MagicMock ), (
535+ 'google.cloud.aiplatform_v1.services.vizier_service was prepopulated with'
536+ ' a MagicMock in conftest.py.'
537+ )
You can’t perform that action at this time.
0 commit comments