def test_temp_writes(self): django_read_only.disable_writes() with django_read_only.temp_writes(): Site.objects.create(domain="example.org", name="Example org") with pytest.raises(django_read_only.DjangoReadOnlyError): Site.objects.create(domain="example.co", name="Example co")
def test_disable_writes_allows_atomics_around_reads(self): django_read_only.disable_writes() with transaction.atomic(): Site.objects.count()
def test_disable_writes_allows_newline_prefix(self): django_read_only.disable_writes() with connection.cursor() as cursor: cursor.execute("\nSELECT 1")
def test_disable_writes_allows_selects(self): django_read_only.disable_writes() Site.objects.count()
def test_disable_writes_allows_union(self): django_read_only.disable_writes() Site.objects.order_by().union(Site.objects.order_by()).count()