Skip to content

Commit ca3a85b

Browse files
committed
Remove six from tests
The package `six` allows for writing code that works with both Python 2 and 3, but because Python 2 is no longer supported, `six` no longer serves a purpose. This commit removes `six` from the tests.
1 parent 729cf6d commit ca3a85b

File tree

12 files changed

+16
-25
lines changed

12 files changed

+16
-25
lines changed

astroquery/alma/tests/test_alma.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2+
from io import StringIO
23
import os
34

45
import pytest
56
from unittest.mock import patch, Mock
6-
from six import StringIO
77

88
from astropy import units as u
99
from astropy import coordinates as coord

astroquery/astrometry_net/tests/test_astrometry_net.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from distutils.version import LooseVersion
55

66
import pytest
7-
import six
87

98
from ...utils.testing_tools import MockResponse
109
from ...exceptions import (InvalidQueryError)
@@ -87,7 +86,7 @@ def test_setting_validation_basic():
8786
anet = AstrometryNet()
8887
# This gets us a list of settings, their types, and restrictions.
8988
constraints = anet._constraints
90-
for constraint, vals in six.iteritems(constraints):
89+
for constraint, vals in constraints.items():
9190
if vals['type'] == str or vals['type'] == bool:
9291
settings = {constraint: 'asdiuhiuas'}
9392
with pytest.raises(ValueError) as e:

astroquery/besancon/tests/test_besancon.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from contextlib import contextmanager
55
import pytest
66
from astropy.io.ascii.tests.common import assert_equal
7-
from six import string_types
87
from ... import besancon
98
from ...utils import commons
109
from ...utils.testing_tools import MockResponse
@@ -65,7 +64,7 @@ def patch_post(request):
6564
def patch_get_readable_fileobj(request):
6665
@contextmanager
6766
def get_readable_fileobj_mockreturn(filename, **kwargs):
68-
if isinstance(filename, string_types):
67+
if isinstance(filename, str):
6968
if '1376235131.430670' in filename:
7069
is_binary = kwargs.get('encoding', None) == 'binary'
7170
file_obj = open(data_path('1376235131.430670.resu'),

astroquery/cadc/tests/test_cadctap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
=============
66
77
"""
8+
from io import BytesIO
9+
from urllib.parse import urlsplit, parse_qs
810
import os
911
import sys
1012

1113
from astropy.table import Table as AstroTable
1214
from astropy.io.fits.hdu.hdulist import HDUList
1315
from astropy.io.votable.tree import VOTableFile, Resource, Table, Field
1416
from astropy.io.votable import parse
15-
from six import BytesIO
16-
from six.moves.urllib_parse import urlsplit, parse_qs
1717
from astroquery.utils.commons import parse_coordinates, FileContainer
1818
from astropy import units as u
1919
from astropy.utils.exceptions import AstropyDeprecationWarning

astroquery/eso/tests/test_eso_remote.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pytest
44
import tempfile
55
import shutil
6-
import six
76
from ...exceptions import LoginError
87

98
from ...eso import Eso
@@ -126,10 +125,10 @@ def test_retrieve_data(self):
126125
assert len(result) > 0
127126
assert "MIDI.2014-07-25T02:03:11.561" in result[0]
128127
result = eso.retrieve_data("MIDI.2014-07-25T02:03:11.561")
129-
assert isinstance(result, six.string_types)
128+
assert isinstance(result, str)
130129
result = eso.retrieve_data("MIDI.2014-07-25T02:03:11.561",
131130
request_all_objects=True)
132-
assert isinstance(result, six.string_types)
131+
assert isinstance(result, str)
133132

134133
@pytest.mark.skipif('not Eso.USERNAME')
135134
def test_retrieve_data_twice(self):

astroquery/gaia/tests/DummyTapHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
1616
"""
17-
from six.moves.urllib.parse import urlencode
17+
from urllib.parse import urlencode
1818

1919
CONTENT_TYPE_POST_DEFAULT = "application/x-www-form-urlencoded"
2020

astroquery/nist/tests/test_nist_remote.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from astropy.table import Table
77
import astropy.units as u
8-
from six import PY2 # noqa
98

109
import pytest
1110

@@ -27,7 +26,6 @@ def test_query(self):
2726
# (regression test for 1355)
2827
assert np.all(result['TP'] == 'T8637')
2928

30-
@pytest.mark.skipif('PY2')
3129
def test_unescape_html(self):
3230
response = nist.core.Nist.query_async(4333 * u.AA, 4334 * u.AA, "V I")
3331
assert '†' in response.text

astroquery/sdss/tests/test_sdss.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22
from contextlib import contextmanager
3+
from urllib.error import URLError
34
import os
45
import socket
56
import numpy as np
67
from numpy.testing import assert_allclose
78

8-
import six
99
from astropy.io import fits
1010
from astropy.table import Column, Table
1111
import pytest
@@ -78,7 +78,7 @@ def get_readable_fileobj_mockreturn(filename, **kwargs):
7878
def patch_get_readable_fileobj_slow(request):
7979
@contextmanager
8080
def get_readable_fileobj_mockreturn(filename, **kwargs):
81-
error = six.moves.urllib_error.URLError('timeout')
81+
error = URLError('timeout')
8282
error.reason = socket.timeout()
8383
raise error
8484
yield True

astroquery/sdss/tests/test_sdss_remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from astropy import coordinates
77
from astropy.table import Table
88

9-
from six.moves.urllib_error import URLError
9+
from urllib.error import URLError
1010

1111
from ... import sdss
1212
from ...exceptions import TimeoutError

astroquery/simbad/tests/test_simbad.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33
import re
44

5-
import six
65
import pytest
76
import astropy.units as u
87
from astropy.table import Table
@@ -131,8 +130,8 @@ def test_parse_result():
131130
'The attempted parsed result is in '
132131
'self.last_parsed_result.\n Exception: 7:115: '
133132
'no element found')
134-
assert isinstance(simbad.Simbad.last_response.text, six.string_types)
135-
assert isinstance(simbad.Simbad.last_response.content, six.binary_type)
133+
assert isinstance(simbad.Simbad.last_response.text, str)
134+
assert isinstance(simbad.Simbad.last_response.content, bytes)
136135

137136

138137
votable_fields = ",".join(simbad.core.Simbad.get_votable_fields())

0 commit comments

Comments
 (0)