summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Chaumeny <thomas.chaumeny@polyconseil.fr>2014-09-26 14:31:50 +0200
committerLoic Bistuer <loic.bistuer@gmail.com>2014-09-29 00:01:38 +0700
commitb2aad7b836bfde012756cca69291c14d2fdbd334 (patch)
tree53c93f9804075ed347d6d83718d37f7dc2a06340 /tests
parentcaf5cd7ba7c9d73194e394a26c81f1a677d54a6c (diff)
Replaced set([foo, ...]) by {foo, ...} literals. Refs PR 3282.
Thanks Collin Anderson for the review.
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_filters/tests.py4
-rw-r--r--tests/basic/tests.py2
-rw-r--r--tests/cache/tests.py16
-rw-r--r--tests/file_storage/tests.py4
-rw-r--r--tests/introspection/tests.py6
-rw-r--r--tests/known_related_objects/tests.py6
-rw-r--r--tests/lookup/tests.py2
-rw-r--r--tests/migrations/test_autodetector.py26
-rw-r--r--tests/migrations/test_loader.py2
-rw-r--r--tests/migrations/test_state.py2
-rw-r--r--tests/migrations/test_writer.py4
-rw-r--r--tests/prefetch_related/tests.py6
-rw-r--r--tests/queries/tests.py34
-rw-r--r--tests/requests/tests.py2
-rw-r--r--tests/test_client_regress/tests.py4
-rw-r--r--tests/utils_tests/test_lazyobject.py2
16 files changed, 61 insertions, 61 deletions
diff --git a/tests/admin_filters/tests.py b/tests/admin_filters/tests.py
index a0149b07c3..dcd4236776 100644
--- a/tests/admin_filters/tests.py
+++ b/tests/admin_filters/tests.py
@@ -91,11 +91,11 @@ class DepartmentListFilterLookupWithNonStringValue(SimpleListFilter):
parameter_name = 'department'
def lookups(self, request, model_admin):
- return sorted(set([
+ return sorted({
(employee.department.id, # Intentionally not a string (Refs #19318)
employee.department.code)
for employee in model_admin.get_queryset(request).all()
- ]))
+ })
def queryset(self, request, queryset):
if self.value():
diff --git a/tests/basic/tests.py b/tests/basic/tests.py
index 356551cc52..3dc3c3ba56 100644
--- a/tests/basic/tests.py
+++ b/tests/basic/tests.py
@@ -429,7 +429,7 @@ class ModelTest(TestCase):
pub_date=datetime(2008, 12, 31, 23, 59, 59, 999999),
)
- s = set([a10, a11, a12])
+ s = {a10, a11, a12}
self.assertTrue(Article.objects.get(headline='Article 11') in s)
def test_field_ordering(self):
diff --git a/tests/cache/tests.py b/tests/cache/tests.py
index 4677791fcd..926136a587 100644
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -1422,16 +1422,16 @@ class CacheUtils(TestCase):
def test_patch_cache_control(self):
tests = (
# Initial Cache-Control, kwargs to patch_cache_control, expected Cache-Control parts
- (None, {'private': True}, set(['private'])),
+ (None, {'private': True}, {'private'}),
# Test whether private/public attributes are mutually exclusive
- ('private', {'private': True}, set(['private'])),
- ('private', {'public': True}, set(['public'])),
- ('public', {'public': True}, set(['public'])),
- ('public', {'private': True}, set(['private'])),
- ('must-revalidate,max-age=60,private', {'public': True}, set(['must-revalidate', 'max-age=60', 'public'])),
- ('must-revalidate,max-age=60,public', {'private': True}, set(['must-revalidate', 'max-age=60', 'private'])),
- ('must-revalidate,max-age=60', {'public': True}, set(['must-revalidate', 'max-age=60', 'public'])),
+ ('private', {'private': True}, {'private'}),
+ ('private', {'public': True}, {'public'}),
+ ('public', {'public': True}, {'public'}),
+ ('public', {'private': True}, {'private'}),
+ ('must-revalidate,max-age=60,private', {'public': True}, {'must-revalidate', 'max-age=60', 'public'}),
+ ('must-revalidate,max-age=60,public', {'private': True}, {'must-revalidate', 'max-age=60', 'private'}),
+ ('must-revalidate,max-age=60', {'public': True}, {'must-revalidate', 'max-age=60', 'public'}),
)
cc_delim_re = re.compile(r'\s*,\s*')
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
index 262603c24a..4e6fe869a1 100644
--- a/tests/file_storage/tests.py
+++ b/tests/file_storage/tests.py
@@ -281,9 +281,9 @@ class FileStorageTests(unittest.TestCase):
os.mkdir(os.path.join(self.temp_dir, 'storage_dir_1'))
dirs, files = self.storage.listdir('')
- self.assertEqual(set(dirs), set(['storage_dir_1']))
+ self.assertEqual(set(dirs), {'storage_dir_1'})
self.assertEqual(set(files),
- set(['storage_test_1', 'storage_test_2']))
+ {'storage_test_1', 'storage_test_2'})
self.storage.delete('storage_test_1')
self.storage.delete('storage_test_2')
diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py
index 59e0fc60ee..9fc99589a8 100644
--- a/tests/introspection/tests.py
+++ b/tests/introspection/tests.py
@@ -55,7 +55,7 @@ class IntrospectionTests(TestCase):
def test_installed_models(self):
tables = [Article._meta.db_table, Reporter._meta.db_table]
models = connection.introspection.installed_models(tables)
- self.assertEqual(models, set([Article, Reporter]))
+ self.assertEqual(models, {Article, Reporter})
def test_sequence_list(self):
sequences = connection.introspection.sequence_list()
@@ -129,8 +129,8 @@ class IntrospectionTests(TestCase):
key_columns = connection.introspection.get_key_columns(cursor, Article._meta.db_table)
self.assertEqual(
set(key_columns),
- set([('reporter_id', Reporter._meta.db_table, 'id'),
- ('response_to_id', Article._meta.db_table, 'id')]))
+ {('reporter_id', Reporter._meta.db_table, 'id'),
+ ('response_to_id', Article._meta.db_table, 'id')})
def test_get_primary_key_column(self):
with connection.cursor() as cursor:
diff --git a/tests/known_related_objects/tests.py b/tests/known_related_objects/tests.py
index 03307f49ac..f7ac18c981 100644
--- a/tests/known_related_objects/tests.py
+++ b/tests/known_related_objects/tests.py
@@ -34,7 +34,7 @@ class ExistingRelatedInstancesTests(TestCase):
with self.assertNumQueries(1):
pools = tournament_1.pool_set.all() | tournament_2.pool_set.all()
related_objects = set(pool.tournament for pool in pools)
- self.assertEqual(related_objects, set((tournament_1, tournament_2)))
+ self.assertEqual(related_objects, {tournament_1, tournament_2})
def test_queryset_or_different_cached_items(self):
tournament = Tournament.objects.get(pk=1)
@@ -52,12 +52,12 @@ class ExistingRelatedInstancesTests(TestCase):
with self.assertNumQueries(2):
pools = tournament_1.pool_set.all() | Pool.objects.filter(pk=3)
related_objects = set(pool.tournament for pool in pools)
- self.assertEqual(related_objects, set((tournament_1, tournament_2)))
+ self.assertEqual(related_objects, {tournament_1, tournament_2})
# and the other direction
with self.assertNumQueries(2):
pools = Pool.objects.filter(pk=3) | tournament_1.pool_set.all()
related_objects = set(pool.tournament for pool in pools)
- self.assertEqual(related_objects, set((tournament_1, tournament_2)))
+ self.assertEqual(related_objects, {tournament_1, tournament_2})
def test_queryset_and(self):
tournament = Tournament.objects.get(pk=1)
diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py
index 6744314625..8dabfb2c18 100644
--- a/tests/lookup/tests.py
+++ b/tests/lookup/tests.py
@@ -114,7 +114,7 @@ class LookupTests(TestCase):
self.assertEqual(arts[self.a1.id], self.a1)
self.assertEqual(arts[self.a2.id], self.a2)
self.assertEqual(Article.objects.in_bulk([self.a3.id]), {self.a3.id: self.a3})
- self.assertEqual(Article.objects.in_bulk(set([self.a3.id])), {self.a3.id: self.a3})
+ self.assertEqual(Article.objects.in_bulk({self.a3.id}), {self.a3.id: self.a3})
self.assertEqual(Article.objects.in_bulk(frozenset([self.a3.id])), {self.a3.id: self.a3})
self.assertEqual(Article.objects.in_bulk((self.a3.id,)), {self.a3.id: self.a3})
self.assertEqual(Article.objects.in_bulk([1000]), {})
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
index 991eb5403d..4138d859d1 100644
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -73,9 +73,9 @@ class AutodetectorTests(TestCase):
book_with_field_and_author_renamed = ModelState("otherapp", "Book", [("id", models.AutoField(primary_key=True)), ("writer", models.ForeignKey("testapp.Writer")), ("title", models.CharField(max_length=200))])
book_with_multiple_authors = ModelState("otherapp", "Book", [("id", models.AutoField(primary_key=True)), ("authors", models.ManyToManyField("testapp.Author")), ("title", models.CharField(max_length=200))])
book_with_multiple_authors_through_attribution = ModelState("otherapp", "Book", [("id", models.AutoField(primary_key=True)), ("authors", models.ManyToManyField("testapp.Author", through="otherapp.Attribution")), ("title", models.CharField(max_length=200))])
- book_unique = ModelState("otherapp", "Book", [("id", models.AutoField(primary_key=True)), ("author", models.ForeignKey("testapp.Author")), ("title", models.CharField(max_length=200))], {"unique_together": set([("author", "title")])})
- book_unique_2 = ModelState("otherapp", "Book", [("id", models.AutoField(primary_key=True)), ("author", models.ForeignKey("testapp.Author")), ("title", models.CharField(max_length=200))], {"unique_together": set([("title", "author")])})
- book_unique_3 = ModelState("otherapp", "Book", [("id", models.AutoField(primary_key=True)), ("newfield", models.IntegerField()), ("author", models.ForeignKey("testapp.Author")), ("title", models.CharField(max_length=200))], {"unique_together": set([("title", "newfield")])})
+ book_unique = ModelState("otherapp", "Book", [("id", models.AutoField(primary_key=True)), ("author", models.ForeignKey("testapp.Author")), ("title", models.CharField(max_length=200))], {"unique_together": {("author", "title")}})
+ book_unique_2 = ModelState("otherapp", "Book", [("id", models.AutoField(primary_key=True)), ("author", models.ForeignKey("testapp.Author")), ("title", models.CharField(max_length=200))], {"unique_together": {("title", "author")}})
+ book_unique_3 = ModelState("otherapp", "Book", [("id", models.AutoField(primary_key=True)), ("newfield", models.IntegerField()), ("author", models.ForeignKey("testapp.Author")), ("title", models.CharField(max_length=200))], {"unique_together": {("title", "newfield")}})
attribution = ModelState("otherapp", "Attribution", [("id", models.AutoField(primary_key=True)), ("author", models.ForeignKey("testapp.Author")), ("book", models.ForeignKey("otherapp.Book"))])
edition = ModelState("thirdapp", "Edition", [("id", models.AutoField(primary_key=True)), ("book", models.ForeignKey("otherapp.Book"))])
custom_user = ModelState("thirdapp", "CustomUser", [("id", models.AutoField(primary_key=True)), ("username", models.CharField(max_length=255))], bases=(AbstractBaseUser, ))
@@ -85,7 +85,7 @@ class AutodetectorTests(TestCase):
aardvark_based_on_author = ModelState("testapp", "Aardvark", [], bases=("testapp.Author", ))
aardvark_pk_fk_author = ModelState("testapp", "Aardvark", [("id", models.OneToOneField("testapp.Author", primary_key=True))])
knight = ModelState("eggs", "Knight", [("id", models.AutoField(primary_key=True))])
- rabbit = ModelState("eggs", "Rabbit", [("id", models.AutoField(primary_key=True)), ("knight", models.ForeignKey("eggs.Knight")), ("parent", models.ForeignKey("eggs.Rabbit"))], {"unique_together": set([("parent", "knight")])})
+ rabbit = ModelState("eggs", "Rabbit", [("id", models.AutoField(primary_key=True)), ("knight", models.ForeignKey("eggs.Knight")), ("parent", models.ForeignKey("eggs.Rabbit"))], {"unique_together": {("parent", "knight")}})
def repr_changes(self, changes):
output = ""
@@ -187,7 +187,7 @@ class AutodetectorTests(TestCase):
graph = MigrationGraph()
changes = autodetector.arrange_for_graph(changes, graph)
changes["testapp"][0].dependencies.append(("otherapp", "0001_initial"))
- changes = autodetector._trim_to_apps(changes, set(["testapp"]))
+ changes = autodetector._trim_to_apps(changes, {"testapp"})
# Make sure there's the right set of migrations
self.assertEqual(changes["testapp"][0].name, "0001_initial")
self.assertEqual(changes["otherapp"][0].name, "0001_initial")
@@ -466,7 +466,7 @@ class AutodetectorTests(TestCase):
# Right dependencies?
self.assertEqual(changes['testapp'][0].dependencies, [("otherapp", "auto_1")])
self.assertEqual(changes['otherapp'][0].dependencies, [])
- self.assertEqual(set(changes['otherapp'][1].dependencies), set([("otherapp", "auto_1"), ("testapp", "auto_1")]))
+ self.assertEqual(set(changes['otherapp'][1].dependencies), {("otherapp", "auto_1"), ("testapp", "auto_1")})
def test_same_app_circular_fk_dependency(self):
"""
@@ -522,7 +522,7 @@ class AutodetectorTests(TestCase):
action = migration.operations[0]
self.assertEqual(action.__class__.__name__, "AlterUniqueTogether")
self.assertEqual(action.name, "book")
- self.assertEqual(action.unique_together, set([("author", "title")]))
+ self.assertEqual(action.unique_together, {("author", "title")})
def test_unique_together_no_changes(self):
"Tests that unique_togther doesn't generate a migration if no changes have been made"
@@ -594,7 +594,7 @@ class AutodetectorTests(TestCase):
action = migration.operations[0]
self.assertEqual(action.__class__.__name__, "AlterUniqueTogether")
self.assertEqual(action.name, "book")
- self.assertEqual(action.unique_together, set([("title", "author")]))
+ self.assertEqual(action.unique_together, {("title", "author")})
def test_add_field_and_unique_together(self):
"Tests that added fields will be created before using them in unique together"
@@ -612,12 +612,12 @@ class AutodetectorTests(TestCase):
action2 = migration.operations[1]
self.assertEqual(action1.__class__.__name__, "AddField")
self.assertEqual(action2.__class__.__name__, "AlterUniqueTogether")
- self.assertEqual(action2.unique_together, set([("title", "newfield")]))
+ self.assertEqual(action2.unique_together, {("title", "newfield")})
def test_remove_index_together(self):
author_index_together = ModelState("testapp", "Author", [
("id", models.AutoField(primary_key=True)), ("name", models.CharField(max_length=200))
- ], {"index_together": set([("id", "name")])})
+ ], {"index_together": {("id", "name")}})
before = self.make_project_state([author_index_together])
after = self.make_project_state([self.author_name])
@@ -636,7 +636,7 @@ class AutodetectorTests(TestCase):
def test_remove_unique_together(self):
author_unique_together = ModelState("testapp", "Author", [
("id", models.AutoField(primary_key=True)), ("name", models.CharField(max_length=200))
- ], {"unique_together": set([("id", "name")])})
+ ], {"unique_together": {("id", "name")}})
before = self.make_project_state([author_unique_together])
after = self.make_project_state([self.author_name])
@@ -1267,7 +1267,7 @@ class AutodetectorTests(TestCase):
self.assertOperationTypes(changes, 'a', 1, ["AddField"])
self.assertOperationTypes(changes, 'b', 0, ["CreateModel"])
self.assertEqual(changes['a'][0].dependencies, [])
- self.assertEqual(set(changes['a'][1].dependencies), set([('a', 'auto_1'), ('b', 'auto_1')]))
+ self.assertEqual(set(changes['a'][1].dependencies), {('a', 'auto_1'), ('b', 'auto_1')})
self.assertEqual(changes['b'][0].dependencies, [('__setting__', 'AUTH_USER_MODEL')])
@override_settings(AUTH_USER_MODEL="b.Tenant")
@@ -1298,7 +1298,7 @@ class AutodetectorTests(TestCase):
self.assertOperationTypes(changes, 'a', 1, ["AddField"])
self.assertOperationTypes(changes, 'b', 0, ["CreateModel"])
self.assertEqual(changes['a'][0].dependencies, [])
- self.assertEqual(set(changes['a'][1].dependencies), set([('__setting__', 'AUTH_USER_MODEL'), ('a', 'auto_1')]))
+ self.assertEqual(set(changes['a'][1].dependencies), {('__setting__', 'AUTH_USER_MODEL'), ('a', 'auto_1')})
self.assertEqual(changes['b'][0].dependencies, [('a', 'auto_1')])
@override_settings(AUTH_USER_MODEL="a.Person")
diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py
index 68d05d296f..676c843e9d 100644
--- a/tests/migrations/test_loader.py
+++ b/tests/migrations/test_loader.py
@@ -25,7 +25,7 @@ class RecorderTests(TestCase):
recorder.record_applied("myapp", "0432_ponies")
self.assertEqual(
set((x, y) for (x, y) in recorder.applied_migrations() if x == "myapp"),
- set([("myapp", "0432_ponies")]),
+ {("myapp", "0432_ponies")},
)
# That should not affect records of another database
recorder_other = MigrationRecorder(connections['other'])
diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py
index db94413bac..65ea6dc1fa 100644
--- a/tests/migrations/test_state.py
+++ b/tests/migrations/test_state.py
@@ -66,7 +66,7 @@ class StateTests(TestCase):
self.assertEqual(author_state.fields[1][1].max_length, 255)
self.assertEqual(author_state.fields[2][1].null, False)
self.assertEqual(author_state.fields[3][1].null, True)
- self.assertEqual(author_state.options, {"unique_together": set([("name", "bio")]), "index_together": set([("bio", "age")])})
+ self.assertEqual(author_state.options, {"unique_together": {("name", "bio")}, "index_together": {("bio", "age")}})
self.assertEqual(author_state.bases, (models.Model, ))
self.assertEqual(book_state.app_label, "migrations")
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
index 2b7ceddb2d..8aac038c1e 100644
--- a/tests/migrations/test_writer.py
+++ b/tests/migrations/test_writer.py
@@ -78,7 +78,7 @@ class WriterTests(TestCase):
self.assertEqual(string, "'foobar'")
self.assertSerializedEqual({1: 2})
self.assertSerializedEqual(["a", 2, True, None])
- self.assertSerializedEqual(set([2, 3, "eighty"]))
+ self.assertSerializedEqual({2, 3, "eighty"})
self.assertSerializedEqual({"lalalala": ["yeah", "no", "maybe"]})
self.assertSerializedEqual(_('Hello'))
# Builtins
@@ -120,7 +120,7 @@ class WriterTests(TestCase):
SettingsReference("someapp.model", "AUTH_USER_MODEL"),
(
"settings.AUTH_USER_MODEL",
- set(["from django.conf import settings"]),
+ {"from django.conf import settings"},
)
)
self.assertSerializedResultEqual(
diff --git a/tests/prefetch_related/tests.py b/tests/prefetch_related/tests.py
index a1272c1e0b..e04b823726 100644
--- a/tests/prefetch_related/tests.py
+++ b/tests/prefetch_related/tests.py
@@ -719,9 +719,9 @@ class GenericRelationTests(TestCase):
# If we limit to books, we know that they will have 'read_by'
# attributes, so the following makes sense:
qs = TaggedItem.objects.filter(content_type=ct, tag='awesome').prefetch_related('content_object__read_by')
- readers_of_awesome_books = set([r.name for tag in qs
- for r in tag.content_object.read_by.all()])
- self.assertEqual(readers_of_awesome_books, set(["me", "you", "someone"]))
+ readers_of_awesome_books = {r.name for tag in qs
+ for r in tag.content_object.read_by.all()}
+ self.assertEqual(readers_of_awesome_books, {"me", "you", "someone"})
def test_nullable_GFK(self):
TaggedItem.objects.create(tag="awesome", content_object=self.book1,
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 406710f8fd..d6f7aa38a0 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -91,10 +91,10 @@ class Queries1Tests(BaseQuerysetTest):
qs1 = Tag.objects.filter(pk__lte=0)
qs2 = Tag.objects.filter(parent__in=qs1)
qs3 = Tag.objects.filter(parent__in=qs2)
- self.assertEqual(qs3.query.subq_aliases, set(['T', 'U', 'V']))
+ self.assertEqual(qs3.query.subq_aliases, {'T', 'U', 'V'})
self.assertIn('v0', str(qs3.query).lower())
qs4 = qs3.filter(parent__in=qs1)
- self.assertEqual(qs4.query.subq_aliases, set(['T', 'U', 'V']))
+ self.assertEqual(qs4.query.subq_aliases, {'T', 'U', 'V'})
# It is possible to reuse U for the second subquery, no need to use W.
self.assertNotIn('w0', str(qs4.query).lower())
# So, 'U0."id"' is referenced twice.
@@ -1972,29 +1972,29 @@ class SubqueryTests(TestCase):
def test_ordered_subselect(self):
"Subselects honor any manual ordering"
query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[0:2])
- self.assertEqual(set(query.values_list('id', flat=True)), set([3, 4]))
+ self.assertEqual(set(query.values_list('id', flat=True)), {3, 4})
query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[:2])
- self.assertEqual(set(query.values_list('id', flat=True)), set([3, 4]))
+ self.assertEqual(set(query.values_list('id', flat=True)), {3, 4})
query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[1:2])
- self.assertEqual(set(query.values_list('id', flat=True)), set([3]))
+ self.assertEqual(set(query.values_list('id', flat=True)), {3})
query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[2:])
- self.assertEqual(set(query.values_list('id', flat=True)), set([1, 2]))
+ self.assertEqual(set(query.values_list('id', flat=True)), {1, 2})
def test_slice_subquery_and_query(self):
"""
Slice a query that has a sliced subquery
"""
query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[0:2])[0:2]
- self.assertEqual(set([x.id for x in query]), set([3, 4]))
+ self.assertEqual({x.id for x in query}, {3, 4})
query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[1:3])[1:3]
- self.assertEqual(set([x.id for x in query]), set([3]))
+ self.assertEqual({x.id for x in query}, {3})
query = DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[2:])[1:]
- self.assertEqual(set([x.id for x in query]), set([2]))
+ self.assertEqual({x.id for x in query}, {2})
def test_related_sliced_subquery(self):
"""
@@ -2010,18 +2010,18 @@ class SubqueryTests(TestCase):
query = ManagedModel.normal_manager.filter(
tag__in=Tag.objects.order_by('-id')[:1]
)
- self.assertEqual(set([x.id for x in query]), set([mm2.id]))
+ self.assertEqual({x.id for x in query}, {mm2.id})
def test_sliced_delete(self):
"Delete queries can safely contain sliced subqueries"
DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[0:1]).delete()
- self.assertEqual(set(DumbCategory.objects.values_list('id', flat=True)), set([1, 2, 3]))
+ self.assertEqual(set(DumbCategory.objects.values_list('id', flat=True)), {1, 2, 3})
DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[1:2]).delete()
- self.assertEqual(set(DumbCategory.objects.values_list('id', flat=True)), set([1, 3]))
+ self.assertEqual(set(DumbCategory.objects.values_list('id', flat=True)), {1, 3})
DumbCategory.objects.filter(id__in=DumbCategory.objects.order_by('-id')[1:]).delete()
- self.assertEqual(set(DumbCategory.objects.values_list('id', flat=True)), set([3]))
+ self.assertEqual(set(DumbCategory.objects.values_list('id', flat=True)), {3})
class CloneTests(TestCase):
@@ -2360,7 +2360,7 @@ class ToFieldTests(TestCase):
self.assertEqual(
set(Eaten.objects.filter(food__in=[apple, pear])),
- set([lunch, dinner]),
+ {lunch, dinner},
)
def test_reverse_in(self):
@@ -2371,7 +2371,7 @@ class ToFieldTests(TestCase):
self.assertEqual(
set(Food.objects.filter(eaten__in=[lunch_apple, lunch_pear])),
- set([apple, pear])
+ {apple, pear}
)
def test_single_object(self):
@@ -2381,7 +2381,7 @@ class ToFieldTests(TestCase):
self.assertEqual(
set(Eaten.objects.filter(food=apple)),
- set([lunch, dinner])
+ {lunch, dinner}
)
def test_single_object_reverse(self):
@@ -2390,7 +2390,7 @@ class ToFieldTests(TestCase):
self.assertEqual(
set(Food.objects.filter(eaten=lunch)),
- set([apple])
+ {apple}
)
def test_recursive_fk(self):
diff --git a/tests/requests/tests.py b/tests/requests/tests.py
index b8291d8359..36d1d80a69 100644
--- a/tests/requests/tests.py
+++ b/tests/requests/tests.py
@@ -68,7 +68,7 @@ class RequestsTests(SimpleTestCase):
self.assertEqual(list(request.GET.keys()), [])
self.assertEqual(list(request.POST.keys()), [])
self.assertEqual(list(request.COOKIES.keys()), [])
- self.assertEqual(set(request.META.keys()), set(['PATH_INFO', 'REQUEST_METHOD', 'SCRIPT_NAME', 'wsgi.input']))
+ self.assertEqual(set(request.META.keys()), {'PATH_INFO', 'REQUEST_METHOD', 'SCRIPT_NAME', 'wsgi.input'})
self.assertEqual(request.META['PATH_INFO'], 'bogus')
self.assertEqual(request.META['REQUEST_METHOD'], 'bogus')
self.assertEqual(request.META['SCRIPT_NAME'], '')
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py
index 71f6d18f24..07bfb91783 100644
--- a/tests/test_client_regress/tests.py
+++ b/tests/test_client_regress/tests.py
@@ -993,8 +993,8 @@ class ContextTests(TestCase):
l = ContextList([c1, c2])
# None, True and False are builtins of BaseContext, and present
# in every Context without needing to be added.
- self.assertEqual(set(['None', 'True', 'False', 'hello', 'goodbye',
- 'python', 'dolly']),
+ self.assertEqual({'None', 'True', 'False', 'hello', 'goodbye',
+ 'python', 'dolly'},
l.keys())
def test_15368(self):
diff --git a/tests/utils_tests/test_lazyobject.py b/tests/utils_tests/test_lazyobject.py
index 5d1989680a..c15388fb3b 100644
--- a/tests/utils_tests/test_lazyobject.py
+++ b/tests/utils_tests/test_lazyobject.py
@@ -266,7 +266,7 @@ class SimpleLazyObjectTestCase(LazyObjectTestCase):
def test_list_set(self):
lazy_list = SimpleLazyObject(lambda: [1, 2, 3, 4, 5])
- lazy_set = SimpleLazyObject(lambda: set([1, 2, 3, 4]))
+ lazy_set = SimpleLazyObject(lambda: {1, 2, 3, 4})
self.assertTrue(1 in lazy_list)
self.assertTrue(1 in lazy_set)
self.assertFalse(6 in lazy_list)