Skip to content

How to use Ignore packages #420

@lucemia

Description

@lucemia

While I use freezegun with google storage api, I got the following error.

google.auth.exceptions.RefreshError: ('invalid_grant: Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim.', {'error': 'invalid_grant', 'error_description': 'Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim.'})

I think ignore packages may solve the problem. Ref: #185

Sometimes it's desired to ignore FreezeGun behaviour for particular packages (i.e. libraries). It's possible to ignore them for a single invocation:

I tried add ["google", "google.auth", "google.cloud"] in ignore list, but still got the same error.

from google.cloud import storage
import freezegun

ig_ms = ["google", "google.oauth2", "urllib3", "google.cloud"]
freezegun.configure(extend_ignore_list=ig_ms)


with freezegun.freeze_time("2017-05-21", ignore=ig_ms):
    client = storage.Client()

    print(list(client.list_buckets()))

I am confused about how to use Ignore Packages correctly.
For example:

import urllib3
import freezegun

with freezegun.freeze_time("2017-05-21", ignore=['urllib3']):
    http = urllib3.PoolManager()
    resp = http.request("GET", "https://httpbin.org/robots.txt")
    print(resp.status)

whether I add urllib3 to ignore list or not,
it will still raise SystemTimeWarning: System time is way off (before 2020-07-01). This will probably lead to SSL verification errors

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