File: test_token_response_pickleability.py

package info (click to toggle)
python-globus-sdk 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,172 kB
  • sloc: python: 35,227; sh: 44; makefile: 35
file content (31 lines) | stat: -rw-r--r-- 789 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pickle

import pytest

import globus_sdk


@pytest.fixture
def auth_client():
    client = globus_sdk.AuthClient()

    yield client


@pytest.fixture
def token_response(auth_client, make_oauth_token_response):
    return make_oauth_token_response(client=auth_client)


def test_pickle_and_unpickle_no_usage(token_response):
    """
    Test pickle and unpickle, with no usage of the result,
    for all pickle protocol versions supported by the current interpreter.
    """
    pickled_versions = [
        pickle.dumps(token_response, protocol=n)
        for n in range(pickle.HIGHEST_PROTOCOL + 1)
    ]
    unpickled_versions = [pickle.loads(x) for x in pickled_versions]
    for x in unpickled_versions:
        assert x.by_resource_server == token_response.by_resource_server