mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-04 02:04:06 +00:00
22 lines
621 B
Python
22 lines
621 B
Python
from unittest import mock
|
|
|
|
import pytest
|
|
|
|
_MOCK_CLASSES = (
|
|
mock.Mock,
|
|
mock.MagicMock,
|
|
mock.AsyncMock,
|
|
mock.NonCallableMock,
|
|
mock.NonCallableMagicMock,
|
|
)
|
|
_MOCK_CLASS_BASELINE = {cls: frozenset(vars(cls)) for cls in _MOCK_CLASSES}
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _reset_mock_class_attributes():
|
|
"""Drop attributes a test sets on the mock classes themselves (`c = mock.MagicMock; c.provider = ...`), so they cannot leak into other tests' instances."""
|
|
yield
|
|
for cls, baseline in _MOCK_CLASS_BASELINE.items():
|
|
for name in set(vars(cls)) - baseline:
|
|
delattr(cls, name)
|