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
fix linting issues
  • Loading branch information
Berthin Torres authored and Berthin Torres committed Jun 21, 2025
commit c1e3abfa8e017681a040d5bdfb03f861c3b2d4ee
8 changes: 4 additions & 4 deletions Lib/test/test_netrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def generate_netrc(self, content, filename=".netrc", mode=0o600, encoding="utf-8
write_mode = "w"
if sys.platform != "cygwin":
write_mode += "t"

netrc_file = os.path.join(self.tmpdir, filename)
with open(netrc_file, mode=write_mode, encoding=encoding) as fp:
fp.write(textwrap.dedent(content))
Expand All @@ -40,7 +40,7 @@ def use_default_netrc_in_home(*args, **kwargs):
with NetrcEnvironment() as helper:
helper.environ.unset("NETRC")
helper.environ.unset("HOME")

helper.generate_netrc(*args, **kwargs)

with mock.patch("os.path.expanduser"):
Expand All @@ -54,7 +54,7 @@ def use_netrc_envvar(*args, **kwargs):

helper.environ.set("NETRC", netrc_file)
return netrc.netrc()

@staticmethod
def use_file_argument(*args, **kwargs):
with NetrcEnvironment() as helper:
Expand Down Expand Up @@ -157,7 +157,7 @@ def _test_token_x(self, make_nrc, content, token, value):
self.assertEqual(nrc.hosts['host.domain.com'], ('log', value, 'pass'))
elif token == 'password':
self.assertEqual(nrc.hosts['host.domain.com'], ('log', 'acct', value))

@support.subTests('make_nrc', ALL_STRATEGIES)
def test_token_value_quotes(self, make_nrc):
self._test_token_x(make_nrc, """\
Expand Down
Loading
0