Skip to content

Commit d51440c

Browse files
committed
removing extra try..except from imports, only keyring import needs to be checked
1 parent 62ee271 commit d51440c

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

astroquery/cosmosim/tests/test_cosmosim_remote.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,21 @@
33
import tempfile
44
import shutil
55
from astropy.tests.helper import pytest, remote_data
6+
from ...exceptions import LoginError
7+
68
try:
79
import keyring
810
HAS_KEYRING = True
911
except ImportError:
1012
HAS_KEYRING = False
11-
try:
13+
14+
if HAS_KEYRING:
1215
from ...cosmosim import CosmoSim
13-
COSMOSIM_IMPORTED = True
14-
except ImportError:
15-
COSMOSIM_IMPORTED = False
16-
from ...exceptions import LoginError
1716

18-
SKIP_TESTS = not(HAS_KEYRING and COSMOSIM_IMPORTED)
17+
SKIP_TESTS = not HAS_KEYRING
1918

2019
#@pytest.mark.skipif('SKIP_TESTS')
2120
#@remote_data
2221
#class TestEso:
2322
# def __init__():
24-
23+

astroquery/eso/tests/test_eso.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22
import os
3-
from distutils.version import LooseVersion
4-
import astropy
5-
try:
6-
from ...eso import Eso
7-
ESO_IMPORTED = True
8-
except ImportError:
9-
ESO_IMPORTED = False
103
from astropy.tests.helper import pytest
114
from ...utils.testing_tools import MockResponse
125

13-
SKIP_TESTS = not ESO_IMPORTED
6+
# keyring is an optional dependency required by the eso module.
7+
try:
8+
import keyring
9+
HAS_KEYRING = True
10+
except ImportError:
11+
HAS_KEYRING = False
12+
13+
if HAS_KEYRING:
14+
from ...eso import Eso
15+
16+
SKIP_TESTS = not HAS_KEYRING
1417

1518
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
1619

@@ -22,12 +25,12 @@ def data_path(filename):
2225
'amber_form.html',
2326
'http://archive.eso.org/wdb/wdb/adp/phase3_main/form':
2427
'vvv_sgra_form.html',
25-
},
28+
},
2629
'POST': {'http://archive.eso.org/wdb/wdb/eso/amber/query':
2730
'amber_sgra_query.tbl',
2831
'http://archive.eso.org/wdb/wdb/adp/phase3_main/query':
2932
'vvv_sgra_survey_response.tbl',
30-
}
33+
}
3134
}
3235

3336

@@ -64,6 +67,7 @@ def test_SgrAstar(monkeypatch):
6467
assert len(result) == 50
6568
assert 'GC_IRS7' in result['Object']
6669

70+
6771
@pytest.mark.skipif('SKIP_TESTS')
6872
def test_vvv(monkeypatch):
6973
eso = Eso()

astroquery/eso/tests/test_eso_remote.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
import tempfile
33
import shutil
44
from astropy.tests.helper import pytest, remote_data
5+
from ...exceptions import LoginError
6+
7+
# keyring is an optional dependency required by the eso module.
58
try:
69
import keyring
710
HAS_KEYRING = True
811
except ImportError:
912
HAS_KEYRING = False
10-
try:
13+
14+
if HAS_KEYRING:
1115
from ...eso import Eso
12-
ESO_IMPORTED = True
13-
except ImportError:
14-
ESO_IMPORTED = False
15-
from ...exceptions import LoginError
1616

17-
SKIP_TESTS = not(HAS_KEYRING and ESO_IMPORTED)
17+
SKIP_TESTS = not HAS_KEYRING
1818

1919
instrument_list = [u'fors1', u'fors2', u'sphere', u'vimos', u'omegacam',
2020
u'hawki', u'isaac', u'naco', u'visir', u'vircam', u'apex',

0 commit comments

Comments
 (0)