diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-11-03 05:36:45 (GMT) |
---|---|---|
committer | INADA Naoki <methane@users.noreply.github.com> | 2017-11-03 05:36:45 (GMT) |
commit | 5fbe5e161c969bc8a0d44a301152f8bf5afe0fc7 (patch) | |
tree | d6d61da7994445e913f232dbf8c049e8cbb42eba /Lib/test | |
parent | 7891556b5cc98e546f905b4a5778e7cd7d9a0c7c (diff) | |
download | cpython-5fbe5e161c969bc8a0d44a301152f8bf5afe0fc7.zip cpython-5fbe5e161c969bc8a0d44a301152f8bf5afe0fc7.tar.gz cpython-5fbe5e161c969bc8a0d44a301152f8bf5afe0fc7.tar.bz2 |
bpo-30806: Fix netrc.__repr__() format (GH-2491)
netrc file format doesn't support quotes and escapes.
See https://linux.die.net/man/5/netrc
(cherry picked from commit b24cd055ecb3eea9a15405a6ca72dafc739e6531)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_netrc.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_netrc.py b/Lib/test/test_netrc.py index 60a3ec9..ca6f27d 100644 --- a/Lib/test/test_netrc.py +++ b/Lib/test/test_netrc.py @@ -1,7 +1,6 @@ -import netrc, os, unittest, sys, textwrap +import netrc, os, unittest, sys, tempfile, textwrap from test import support -temp_filename = support.TESTFN class NetrcTestCase(unittest.TestCase): @@ -10,7 +9,8 @@ class NetrcTestCase(unittest.TestCase): mode = 'w' if sys.platform != 'cygwin': mode += 't' - with open(temp_filename, mode) as fp: + temp_fd, temp_filename = tempfile.mkstemp() + with os.fdopen(temp_fd, mode=mode) as fp: fp.write(test_data) self.addCleanup(os.unlink, temp_filename) return netrc.netrc(temp_filename) @@ -24,6 +24,9 @@ class NetrcTestCase(unittest.TestCase): ('log1', 'acct1', 'pass1')) self.assertEqual(nrc.hosts['default'], ('log2', None, 'pass2')) + nrc2 = self.make_nrc(nrc.__repr__()) + self.assertEqual(nrc.hosts, nrc2.hosts) + def test_macros(self): nrc = self.make_nrc("""\ macdef macro1 |