33from test import support
44
55TEST_NETRC = """
6+
7+ #this is a comment
8+ #this is a comment
9+ # this is a comment
10+
611machine foo login log1 password pass1 account acct1
12+ machine bar login log1 password pass# account acct1
713
814macdef macro1
915line1
@@ -28,17 +34,21 @@ def setUp(self):
2834 fp = open (temp_filename , mode )
2935 fp .write (TEST_NETRC )
3036 fp .close ()
37+ self .nrc = netrc .netrc (temp_filename )
3138
3239 def tearDown (self ):
3340 os .unlink (temp_filename )
3441
3542 def test_case_1 (self ):
36- nrc = netrc .netrc (temp_filename )
37- self .assertTrue (nrc .macros == {'macro1' :['line1\n ' , 'line2\n ' ],
38- 'macro2' :['line3\n ' , 'line4\n ' ]}
39- )
40- self .assertTrue (nrc .hosts ['foo' ] == ('log1' , 'acct1' , 'pass1' ))
41- self .assertTrue (nrc .hosts ['default' ] == ('log2' , None , 'pass2' ))
43+ self .assertEqual (self .nrc .hosts ['foo' ], ('log1' , 'acct1' , 'pass1' ))
44+ self .assertEqual (self .nrc .hosts ['default' ], ('log2' , None , 'pass2' ))
45+
46+ def test_macros (self ):
47+ self .assertEqual (self .nrc .macros , {'macro1' :['line1\n ' , 'line2\n ' ],
48+ 'macro2' :['line3\n ' , 'line4\n ' ]})
49+
50+ def test_parses_passwords_with_hash_character (self ):
51+ self .assertEqual (self .nrc .hosts ['bar' ], ('log1' , 'acct1' , 'pass#' ))
4252
4353def test_main ():
4454 support .run_unittest (NetrcTestCase )
0 commit comments