Skip to content

Commit 96c7e62

Browse files
meatballsmarcharper
authored andcommitted
Use assertEqual instead of unecessary loop
1 parent 5916039 commit 96c7e62

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

axelrod/tests/unit/test_graph.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ def test_out_dict(self):
9494
2: {1: None, 3: None},
9595
3: {2: None}
9696
}
97-
for key in expected_out_mapping:
98-
self.assertEqual(g.out_mapping[key], expected_out_mapping[key])
97+
self.assertEqual(g.out_mapping, expected_out_mapping)
9998

10099
# Undirected graph with vertices and weighted edges
101100
g = graph.Graph(edges=[[1, 2, 10], [2, 3, 5]])
@@ -104,17 +103,15 @@ def test_out_dict(self):
104103
2: {1: 10, 3: 5},
105104
3: {2: 5}
106105
}
107-
for key in expected_out_mapping:
108-
self.assertEqual(g.out_mapping[key], expected_out_mapping[key])
106+
self.assertEqual(g.out_mapping, expected_out_mapping)
109107

110108
# Directed graph with vertices and weighted edges
111109
g = graph.Graph(edges=[[1, 2, 10], [2, 3, 5]], directed=True)
112110
expected_out_mapping = {
113111
1: {2: 10},
114112
2: {3: 5},
115113
}
116-
for key in expected_out_mapping:
117-
self.assertEqual(g.out_mapping[key], expected_out_mapping[key])
114+
self.assertEqual(g.out_mapping, expected_out_mapping)
118115

119116
def test_in_dict(self):
120117
# Undirected graph with vertices and unweighted edges
@@ -124,8 +121,7 @@ def test_in_dict(self):
124121
2: {1: None, 3: None},
125122
3: {2: None}
126123
}
127-
for key in expected_in_mapping:
128-
self.assertEqual(g.in_mapping[key], expected_in_mapping[key])
124+
self.assertEqual(g.in_mapping, expected_in_mapping)
129125

130126
# Undirected graph with vertices and weighted edges
131127
g = graph.Graph(edges=[[1, 2, 10], [2, 3, 5]])
@@ -134,17 +130,15 @@ def test_in_dict(self):
134130
2: {1: 10, 3: 5},
135131
3: {2: 5}
136132
}
137-
for key in expected_in_mapping:
138-
self.assertEqual(g.in_mapping[key], expected_in_mapping[key])
133+
self.assertEqual(g.in_mapping, expected_in_mapping)
139134

140135
# Directed graph with vertices and weighted edges
141136
g = graph.Graph(edges=[[1, 2, 10], [2, 3, 5]], directed=True)
142137
expected_in_mapping = {
143138
2: {1: 10},
144139
3: {2: 5}
145140
}
146-
for key in expected_in_mapping:
147-
self.assertEqual(g.in_mapping[key], expected_in_mapping[key])
141+
self.assertEqual(g.in_mapping, expected_in_mapping)
148142

149143
def test_repr(self):
150144
# Undirected graph with no vertices

0 commit comments

Comments
 (0)