Skip to content

Commit f2a6a85

Browse files
committed
Running pyupgrade with Python 3+ support
Removes some old Python 2 literals
1 parent b62ca08 commit f2a6a85

File tree

3 files changed

+22
-30
lines changed

3 files changed

+22
-30
lines changed

example/tests/integration/test_includes.py

+8-14
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_included_data_on_list(multiple_entries, client):
2121
comment_count = len(
2222
[resource for resource in included if resource["type"] == "comments"]
2323
)
24-
expected_comment_count = sum([entry.comments.count() for entry in multiple_entries])
24+
expected_comment_count = sum(entry.comments.count() for entry in multiple_entries)
2525
assert comment_count == expected_comment_count, "List comment count is incorrect"
2626

2727

@@ -135,28 +135,24 @@ def test_deep_included_data_on_list(multiple_entries, client):
135135
comment_count = len(
136136
[resource for resource in included if resource["type"] == "comments"]
137137
)
138-
expected_comment_count = sum([entry.comments.count() for entry in multiple_entries])
138+
expected_comment_count = sum(entry.comments.count() for entry in multiple_entries)
139139
assert comment_count == expected_comment_count, "List comment count is incorrect"
140140

141141
author_count = len(
142142
[resource for resource in included if resource["type"] == "authors"]
143143
)
144144
expected_author_count = sum(
145-
[
146-
entry.comments.filter(author__isnull=False).count()
147-
for entry in multiple_entries
148-
]
145+
entry.comments.filter(author__isnull=False).count()
146+
for entry in multiple_entries
149147
)
150148
assert author_count == expected_author_count, "List author count is incorrect"
151149

152150
author_bio_count = len(
153151
[resource for resource in included if resource["type"] == "authorBios"]
154152
)
155153
expected_author_bio_count = sum(
156-
[
157-
entry.comments.filter(author__bio__isnull=False).count()
158-
for entry in multiple_entries
159-
]
154+
entry.comments.filter(author__bio__isnull=False).count()
155+
for entry in multiple_entries
160156
)
161157
assert (
162158
author_bio_count == expected_author_bio_count
@@ -166,10 +162,8 @@ def test_deep_included_data_on_list(multiple_entries, client):
166162
[resource for resource in included if resource["type"] == "writers"]
167163
)
168164
expected_writer_count = sum(
169-
[
170-
entry.comments.filter(author__isnull=False).count()
171-
for entry in multiple_entries
172-
]
165+
entry.comments.filter(author__isnull=False).count()
166+
for entry in multiple_entries
173167
)
174168
assert writer_count == expected_writer_count, "List writer count is incorrect"
175169

example/tests/integration/test_polymorphism.py

+13-15
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ def test_polymorphism_on_detail_relations(single_company, client):
2424
content["data"]["relationships"]["currentProject"]["data"]["type"]
2525
== "artProjects"
2626
)
27-
assert set(
28-
[
29-
rel["type"]
30-
for rel in content["data"]["relationships"]["futureProjects"]["data"]
31-
]
32-
) == set(["researchProjects", "artProjects"])
27+
assert {
28+
rel["type"]
29+
for rel in content["data"]["relationships"]["futureProjects"]["data"]
30+
} == {"researchProjects", "artProjects"}
3331

3432

3533
def test_polymorphism_on_included_relations(single_company, client):
@@ -47,15 +45,15 @@ def test_polymorphism_on_included_relations(single_company, client):
4745
== "artProjects"
4846
)
4947
assert content["data"]["relationships"]["currentResearchProject"]["data"] is None
50-
assert set(
51-
[
52-
rel["type"]
53-
for rel in content["data"]["relationships"]["futureProjects"]["data"]
54-
]
55-
) == set(["researchProjects", "artProjects"])
56-
assert set([x.get("type") for x in content.get("included")]) == set(
57-
["artProjects", "artProjects", "researchProjects"]
58-
), "Detail included types are incorrect"
48+
assert {
49+
rel["type"]
50+
for rel in content["data"]["relationships"]["futureProjects"]["data"]
51+
} == {"researchProjects", "artProjects"}
52+
assert {x.get("type") for x in content.get("included")} == {
53+
"artProjects",
54+
"artProjects",
55+
"researchProjects",
56+
}, "Detail included types are incorrect"
5957
# Ensure that the child fields are present.
6058
assert content.get("included")[0].get("attributes").get("artist") is not None
6159
assert content.get("included")[1].get("attributes").get("artist") is not None

example/tests/test_filters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ def test_search_multiple_keywords(self):
600600
expected_ids = set.intersection(*union)
601601
expected_len = len(expected_ids)
602602
self.assertEqual(len(dja_response["data"]), expected_len)
603-
returned_ids = set([k["id"] for k in dja_response["data"]])
603+
returned_ids = {k["id"] for k in dja_response["data"]}
604604
self.assertEqual(returned_ids, expected_ids)
605605

606606
def test_param_invalid(self):

0 commit comments

Comments
 (0)