test_basicauth_with_netrc() — requests Function Reference
Architecture documentation for the test_basicauth_with_netrc() function in test_requests.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD d49fdae3_788e_3ec8_839b_2f6197fd2ba8["test_basicauth_with_netrc()"] 22b80b19_26d4_cd0e_c476_3edf87b3df14["TestRequests"] d49fdae3_788e_3ec8_839b_2f6197fd2ba8 -->|defined in| 22b80b19_26d4_cd0e_c476_3edf87b3df14 style d49fdae3_788e_3ec8_839b_2f6197fd2ba8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_requests.py lines 675–708
def test_basicauth_with_netrc(self, httpbin):
auth = ("user", "pass")
wrong_auth = ("wronguser", "wrongpass")
url = httpbin("basic-auth", "user", "pass")
old_auth = requests.sessions.get_netrc_auth
try:
def get_netrc_auth_mock(url):
return auth
requests.sessions.get_netrc_auth = get_netrc_auth_mock
# Should use netrc and work.
r = requests.get(url)
assert r.status_code == 200
# Given auth should override and fail.
r = requests.get(url, auth=wrong_auth)
assert r.status_code == 401
s = requests.session()
# Should use netrc and work.
r = s.get(url)
assert r.status_code == 200
# Given auth should override and fail.
s.auth = wrong_auth
r = s.get(url)
assert r.status_code == 401
finally:
requests.sessions.get_netrc_auth = old_auth
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_basicauth_with_netrc() do?
test_basicauth_with_netrc() is a function in the requests codebase, defined in tests/test_requests.py.
Where is test_basicauth_with_netrc() defined?
test_basicauth_with_netrc() is defined in tests/test_requests.py at line 675.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free