Skip to content

Commit b13bbdf

Browse files
committed
test: Compare dict directly
1 parent a32f5f6 commit b13bbdf

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

graphene_mongo/tests/test_query.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def resolve_editors(self, *args, **kwargs):
7676
result = schema.execute(query)
7777
assert not result.errors
7878
metadata = result.data['editor'].pop('metadata')
79-
assert cmp(json.loads(metadata), expected_metadata) == 0
80-
assert cmp(result.data, expected) == 0
79+
assert json.loads(metadata) == expected_metadata
80+
assert result.data == expected
8181

8282

8383
def test_should_query_reporter(fixtures):
@@ -139,7 +139,7 @@ def resolve_reporter(self, *args, **kwargs):
139139
schema = graphene.Schema(query=Query)
140140
result = schema.execute(query)
141141
assert not result.errors
142-
assert cmp(result.data, expected) == 0
142+
assert result.data == expected
143143

144144

145145
def test_should_custom_kwargs(fixtures):
@@ -177,7 +177,7 @@ def resolve_editors(self, *args, **kwargs):
177177
schema = graphene.Schema(query=Query)
178178
result = schema.execute(query)
179179
assert not result.errors
180-
assert cmp(result.data, expected) == 0
180+
assert result.data == expected
181181

182182

183183
def test_should_self_reference(fixtures):
@@ -246,7 +246,7 @@ def resolve_all_players(self, *args, **kwargs):
246246
schema = graphene.Schema(query=Query)
247247
result = schema.execute(query)
248248
assert not result.errors
249-
assert cmp(result.data, expected) == 0
249+
assert result.data == expected
250250

251251

252252
def test_should_query_with_embedded_document(fixtures):
@@ -279,7 +279,7 @@ def resolve_professor_vector(self, info, id):
279279
schema = graphene.Schema(query=Query, types=[ProfessorVectorType])
280280
result = schema.execute(query)
281281
assert not result.errors
282-
assert cmp(result.data, expected) == 0
282+
assert result.data == expected
283283

284284

285285
def test_should_query_child(fixtures):
@@ -323,7 +323,7 @@ def resolve_children(self, *args, **kwargs):
323323
schema = graphene.Schema(query=Query)
324324
result = schema.execute(query)
325325
assert not result.errors
326-
assert cmp(result.data, expected) == 0
326+
assert result.data == expected
327327

328328

329329
def test_should_query_cell_tower(fixtures):
@@ -383,4 +383,4 @@ def resolve_cell_towers(self, *args, **kwargs):
383383
schema = graphene.Schema(query=Query)
384384
result = schema.execute(query)
385385
assert not result.errors
386-
assert cmp(result.data, expected) == 0
386+
assert result.data == expected

graphene_mongo/tests/test_relay_query.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,7 @@ class Query(graphene.ObjectType):
526526
result = schema.execute(query)
527527

528528
assert not result.errors
529-
assert json.dumps(result.data, sort_keys=True) == json.dumps(
530-
expected, sort_keys=True)
529+
assert result.data == expected
531530

532531

533532
def test_should_before(fixtures):
@@ -569,8 +568,7 @@ class Query(graphene.ObjectType):
569568
result = schema.execute(query)
570569

571570
assert not result.errors
572-
assert json.dumps(result.data, sort_keys=True) == json.dumps(
573-
expected, sort_keys=True)
571+
assert result.data == expected
574572

575573

576574
def test_should_last_n(fixtures):
@@ -611,8 +609,7 @@ class Query(graphene.ObjectType):
611609
result = schema.execute(query)
612610

613611
assert not result.errors
614-
assert json.dumps(result.data, sort_keys=True) == \
615-
json.dumps(expected, sort_keys=True)
612+
assert result.data == expected
616613

617614

618615
def test_should_self_reference(fixtures):
@@ -723,8 +720,7 @@ class Query(graphene.ObjectType):
723720
schema = graphene.Schema(query=Query)
724721
result = schema.execute(query)
725722
assert not result.errors
726-
assert json.dumps(result.data, sort_keys=True) == json.dumps(
727-
expected, sort_keys=True)
723+
assert result.data == expected
728724

729725

730726
def test_should_lazy_reference(fixtures):
@@ -789,8 +785,7 @@ class Query(graphene.ObjectType):
789785

790786
result = schema.execute(query)
791787
assert not result.errors
792-
assert json.dumps(result.data, sort_keys=True) == json.dumps(
793-
expected, sort_keys=True)
788+
assert result.data == expected
794789

795790

796791
def test_should_query_with_embedded_document(fixtures):
@@ -873,8 +868,7 @@ class Query(graphene.ObjectType):
873868
schema = graphene.Schema(query=Query)
874869
result = schema.execute(query)
875870
assert not result.errors
876-
assert json.dumps(result.data, sort_keys=True) == json.dumps(
877-
expected, sort_keys=True)
871+
assert result.data == expected
878872

879873

880874
def test_should_get_queryset_returns_qs_filters(fixtures):
@@ -919,5 +913,4 @@ class Query(graphene.ObjectType):
919913
schema = graphene.Schema(query=Query)
920914
result = schema.execute(query)
921915
assert not result.errors
922-
assert json.dumps(result.data, sort_keys=True) == json.dumps(
923-
expected, sort_keys=True)
916+
assert result.data == expected

0 commit comments

Comments
 (0)