Repository: django/django
File: tests/admin_scripts/tests.py (Python)

Code before:
                "admin_scripts.complex_app",
                "admin_scripts.simple_app",
                "django.contrib.auth",
                "django.contrib.contenttypes",
            ]
        ):
            out = StringIO()
            call_command("duplicate", stdout=out)
            self.assertEqual(out.getvalue().strip(), "complex_app")
        with self.settings(
            INSTALLED_APPS=[
                "admin_scripts.simple_app",
                "admin_scripts.complex_app",
                "django.contrib.auth",
                "django.contrib.contenttypes",
            ]
        ):
            out = StringIO()
            call_command("duplicate", stdout=out)
            self.assertEqual(out.getvalue().strip(), "simple_app")


class CommandDBOptionChoiceTests(SimpleTestCase):
    def test_invalid_choice_db_option(self):
        # Update expected error based on Python version
        if PY314 and not PY315:
            # Python 3.14 includes suggestions
            expected_error = (
                r"Error: argument --database: invalid choice: 'deflaut', "
                r"maybe you meant 'default'\? \(choose from default, other\)"
            )
        else:
            # Python < 3.14 or >= 3.15
            expected_error = (
                r"Error: argument --database: invalid choice: 'deflaut' "
                r"\(choose from '?default'?, '?other'?\)"
            )
        args = [
            "changepassword",
            "createsuperuser",
            "remove_stale_contenttypes",
            "check",
            "createcachetable",
            "dbshell",
            "flush",
            "dumpdata",
            "inspectdb",
            "loaddata",
            "showmigrations",
            "sqlflush",
            "sqlmigrate",

Review comment (suggestion):
We're expecting this change in all versions after 3.14. 3.15 alpha 2 comes out tomorrow and should have this change. So please go ahead and update this.
```suggestion
        if PY314:
```

Code after:
                "admin_scripts.complex_app",
                "admin_scripts.simple_app",
                "django.contrib.auth",
                "django.contrib.contenttypes",
            ]
        ):
            out = StringIO()
            call_command("duplicate", stdout=out)
            self.assertEqual(out.getvalue().strip(), "complex_app")
        with self.settings(
            INSTALLED_APPS=[
                "admin_scripts.simple_app",
                "admin_scripts.complex_app",
                "django.contrib.auth",
                "django.contrib.contenttypes",
            ]
        ):
            out = StringIO()
            call_command("duplicate", stdout=out)
            self.assertEqual(out.getvalue().strip(), "simple_app")


class CommandDBOptionChoiceTests(SimpleTestCase):
    def test_invalid_choice_db_option(self):
        if PY314:
            expected_error = (
                r"Error: argument --database: invalid choice: 'deflaut', "
                r"maybe you meant 'default'\? \(choose from default, other\)"
            )
        else:
            expected_error = (
                r"Error: argument --database: invalid choice: 'deflaut' "
                r"\(choose from '?default'?, '?other'?\)"
            )
        args = [
            "changepassword",
            "createsuperuser",
            "remove_stale_contenttypes",
            "check",
            "createcachetable",
            "dbshell",
            "flush",
            "dumpdata",
            "inspectdb",
            "loaddata",
            "showmigrations",
            "sqlflush",
            "sqlmigrate",
            "sqlsequencereset",
            "migrate",
        ]