summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/extra_regress/models.py6
-rw-r--r--tests/forms_tests/tests/test_formsets.py4
-rw-r--r--tests/gis_tests/geos_tests/test_geos.py3
-rw-r--r--tests/gis_tests/test_data.py10
-rw-r--r--tests/i18n/tests.py4
-rw-r--r--tests/middleware/test_security.py20
-rw-r--r--tests/multiple_database/models.py6
-rw-r--r--tests/queries/test_qs_combinators.py6
-rw-r--r--tests/schema/fields.py17
-rw-r--r--tests/schema/tests.py4
-rw-r--r--tests/staticfiles_tests/cases.py3
11 files changed, 31 insertions, 52 deletions
diff --git a/tests/extra_regress/models.py b/tests/extra_regress/models.py
index b069affccd..3765601f7f 100644
--- a/tests/extra_regress/models.py
+++ b/tests/extra_regress/models.py
@@ -13,12 +13,10 @@ class RevisionableModel(models.Model):
def __str__(self):
return "%s (%s, %s)" % (self.title, self.id, self.base.id)
- def save(self, *args, **kwargs):
- super().save(*args, **kwargs)
+ def save(self, *args, force_insert=None, force_update=None, **kwargs):
+ super().save(*args, force_insert=force_insert, force_update=force_update, **kwargs)
if not self.base:
self.base = self
- kwargs.pop('force_insert', None)
- kwargs.pop('force_update', None)
super().save(*args, **kwargs)
def new_revision(self):
diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py
index 26d9e15605..f552f689dc 100644
--- a/tests/forms_tests/tests/test_formsets.py
+++ b/tests/forms_tests/tests/test_formsets.py
@@ -56,8 +56,8 @@ SplitDateTimeFormSet = formset_factory(SplitDateTimeForm)
class CustomKwargForm(Form):
- def __init__(self, *args, **kwargs):
- self.custom_kwarg = kwargs.pop('custom_kwarg')
+ def __init__(self, *args, custom_kwarg, **kwargs):
+ self.custom_kwarg = custom_kwarg
super().__init__(*args, **kwargs)
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py
index c90927c5cc..bb3341493c 100644
--- a/tests/gis_tests/geos_tests/test_geos.py
+++ b/tests/gis_tests/geos_tests/test_geos.py
@@ -1258,8 +1258,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
to the parent class during `__init__`.
"""
class ExtendedPolygon(Polygon):
- def __init__(self, *args, **kwargs):
- data = kwargs.pop('data', 0)
+ def __init__(self, *args, data=0, **kwargs):
super().__init__(*args, **kwargs)
self._data = data
diff --git a/tests/gis_tests/test_data.py b/tests/gis_tests/test_data.py
index adcd57b48b..c1e1f5efec 100644
--- a/tests/gis_tests/test_data.py
+++ b/tests/gis_tests/test_data.py
@@ -43,9 +43,8 @@ class TestDS(TestObj):
"""
Object for testing GDAL data sources.
"""
- def __init__(self, name, **kwargs):
+ def __init__(self, name, *, ext='shp', **kwargs):
# Shapefile is default extension, unless specified otherwise.
- ext = kwargs.pop('ext', 'shp')
self.ds = get_ds_file(name, ext)
super().__init__(**kwargs)
@@ -55,19 +54,14 @@ class TestGeom(TestObj):
Testing object used for wrapping reference geometry data
in GEOS/GDAL tests.
"""
- def __init__(self, **kwargs):
+ def __init__(self, *, coords=None, centroid=None, ext_ring_cs=None, **kwargs):
# Converting lists to tuples of certain keyword args
# so coordinate test cases will match (JSON has no
# concept of tuple).
- coords = kwargs.pop('coords', None)
if coords:
self.coords = tuplize(coords)
-
- centroid = kwargs.pop('centroid', None)
if centroid:
self.centroid = tuple(centroid)
-
- ext_ring_cs = kwargs.pop('ext_ring_cs', None)
if ext_ring_cs:
ext_ring_cs = tuplize(ext_ring_cs)
self.ext_ring_cs = ext_ring_cs
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index d2b878b435..9aa8821ef9 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -1388,10 +1388,6 @@ class UnprefixedDefaultLanguageTests(SimpleTestCase):
response = self.client.get('/simple/', HTTP_ACCEPT_LANGUAGE='fr')
self.assertEqual(response.content, b'Yes')
- def test_unexpected_kwarg_to_i18n_patterns(self):
- with self.assertRaisesMessage(AssertionError, "Unexpected kwargs for i18n_patterns(): {'foo':"):
- i18n_patterns(object(), foo='bar')
-
def test_page_with_dash(self):
# A page starting with /de* shouldn't match the 'de' langauge code.
response = self.client.get('/de-simple-page/')
diff --git a/tests/middleware/test_security.py b/tests/middleware/test_security.py
index b8e77f76e4..31a3dbb74c 100644
--- a/tests/middleware/test_security.py
+++ b/tests/middleware/test_security.py
@@ -13,19 +13,19 @@ class SecurityMiddlewareTest(SimpleTestCase):
def secure_request_kwargs(self):
return {"wsgi.url_scheme": "https"}
- def response(self, *args, **kwargs):
- headers = kwargs.pop("headers", {})
+ def response(self, *args, headers=None, **kwargs):
response = HttpResponse(*args, **kwargs)
- for k, v in headers.items():
- response[k] = v
+ if headers:
+ for k, v in headers.items():
+ response[k] = v
return response
- def process_response(self, *args, **kwargs):
+ def process_response(self, *args, secure=False, request=None, **kwargs):
request_kwargs = {}
- if kwargs.pop("secure", False):
+ if secure:
request_kwargs.update(self.secure_request_kwargs)
- request = (kwargs.pop("request", None) or
- self.request.get("/some/url", **request_kwargs))
+ if request is None:
+ request = self.request.get("/some/url", **request_kwargs)
ret = self.middleware.process_request(request)
if ret:
return ret
@@ -34,8 +34,8 @@ class SecurityMiddlewareTest(SimpleTestCase):
request = RequestFactory()
- def process_request(self, method, *args, **kwargs):
- if kwargs.pop("secure", False):
+ def process_request(self, method, *args, secure=False, **kwargs):
+ if secure:
kwargs.update(self.secure_request_kwargs)
req = getattr(self.request, method.lower())(*args, **kwargs)
return self.middleware.process_request(req)
diff --git a/tests/multiple_database/models.py b/tests/multiple_database/models.py
index 3e93bb67bc..14cb946f62 100644
--- a/tests/multiple_database/models.py
+++ b/tests/multiple_database/models.py
@@ -40,12 +40,10 @@ class Person(models.Model):
# calls. This argument is used to establish that the BookManager
# is actually getting used when it should be.
class BookManager(models.Manager):
- def create(self, *args, **kwargs):
- kwargs.pop('extra_arg', None)
+ def create(self, *args, extra_arg=None, **kwargs):
return super().create(*args, **kwargs)
- def get_or_create(self, *args, **kwargs):
- kwargs.pop('extra_arg', None)
+ def get_or_create(self, *args, extra_arg=None, **kwargs):
return super().get_or_create(*args, **kwargs)
diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py
index 0528f1c08d..bfb3d30825 100644
--- a/tests/queries/test_qs_combinators.py
+++ b/tests/queries/test_qs_combinators.py
@@ -42,12 +42,6 @@ class QuerySetSetOperationTests(TestCase):
self.assertEqual(len(list(qs1.union(qs2, all=True))), 20)
self.assertEqual(len(list(qs1.union(qs2))), 10)
- def test_union_bad_kwarg(self):
- qs1 = Number.objects.all()
- msg = "union() received an unexpected keyword argument 'bad'"
- with self.assertRaisesMessage(TypeError, msg):
- self.assertEqual(len(list(qs1.union(qs1, bad=True))), 20)
-
def test_limits(self):
qs1 = Number.objects.all()
qs2 = Number.objects.all()
diff --git a/tests/schema/fields.py b/tests/schema/fields.py
index 16a61ee5f6..f03b9813b6 100644
--- a/tests/schema/fields.py
+++ b/tests/schema/fields.py
@@ -13,23 +13,24 @@ class CustomManyToManyField(RelatedField):
"""
many_to_many = True
- def __init__(self, to, db_constraint=True, swappable=True, **kwargs):
+ def __init__(self, to, db_constraint=True, swappable=True, related_name=None, related_query_name=None,
+ limit_choices_to=None, symmetrical=None, through=None, through_fields=None, db_table=None, **kwargs):
try:
to._meta
except AttributeError:
to = str(to)
kwargs['rel'] = ManyToManyRel(
self, to,
- related_name=kwargs.pop('related_name', None),
- related_query_name=kwargs.pop('related_query_name', None),
- limit_choices_to=kwargs.pop('limit_choices_to', None),
- symmetrical=kwargs.pop('symmetrical', to == RECURSIVE_RELATIONSHIP_CONSTANT),
- through=kwargs.pop('through', None),
- through_fields=kwargs.pop('through_fields', None),
+ related_name=related_name,
+ related_query_name=related_query_name,
+ limit_choices_to=limit_choices_to,
+ symmetrical=symmetrical if symmetrical is not None else (to == RECURSIVE_RELATIONSHIP_CONSTANT),
+ through=through,
+ through_fields=through_fields,
db_constraint=db_constraint,
)
self.swappable = swappable
- self.db_table = kwargs.pop('db_table', None)
+ self.db_table = db_table
if kwargs['rel'].through is not None:
assert self.db_table is None, "Cannot specify a db_table if an intermediary model is used."
super().__init__(**kwargs)
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index d21f608e02..abcaa5b480 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -1819,9 +1819,9 @@ class SchemaTests(TransactionTestCase):
"""
#23065 - Constraint names must be quoted if they contain capital letters.
"""
- def get_field(*args, **kwargs):
+ def get_field(*args, field_class=IntegerField, **kwargs):
kwargs['db_column'] = "CamelCase"
- field = kwargs.pop('field_class', IntegerField)(*args, **kwargs)
+ field = field_class(*args, **kwargs)
field.set_attributes_from_name("CamelCase")
return field
diff --git a/tests/staticfiles_tests/cases.py b/tests/staticfiles_tests/cases.py
index 593739d401..81faf6d7d9 100644
--- a/tests/staticfiles_tests/cases.py
+++ b/tests/staticfiles_tests/cases.py
@@ -76,8 +76,7 @@ class CollectionTestCase(BaseStaticFilesMixin, SimpleTestCase):
self.patched_settings.disable()
super().tearDown()
- def run_collectstatic(self, **kwargs):
- verbosity = kwargs.pop('verbosity', 0)
+ def run_collectstatic(self, *, verbosity=0, **kwargs):
call_command('collectstatic', interactive=False, verbosity=verbosity,
ignore_patterns=['*.ignoreme'], **kwargs)