MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / Pickle

Class Pickle

tests/Pickle.py:42–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40
41
42class Pickle(Framework.TestCase):
43 def testPickleGithub(self):
44 gh = github.Github()
45 gh2 = pickle.loads(pickle.dumps(gh))
46 self.assertIsInstance(gh2, github.Github)
47 self.assertIsNotNone(gh2._Github__requester._Requester__connection_lock)
48 self.assertIsNone(gh2._Github__requester._Requester__connection)
49 self.assertEqual(len(gh2._Github__requester._Requester__custom_connections), 0)
50
51 def testPickleRepository(self):
52 gh = github.Github(lazy=True)
53 repo = gh.get_repo(REPO_NAME)
54 repo2 = pickle.loads(pickle.dumps(repo))
55 self.assertIsInstance(repo2, Repository)
56 self.assertIsNotNone(repo2._requester._Requester__connection_lock)
57 self.assertIsNone(repo2._requester._Requester__connection)
58 self.assertEqual(len(repo2._requester._Requester__custom_connections), 0)
59
60 def testPicklePaginatedList(self):
61 gh = github.Github()
62 repo = gh.get_repo(REPO_NAME, lazy=True)
63 branches = repo.get_branches()
64 branches2 = pickle.loads(pickle.dumps(branches))
65 self.assertIsInstance(branches2, PaginatedList)
66
67 auths = [
68 Login("login", "password"),
69 Token("token"),
70 AppAuth("id", "key"),
71 AppAuthToken("token"),
72 AppInstallationAuth(AppAuth("id", "key"), 123),
73 AppUserAuth("client_id", "client_secret", "access_token"),
74 NetrcAuth(),
75 ]
76
77 def testPickleAuthSetup(self):
78 # check we are testing *all* exiting auth classes
79 auth_module = sys.modules[github.Auth.__name__]
80 existing_auths = [
81 clazz_type.__name__
82 for clazz, clazz_type in inspect.getmembers(auth_module, inspect.isclass)
83 if Auth in clazz_type.mro() and ABC not in clazz_type.__bases__
84 ]
85 tested_auths = [type(auth).__name__ for auth in self.auths]
86 self.assertSequenceEqual(sorted(existing_auths), sorted(tested_auths))
87
88 def testPickleAuth(self):
89 for auth in self.auths:
90 with self.subTest(auth=type(auth).__name__):
91 auth2 = pickle.loads(pickle.dumps(auth))
92 self.assertIsInstance(auth2, type(auth))

Callers

nothing calls this directly

Calls 7

LoginClass · 0.90
TokenClass · 0.90
AppAuthClass · 0.90
AppAuthTokenClass · 0.90
AppInstallationAuthClass · 0.90
AppUserAuthClass · 0.90
NetrcAuthClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…