8000 gh-135788: Support NETRC environment variable in `netrc` by berthin · Pull Request #135802 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-135788: Support NETRC environment variable in netrc #135802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
undo 80 chars, try again with os_helper.temp_dir
  • Loading branch information
Berthin Torres authored and Berthin Torres committed Jun 22, 2025
commit b4c22e9279b969be69a5bcd619245269362b4624
10 changes: 4 additions & 6 deletions Lib/test/test_netrc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import netrc, os, unittest, sys, tempfile, textwrap
import netrc, os, unittest, sys, textwrap
from contextlib import ExitStack
from test.support import os_helper, subTests
from unittest import mock
Expand All @@ -24,7 +24,7 @@ def __enter__(self):
self.environ = self.stack.enter_context(
os_helper.EnvironmentVarGuard(),
)
self.tmpdir = self.stack.enter_context(tempfile.TemporaryDirectory())
self.tmpdir = self.stack.enter_context(os_helper.temp_dir())
return self

def __exit__(self, *ignore_exc):
Expand Down Expand Up @@ -110,8 +110,7 @@ def test_toplevel_non_ordered_tokens(self, make_nrc):
machine host.domain.com password pass1 login log1 account acct1
default login log2 password pass2 account acct2
""")
self.assertEqual(nrc.hosts['host.domain.com'],
('log1', 'acct1', 'pass1'))
self.assertEqual(nrc.hosts['host.domain.com'], ('log1', 'acct1', 'pass1'))
self.assertEqual(nrc.hosts['default'], ('log2', 'acct2', 'pass2'))

@subTests('make_nrc', ALL_NETRC_FILE_SCENARIOS)
Expand All @@ -120,8 +119,7 @@ def test_toplevel_tokens(self, make_nrc):
machine host.domain.com login log1 password pass1 account acct1
default login log2 password pass2 account acct2
""")
self.assertEqual(nrc.hosts['host.domain.com'],
('log1', 'acct1', 'pass1'))
self.assertEqual(nrc.hosts['host.domain.com'], ('log1', 'acct1', 'pass1'))
self.assertEqual(nrc.hosts['default'], ('log2', 'acct2', 'pass2'))

@subTests('make_nrc', ALL_NETRC_FILE_SCENARIOS)
Expand Down
Loading
0