Skip to content

Commit 2c52429

Browse files
committed
TST: fixing up tests to pass with the changed formats
1 parent 7c6c5ff commit 2c52429

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

astroquery/xmatch/tests/test_xmatch_remote.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import pytest
66
import requests
77
from requests import ReadTimeout
8+
from numpy.testing import assert_allclose
89

910
from astropy.table import Table
1011
from astropy.units import arcsec, arcmin
11-
from astropy.io import ascii
1212

1313
from astropy.coordinates import SkyCoord
1414

@@ -37,12 +37,15 @@ def test_is_xmatch_up():
3737
def remote_table(tmp_path_factory):
3838
# this can be used to check that the API is still functional & doing as expected
3939
infile = DATA_DIR / "posList.csv"
40-
outfile = tmp_path_factory.mktemp("remote_data") / "http_result.csv"
41-
os.system("curl -X POST -F request=xmatch -F distMaxArcsec=5 -F RESPONSEFORMAT=csv "
40+
outfile = tmp_path_factory.mktemp("remote_data") / "http_result.vot"
41+
os.system("curl -X POST -F request=xmatch -F distMaxArcsec=5 -F RESPONSEFORMAT=votable "
4242
"-F cat1=@{1} -F colRA1=ra -F colDec1=dec -F cat2=vizier:II/246/out "
4343
"http://cdsxmatch.u-strasbg.fr/xmatch/api/v1/sync > {0}".
4444
format(outfile, infile))
45-
return ascii.read(outfile, format="csv", fast_reader=False)
45+
remote_table = Table.read(outfile, format="votable")
46+
remote_table.rename_column('_2MASS', '2MASS')
47+
48+
return remote_table
4649

4750

4851
@pytest.mark.remote_data
@@ -83,7 +86,11 @@ def test_xmatch_query(self, xmatch, remote_table):
8386
'e_Jmag', 'e_Hmag', 'e_Kmag', 'Qfl', 'Rfl', 'X', 'MeasureJD']
8487
assert len(table) == 11
8588

86-
assert all(table == remote_table)
89+
for col in table.colnames:
90+
if remote_table[col].dtype.kind == 'U':
91+
assert all(table[col] == remote_table[col])
92+
else:
93+
assert_allclose(table[col], remote_table[col])
8794

8895
def test_xmatch_query_astropy_table(self, xmatch, remote_table):
8996
input_table = Table.read(DATA_DIR / "posList.csv", format="ascii.csv")
@@ -99,8 +106,11 @@ def test_xmatch_query_astropy_table(self, xmatch, remote_table):
99106
'errHalfMaj', 'errHalfMin', 'errPosAng', 'Jmag', 'Hmag', 'Kmag',
100107
'e_Jmag', 'e_Hmag', 'e_Kmag', 'Qfl', 'Rfl', 'X', 'MeasureJD']
101108
assert len(table) == 11
102-
103-
assert all(table == remote_table)
109+
for col in table.colnames:
110+
if remote_table[col].dtype.kind == 'U':
111+
assert all(table[col] == remote_table[col])
112+
else:
113+
assert_allclose(table[col], remote_table[col])
104114

105115
@pytest.mark.skipif('regions' not in sys.modules,
106116
reason="requires astropy-regions")

docs/xmatch/xmatch.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ in the resulting table for demonstration purposes. Finally, ``colRa1`` and
5555
<class 'astropy.table.table.Table'>
5656
>>> print(table)
5757
angDist ra dec 2MASS ... Qfl Rfl X MeasureJD
58+
arcsec ... d
5859
-------- --------- --------- ---------------- ... --- --- --- ------------
5960
1.352044 267.22029 -20.35869 17485281-2021323 ... EEU 226 2 2450950.8609
6061
1.578188 267.22029 -20.35869 17485288-2021328 ... UUB 662 2 2450950.8609

0 commit comments

Comments
 (0)