question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sporadic test failures in `test_name_resolve_cache`

See original GitHub issue

Description

I am seeing inconsistent failures in the above test when get_icrs_coordinates is not using the expected URL:

    @pytest.mark.remote_data
    def test_name_resolve_cache(tmpdir):
        from astropy.utils.data import get_cached_urls
    
        target_name = "castor"
    
        temp_cache_dir = str(tmpdir.mkdir('cache'))
        with paths.set_temp_cache(temp_cache_dir, delete=True):
            assert len(get_cached_urls()) == 0
    
            icrs1 = get_icrs_coordinates(target_name, cache=True)
    
            urls = get_cached_urls()
            assert len(urls) == 1
>           assert 'http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/' in urls[0]
E           AssertionError: assert 'http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/' in 'http://vizier.cfa.harvard.edu/viz-bin/nph-sesame/A?castor'

/opt/lib/python3.9/site-packages/astropy/coordinates/tests/test_name_resolve.py:158: AssertionError

Apparently the function is somewhat randomly using the Vizier instead of the CDS mirror (this is from a European domain).

System Details

macOS-10.14.6-x86_64-i386-64bit Python 3.9.5 (default, May 14 2021, 02:39:23) [Clang 11.0.0 (clang-1100.0.33.17)] Numpy 1.21.0rc2 astropy 4.3rc1 Scipy 1.6.3 Matplotlib 3.3.3

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
nstarmancommented, Jun 21, 2021

is there a generic kind of “assert_or” that would do … for any length of sesame_url?

import operator
any(map(operator.contains, urls, sesame_url))

Wait. That almost works. Also need an itertools ~permute~ product.

Edit: Here’s something that works for any length urls and sesame_url, exploring all permutations

import operator
import itertools

urls = ["aa", "bb"]
sesame_url = ["ac", "ca"]

mixed = tuple(itertools.product(urls, sesame_url)) 
any(map(operator.contains, (elt[0] for elt in mixed), (elt[1] for elt in mixed)))
1reaction
pllimcommented, Jun 22, 2021

Does #11871 work for you?

p.s. I am unable to tag @nstarman as a reviewer, so FYI here. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a good test review process for sporadic failures
i am talking about test problems. this is where usually a failure is sporadic. Indeed the tests can fail for reasons like networking....
Read more >
How to Fix Flaky Tests - Semaphore CI
Randomly failing tests are the hardest to debug. Here's a framework you can use to fix them and keep your test suite healthy....
Read more >
How to reduce flaky test failures - CircleCI
Flaky tests, also known as flappers, fail to produce accurate and consistent results. These tests may be unreliable because of newly-written ...
Read more >
Debugging Intermittent Test Failures - Firefox Source Docs
Intermittents are test failures which happen intermittently, in a seemingly random way. Often you'll write a test that passes fine locally on your...
Read more >
Diagnosing Random Angular Test Failures - WalkingRiver.com
Have you ever had an intermittent or random failure in your unit tests? ... The fact that the new test and the failing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found