import unittest.mock import django.contrib.sites.models import pytest @pytest.fixture def mock_domain(): fake_site = django.contrib.sites.models.Site(domain="my.website", name="My Website") with unittest.mock.patch( "django.contrib.sites.models.SiteManager.get_current", return_value=fake_site, ): yield @pytest.fixture(autouse=True) def enable_db_access_for_all_tests(db): pass