# Path: tests/testapp/models.py
# class CharSetDefaultModel(Model):
#     field = SetCharField(
#         base_field=CharField(max_length=5),
#         size=5,
#         max_length=32,
#         default=lambda: {"a", "d"},
#     )
# 
# class CharSetModel(Model):
#     field = SetCharField(base_field=CharField(max_length=8), size=3, max_length=32)
#     field2 = SetCharField(base_field=CharField(max_length=8), max_length=255)
# 
# class IntSetModel(Model):
#     field = SetCharField(base_field=IntegerField(), size=5, max_length=32)


import json
import re
import pytest
from django import forms
from django.core import exceptions, serializers
from django.core.management import call_command
from django.db import connection, models
from django.db.migrations.writer import MigrationWriter
from django.db.models import Q, Value
from django.test import SimpleTestCase, TestCase, TransactionTestCase, override_settings
from django.test.utils import isolate_apps
from django_mysql.forms import SimpleSetField
from django_mysql.models import SetCharField, SetF
from django_mysql.test.utils import override_mysql_variables
from tests.testapp.models import CharSetDefaultModel, CharSetModel, IntSetModel

        errors = Invalid.check()
        assert len(errors) == 1
        assert errors[0].id == "django_mysql.E003"
        assert "Field can overrun" in errors[0].msg

    def test_max_length_missing_doesnt_crash(self):
        class Invalid(models.Model):
            field = SetCharField(models.CharField(max_length=2), size=2)

        errors = Invalid.check()
        assert len(errors) == 1
        assert errors[0].id == "fields.E120"
        assert errors[0].msg == "CharFields must define a 'max_length' attribute."


class TestDeconstruct(TestCase):
    def test_deconstruct(self):
        field = SetCharField(models.IntegerField(), max_length=32)
        name, path, args, kwargs = field.deconstruct()
        new = SetCharField(*args, **kwargs)
        assert new.base_field.__class__ == field.base_field.__class__

    def test_deconstruct_with_size(self):
        field = SetCharField(models.IntegerField(), size=3, max_length=32)
        name, path, args, kwargs = field.deconstruct()
        new = SetCharField(*args, **kwargs)
        assert new.size == field.size

    def test_deconstruct_args(self):

# Path: tests/testapp/models.py
# class CharSetDefaultModel(Model):
#     field = SetCharField(
#         base_field=CharField(max_length=5),
#         size=5,
#         max_length=32,
#         default=lambda: {"a", "d"},
#     )
# 
# class CharSetModel(Model):
#     field = SetCharField(base_field=CharField(max_length=8), size=3, max_length=32)
#     field2 = SetCharField(base_field=CharField(max_length=8), max_length=255)
# 
# class IntSetModel(Model):
#     field = SetCharField(base_field=IntegerField(), size=5, max_length=32)


# Path: tests/testapp/test_setcharfield.py
import json
import re
import pytest
from django import forms
from django.core import exceptions, serializers
from django.core.management import call_command
from django.db import connection, models
from django.db.migrations.writer import MigrationWriter
from django.db.models import Q, Value
from django.test import SimpleTestCase, TestCase, TransactionTestCase, override_settings
from django.test.utils import isolate_apps
from django_mysql.forms import SimpleSetField
from django_mysql.models import SetCharField, SetF
from django_mysql.test.utils import override_mysql_variables
from tests.testapp.models import CharSetDefaultModel, CharSetModel, IntSetModel


        errors = Invalid.check()
        assert len(errors) == 1
        assert errors[0].id == "django_mysql.E003"
        assert "Field can overrun" in errors[0].msg

    def test_max_length_missing_doesnt_crash(self):
        class Invalid(models.Model):
            field = SetCharField(models.CharField(max_length=2), size=2)

        errors = Invalid.check()
        assert len(errors) == 1
        assert errors[0].id == "fields.E120"
        assert errors[0].msg == "CharFields must define a 'max_length' attribute."


class TestDeconstruct(TestCase):
    def test_deconstruct(self):
        field = SetCharField(models.IntegerField(), max_length=32)
        name, path, args, kwargs = field.deconstruct()
        new = SetCharField(*args, **kwargs)
        assert new.base_field.__class__ == field.base_field.__class__

    def test_deconstruct_with_size(self):
        field = SetCharField(models.IntegerField(), size=3, max_length=32)
        name, path, args, kwargs = field.deconstruct()
        new = SetCharField(*args, **kwargs)
        assert new.size == field.size

    def test_deconstruct_args(self):

        field = SetCharField(models.CharField(max_length=5), max_length=32)