| 40 | |
| 41 | |
| 42 | class 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)) |
nothing calls this directly
no test coverage detected
searching dependent graphs…