Skip to content

Commit 9c97444

Browse files
committed
Remove custom assert messages from gaia tests
`pytest` produces informative assert failure messages automatically.
1 parent 9348aaa commit 9c97444

File tree

1 file changed

+18
-38
lines changed

1 file changed

+18
-38
lines changed

astroquery/gaia/tests/test_gaiatap.py

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -131,64 +131,48 @@ def test_query_object(self, column_attrs, mock_querier):
131131
assert "Missing required argument: height" in err.value.args[0]
132132

133133
table = mock_querier.query_object(skycoord, width=width, height=10 * u.deg)
134-
assert len(table) == 3, \
135-
"Wrong job results (num rows). Expected: %d, found %d" % \
136-
(3, len(table))
134+
assert len(table) == 3
137135
for colname, attrs in column_attrs.items():
138136
assert table[colname].attrs_equal(attrs)
139137
# by radius
140138
table = mock_querier.query_object(skycoord, radius=1 * u.deg)
141-
assert len(table) == 3, \
142-
"Wrong job results (num rows). Expected: %d, found %d" % \
143-
(3, len(table))
139+
assert len(table) == 3
144140
for colname, attrs in column_attrs.items():
145141
assert table[colname].attrs_equal(attrs)
146142

147143
def test_query_object_async(self, column_attrs, mock_querier_async):
148144
table = mock_querier_async.query_object_async(
149145
skycoord, width=12 * u.deg, height=10 * u.deg
150146
)
151-
assert len(table) == 3, \
152-
"Wrong job results (num rows). Expected: %d, found %d" % \
153-
(3, len(table))
147+
assert len(table) == 3
154148
for colname, attrs in column_attrs.items():
155149
assert table[colname].attrs_equal(attrs)
156150
# by radius
157151
table = mock_querier_async.query_object_async(skycoord, radius=1 * u.deg)
158-
assert len(table) == 3, \
159-
"Wrong job results (num rows). Expected: %d, found %d" % \
160-
(3, len(table))
152+
assert len(table) == 3
161153
for colname, attrs in column_attrs.items():
162154
assert table[colname].attrs_equal(attrs)
163155

164156
def test_cone_search_sync(self, column_attrs, mock_querier):
165157
job = mock_querier.cone_search(skycoord, 1 * u.deg)
166-
assert job.async_ is False, "Expected a synchronous job"
167-
assert job.get_phase() == 'COMPLETED', \
168-
"Wrong job phase. Expected: %s, found %s" % \
169-
('COMPLETED', job.get_phase())
170-
assert job.failed is False, "Wrong job status (set Failed = True)"
158+
assert job.async_ is False
159+
assert job.get_phase() == "COMPLETED"
160+
assert job.failed is False
171161
# results
172162
results = job.get_results()
173-
assert len(results) == 3, \
174-
"Wrong job results (num rows). Expected: %d, found %d" % \
175-
(3, len(results))
163+
assert len(results) == 3
176164
for colname, attrs in column_attrs.items():
177165
assert results[colname].attrs_equal(attrs)
178166

179167
def test_cone_search_async(self, column_attrs, mock_querier_async):
180168
radius = 1.0 * u.deg
181169
job = mock_querier_async.cone_search_async(skycoord, radius)
182-
assert job.async_ is True, "Expected an asynchronous job"
183-
assert job.get_phase() == 'COMPLETED', \
184-
"Wrong job phase. Expected: %s, found %s" % \
185-
('COMPLETED', job.get_phase())
186-
assert job.failed is False, "Wrong job status (set Failed = True)"
170+
assert job.async_ is True
171+
assert job.get_phase() == "COMPLETED"
172+
assert job.failed is False
187173
# results
188174
results = job.get_results()
189-
assert len(results) == 3, \
190-
"Wrong job results (num rows). Expected: %d, found %d" % \
191-
(3, len(results))
175+
assert len(results) == 3
192176
for colname, attrs in column_attrs.items():
193177
assert results[colname].attrs_equal(attrs)
194178

@@ -318,22 +302,18 @@ def test_xmatch(self, mock_querier_async):
318302
full_qualified_table_name_b='schemaB.tableB',
319303
results_table_name='results',
320304
)
321-
assert job.async_ is True, "Expected an asynchronous job"
322-
assert job.get_phase() == 'COMPLETED', \
323-
"Wrong job phase. Expected: %s, found %s" % \
324-
('COMPLETED', job.get_phase())
325-
assert job.failed is False, "Wrong job status (set Failed = True)"
305+
assert job.async_ is True
306+
assert job.get_phase() == "COMPLETED"
307+
assert job.failed is False
326308
job = mock_querier_async.cross_match(
327309
full_qualified_table_name_a='schemaA.tableA',
328310
full_qualified_table_name_b='schemaB.tableB',
329311
results_table_name='results',
330312
background=True,
331313
)
332-
assert job.async_ is True, "Expected an asynchronous job"
333-
assert job.get_phase() == 'EXECUTING', \
334-
"Wrong job phase. Expected: %s, found %s" % \
335-
('EXECUTING', job.get_phase())
336-
assert job.failed is False, "Wrong job status (set Failed = True)"
314+
assert job.async_ is True
315+
assert job.get_phase() == "EXECUTING"
316+
assert job.failed is False
337317

338318
@patch.object(TapPlus, 'login')
339319
def test_login(self, mock_login):

0 commit comments

Comments
 (0)