<commit_before>from django.test import TestCase
from django.test.client import RequestFactory
from django.contrib import admin
from django.contrib.admin.views.main import ChangeList
from django.contrib.auth.models import AnonymousUser

from django_countries import filters
from django_countries.tests import models

test_site = admin.AdminSite(name="test-admin")


class PersonAdmin(admin.ModelAdmin):
    list_filter = [("country", filters.CountryFilter)]


test_site.register(models.Person, PersonAdmin)


class TestCountryFilter(TestCase):
    def get_changelist_args(self, **kwargs):
        m = self.person_admin
        args = [
            kwargs.pop("list_display", m.list_display),
            kwargs.pop("list_display_links", m.list_display_links),
            kwargs.pop("list_filter", m.list_filter),
            kwargs.pop("date_hierarchy", m.date_hierarchy),
            kwargs.pop("search_fields", m.search_fields),
            kwargs.pop("list_select_related", m.list_select_related),
            kwargs.pop("list_per_page", m.list_per_page),
            kwargs.pop("list_max_show_all", m.list_max_show_all),
            kwargs.pop("list_editable", m.list_editable),
            m,
        ]
        args.append(kwargs.pop("sortable_by", m.sortable_by))
        assert not kwargs, "Unexpected kwarg %s" % kwargs
        return args

    def setUp(self):
        models.Person.objects.create(name="Alice", country="NZ")
        models.Person.objects.create(name="Bob", country="AU")
        models.Person.objects.create(name="Chris", country="NZ")
        self.person_admin = PersonAdmin(models.Person, test_site)<commit_msg>Tidy up get_changelist_args test function<commit_after>from django.test import TestCase
from django.test.client import RequestFactory
from django.contrib import admin
from django.contrib.admin.views.main import ChangeList
from django.contrib.auth.models import AnonymousUser

from django_countries import filters
from django_countries.tests import models

test_site = admin.AdminSite(name="test-admin")


class PersonAdmin(admin.ModelAdmin):
    list_filter = [("country", filters.CountryFilter)]


test_site.register(models.Person, PersonAdmin)


class TestCountryFilter(TestCase):
    def get_changelist_args(self, **kwargs):
        m = self.person_admin
        args = [
            kwargs.pop("list_display", m.list_display),
            kwargs.pop("list_display_links", m.list_display_links),
            kwargs.pop("list_filter", m.list_filter),
            kwargs.pop("date_hierarchy", m.date_hierarchy),
            kwargs.pop("search_fields", m.search_fields),
            kwargs.pop("list_select_related", m.list_select_related),
            kwargs.pop("list_per_page", m.list_per_page),
            kwargs.pop("list_max_show_all", m.list_max_show_all),
            kwargs.pop("list_editable", m.list_editable),
            m,
            kwargs.pop("sortable_by", m.sortable_by),
        ]
        assert not kwargs, "Unexpected kwarg %s" % kwargs
        return args

    def setUp(self):
        models.Person.objects.create(name="Alice", country="NZ")
        models.Person.objects.create(name="Bob", country="AU")
        models.Person.objects.create(name="Chris", country="NZ")
        self.person_admin = PersonAdmin(models.Person, test_site)
{'fraction_non_alphanumeric': 0.11333333333333333, 'fraction_numerical': 0.0, 'mean_word_length': 3.47289972899729, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6950404', 'n_tokens_mistral': 974, 'n_tokens_neox': 962, 'n_words': 175}