Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Test failures with remote_data=True #4896

Description

@pllim

Someone should turn on remote_data and do a test before 1.2 release. I get the following failures on my machine (the last one cracks me up):

================================== FAILURES ===================================
___________________ test_database_specify[ngc 3642-db_dict0] ___________________

name = 'ngc 3642'
db_dict = {'all': '# ngc3642    #Q22523722
#=S=Simbad (via url):    1
%@ 503952
%I.0 NGC 3642
%C.0 LIN
%C.N0 15.15.01.00
%J 170....V=VizieR (local):    1
%J 170.56 +59.08 = 11:22.2     +59:05
%I.0 {NGC} 3642



#====Done (2013-Feb-12,16:37:42z)===='}

    @remote_data
    @pytest.mark.parametrize(("name", "db_dict"), [('ngc 3642', _cached_ngc3642),
                                                   ('castor', _cached_castor)])
    def test_database_specify(name, db_dict):
        # First check that at least some sesame mirror is up
        for url in sesame_url.get():
            if urllib.request.urlopen(url).getcode() == 200:
                break
        else:
            pytest.skip("All SESAME mirrors appear to be down, skipping "
                        "test_name_resolve.py:test_database_specify()...")

        for db in db_dict.keys():
            with sesame_database.set(db):
                try:
                    icrs = SkyCoord.from_name(name)
                except NameResolveError:
>                   ra, dec = db_dict[db]
E                   ValueError: too many values to unpack

.../astropy/coordinates/tests/test_name_resolve.py:160: ValueError___________________ test_database_specify[ngc 3642-db_dict0] ___________________

name = 'ngc 3642'
db_dict = {'all': '# ngc3642    #Q22523722\n#=S=Simbad (via url):    1\n%@ 503952\n%I.0 NGC 3642\n%C.0 LIN\n%C.N0 15.15.01.00\n%...eR (local):    1\n%J 170.56 +59.08 = 11:22.2     +59:05\n%I.0 {NGC} 3642\n\n\n\n#====Done (2013-Feb-12,16:37:42z)===='}

    @remote_data
    @pytest.mark.parametrize(("name", "db_dict"), [('ngc 3642', _cached_ngc3642),
                                                   ('castor', _cached_castor)])
    def test_database_specify(name, db_dict):
        # First check that at least some sesame mirror is up
        for url in sesame_url.get():
            if urllib.request.urlopen(url).getcode() == 200:
                break
        else:
            pytest.skip("All SESAME mirrors appear to be down, skipping "
                        "test_name_resolve.py:test_database_specify()...")

        for db in db_dict.keys():
            with sesame_database.set(db):
                try:
                    icrs = SkyCoord.from_name(name)
                except NameResolveError:
>                   ra, dec = db_dict[db]
E                   ValueError: too many values to unpack

.../astropy/coordinates/tests/test_name_resolve.py:160: ValueError
_____________________ test_constellations_with_nameresolve _____________________

    @remote_data
    def test_constellations_with_nameresolve():
        assert SkyCoord.from_name('And I').get_constellation(short_name=True) == 'And'

        #you'd think "And ..." should be in Andromeda.  But you'd be wrong.
        assert SkyCoord.from_name('And VI').get_constellation() == 'Pegasus'

        #maybe it's because And VI isn't really a galaxy?
        assert SkyCoord.from_name('And XXII').get_constellation() == 'Pisces'
        assert SkyCoord.from_name('And XXX').get_constellation() == 'Cassiopeia'
        #ok maybe not

        #ok, but at least some of the others do make sense...
        assert SkyCoord.from_name('Coma Cluster').get_constellation(short_name=True) == 'Com'
>       assert SkyCoord.from_name('UMa II').get_constellation() == 'Ursa Major'

.../astropy/coordinates/tests/test_sky_coord.py:1162: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../astropy/coordinates/sky_coordinate.py:1174: in from_name
    icrs_coord = get_icrs_coordinates(name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'UMa II'

    def get_icrs_coordinates(name):
        """
        Retrieve an ICRS object by using an online name resolving service to
        retrieve coordinates for the specified name. By default, this will
        search all available databases until a match is found. If you would like
        to specify the database, use the science state
        ``astropy.coordinates.name_resolve.sesame_database``. You can also
        specify a list of servers to use for querying Sesame using the science
        state ``astropy.coordinates.name_resolve.sesame_url``. This will try
        each one in order until a valid response is returned. By default, this
        list includes the main Sesame host and a mirror at vizier.  The
        configuration item `astropy.utils.data.Conf.remote_timeout` controls the
        number of seconds to wait for a response from the server before giving
        up.

        Parameters
        ----------
        name : str
            The name of the object to get coordinates for, e.g. ``'M42'``.

        Returns
        -------
        coord : `astropy.coordinates.ICRS` object
            The object's coordinates in the ICRS frame.

        """

        database = sesame_database.get()
        # The web API just takes the first letter of the database name
        db = database.upper()[0]

        # Make sure we don't have duplicates in the url list
        urls = []
        domains = []
        for url in sesame_url.get():
            domain = urllib.parse.urlparse(url).netloc

            # Check for duplicates
            if domain not in domains:
                domains.append(domain)

                # Add the query to the end of the url, add to url list
                fmt_url = os.path.join(url, "{db}?{name}")
                fmt_url = fmt_url.format(name=urllib.parse.quote(name), db=db)
                urls.append(fmt_url)

        for url in urls:
            try:
                # Retrieve ascii name resolve data from CDS
                resp = urllib.request.urlopen(url, timeout=data.conf.remote_timeout)
                resp_data = resp.read()
                break
            except urllib.error.URLError as e:
                # This catches a timeout error, see:
                #   http://stackoverflow.com/questions/2712524/handling-urllib2s-timeout-python
                if isinstance(e.reason, socket.timeout):
                    # If it was a timeout, try with the next URL
                    continue
                else:
                    raise NameResolveError(
                        "Unable to retrieve coordinates for name '{0}'; "
                        "connection timed out".format(name))
            except socket.timeout:
                # There are some cases where urllib2 does not catch socket.timeout
                # especially while receiving response data on an already previously
                # working request
                raise NameResolveError(
                    "Unable to retrieve coordinates for name '{0}'; connection "
                    "timed out".format(name))

        # All Sesame URL's timed out...
        else:
            raise NameResolveError("All Sesame queries timed out. Unable to "
                                   "retrieve coordinates.")

        ra, dec = _parse_response(resp_data)

        if ra is None and dec is None:
            if db == "A":
                err = "Unable to find coordinates for name '{0}'".format(name)
            else:
                err = "Unable to find coordinates for name '{0}' in database {1}"\
                      .format(name, database)

>           raise NameResolveError(err)
E           NameResolveError: Unable to find coordinates for name 'UMa II'

.../astropy/coordinates/name_resolve.py:173: NameResolveError
___________________ TestFileFunctions.test_open_nonexistent ____________________

self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0x7f6b58687cd0>

    def test_open_nonexistent(self):
        """Test that trying to open a non-existent file results in an
            IOError (and not some other arbitrary exception).
            """

        try:
            fits.open(self.temp('foobar.fits'))
        except IOError as e:
>           assert 'No such file or directory' in str(e)
E           assert 'No such file or directory' in "[Errno 2] Datei oder Verzeichnis nicht gefunden: '/tmp/fits-test-Y2tDbp/foobar.fits'"
E            +  where "[Errno 2] Datei oder Verzeichnis nicht gefunden: '/tmp/fits-test-Y2tDbp/foobar.fits'" = str(IOError(2, 'Datei oder Verzeichnis nicht gefunden'))

.../astropy/io/fits/tests/test_core.py:598: AssertionError
======= 4 failed, 9850 passed, 73 skipped, 42 xfailed in 262.66 seconds ========
1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions