# Path: tests/testapp/models.py
# class EnumModel(Model):
#     field = EnumField(
#         choices=[
#             ("red", "Red"),
#             ("bloodred", "Blood Red"),
#             "green",
#             ("blue", "Navy Blue"),
#             ("coralblue", "Coral Blue"),
#         ]
#     )
# 
# class NullableEnumModel(Model):
#     field = EnumField(
#         choices=["goat", ("deer", "Deer"), "bull", "dog's"],  # Test if escaping works
#         null=True,
#     )


import pytest
from django.core.exceptions import ValidationError
from django.core.management import call_command
from django.db import connection
from django.db.utils import DataError
from django.test import TestCase, TransactionTestCase, override_settings
from django_mysql.models import EnumField
from tests.testapp.models import EnumModel, NullableEnumModel
        with pytest.raises(TypeError) as exc_info:
            EnumField(choices=["red", 10])  # type: ignore [list-item]
        assert 'Invalid choice "10"' in str(exc_info.value)

    def test_invalid_max_length(self):
        with pytest.raises(TypeError) as exc_info:
            EnumField(choices=["red"], max_length=100)
        assert '"max_length" is not a valid argument' in str(exc_info.value)

    def test_correct(self):
        s = EnumModel.objects.create(field="red")
        assert s.field == "red"
        s = EnumModel.objects.get(id=s.id)
        assert s.field == "red"

    def test_invalid_value(self):
        with pytest.raises(DataError):
            EnumModel.objects.create(field="elephant")

    def test_empty(self):
        with pytest.raises(DataError):
            EnumModel.objects.create()

    def test_null_storage(self):
        s = NullableEnumModel.objects.create()
        assert s.field is None
        s = NullableEnumModel.objects.get(id=s.id)
        assert s.field is None

    def test_isnull_lookup(self):

# Path: tests/testapp/models.py
# class EnumModel(Model):
#     field = EnumField(
#         choices=[
#             ("red", "Red"),
#             ("bloodred", "Blood Red"),
#             "green",
#             ("blue", "Navy Blue"),
#             ("coralblue", "Coral Blue"),
#         ]
#     )
# 
# class NullableEnumModel(Model):
#     field = EnumField(
#         choices=["goat", ("deer", "Deer"), "bull", "dog's"],  # Test if escaping works
#         null=True,
#     )


# Path: tests/testapp/test_enumfield.py
import pytest
from django.core.exceptions import ValidationError
from django.core.management import call_command
from django.db import connection
from django.db.utils import DataError
from django.test import TestCase, TransactionTestCase, override_settings
from django_mysql.models import EnumField
from tests.testapp.models import EnumModel, NullableEnumModel

        with pytest.raises(TypeError) as exc_info:
            EnumField(choices=["red", 10])  # type: ignore [list-item]
        assert 'Invalid choice "10"' in str(exc_info.value)

    def test_invalid_max_length(self):
        with pytest.raises(TypeError) as exc_info:
            EnumField(choices=["red"], max_length=100)
        assert '"max_length" is not a valid argument' in str(exc_info.value)

    def test_correct(self):
        s = EnumModel.objects.create(field="red")
        assert s.field == "red"
        s = EnumModel.objects.get(id=s.id)
        assert s.field == "red"

    def test_invalid_value(self):
        with pytest.raises(DataError):
            EnumModel.objects.create(field="elephant")

    def test_empty(self):
        with pytest.raises(DataError):
            EnumModel.objects.create()

    def test_null_storage(self):
        s = NullableEnumModel.objects.create()
        assert s.field is None
        s = NullableEnumModel.objects.get(id=s.id)
        assert s.field is None

    def test_isnull_lookup(self):

        NullableEnumModel.objects.create(field="goat")