Skip to content

flaky test_ip_fallback #466

@karlicoss

Description

@karlicoss

Hey @purarue thought you might have a hunch what's the best way to fix this!
Getting this consistently almost every other CI run.

def test_ip_fallback() -> None:

=================================== FAILURES ===================================
_______________________________ test_ip_fallback _______________________________

    def test_ip_fallback() -> None:
        # precondition, make sure that the data override works
        assert ilen(ip_module.ips()) == ilen(data())
>       assert ilen(ip_module.ips()) == ilen(via_ip.fallback_locations())
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/my/tests/location/fallback.py:23: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/tests-all/lib/python3.13/site-packages/more_itertools/more.py:536: in ilen
    return sum(compress(repeat(1), zip(iterable)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
my/location/fallback/via_ip.py:45: in fallback_locations
    lat, lon = ip.latlon
               ^^^^^^^^^
my/ip/common.py:27: in latlon
    loc: str = self.ipgeocache()["loc"]
               ^^^^^^^^^^^^^^^^^
my/ip/common.py:23: in ipgeocache
    return ipgeocache.get(self.addr)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/tests-all/lib/python3.13/site-packages/ipgeocache/__init__.py:120: in get
    return get_from_cache_or_request(
.tox/tests-all/lib/python3.13/site-packages/ipgeocache/__init__.py:99: in get_from_cache_or_request
    resp.raise_for_status()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Response [429]>

    def raise_for_status(self):
        """Raises :class:`HTTPError`, if one occurred."""
    
        http_error_msg = ""
        if isinstance(self.reason, bytes):
            # We attempt to decode utf-8 first because some servers
            # choose to localize their reason strings. If the string
            # isn't utf-8, we fall back to iso-8859-1 for all other
            # encodings. (See PR #3538)
            try:
                reason = self.reason.decode("utf-8")
            except UnicodeDecodeError:
                reason = self.reason.decode("iso-8859-1")
        else:
            reason = self.reason
    
        if 400 <= self.status_code < 500:
            http_error_msg = (
                f"{self.status_code} Client Error: {reason} for url: {self.url}"
            )
    
        elif 500 <= self.status_code < 600:
            http_error_msg = (
                f"{self.status_code} Server Error: {reason} for url: {self.url}"
            )
    
        if http_error_msg:
>           raise HTTPError(http_error_msg, response=self)
E           requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://ipinfo.io/67.98.113.0

.tox/tests-all/lib/python3.13/site-packages/requests/models.py:1026: HTTPError

From a quick look, it seems like it's always this IP, but I'm confused a bit -- thought the point was that requests to ipinfo would be cached? So kinda confused what's causing it

yield IP(addr="67.98.113.0", dt=datetime(2020, 1, 1, 12, 0, 0, tzinfo=timezone.utc))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions