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

Method testNetrcAuth

tests/Authentication.py:270–285  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

268 self.assertEqual(user.login, "EnricoMi")
269
270 def testNetrcAuth(self):
271 with NamedTemporaryFile("wt", delete=False) as tmp:
272 # write temporary netrc file
273 tmp.write("machine api.github.com\n")
274 tmp.write("login github-user\n")
275 tmp.write("password github-password\n")
276 tmp.close()
277
278 auth = github.Auth.NetrcAuth()
279 with mock.patch.dict(os.environ, {"NETRC": tmp.name}):
280 github.Github(auth=auth)
281
282 self.assertEqual(auth.login, "github-user")
283 self.assertEqual(auth.password, "github-password")
284 self.assertEqual(auth.token, "Z2l0aHViLXVzZXI6Z2l0aHViLXBhc3N3b3Jk")
285 self.assertEqual(auth.token_type, "Basic")
286
287 def testNetrcAuthFails(self):
288 # provide an empty netrc file to make sure this test does not find one

Callers

nothing calls this directly

Calls 2

writeMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected