MCPcopy
hub / github.com/psf/requests / test_basicauth_encodes_byte_strings

Method test_basicauth_encodes_byte_strings

tests/test_requests.py:572–580  ·  view source on GitHub ↗

Ensure b'test' formats as the byte string "test" rather than the unicode string "b'test'" in Python 3.

(self)

Source from the content-addressed store, hash-verified

570 assert p.headers["Authorization"] == _basic_auth_str(username, password)
571
572 def test_basicauth_encodes_byte_strings(self):
573 """Ensure b'test' formats as the byte string "test" rather
574 than the unicode string "b'test'" in Python 3.
575 """
576 auth = (b"\xc5\xafsername", b"test\xc6\xb6")
577 r = requests.Request("GET", "http://localhost", auth=auth)
578 p = r.prepare()
579
580 assert p.headers["Authorization"] == "Basic xa9zZXJuYW1lOnRlc3TGtg=="
581
582 @pytest.mark.parametrize(
583 "url, exception",

Callers

nothing calls this directly

Calls 1

prepareMethod · 0.95

Tested by

no test coverage detected