2 import netrc
, os
, unittest
, sys
3 from test
import test_support
6 machine foo login log1 password pass1 account acct1
16 default login log2 password pass2
20 temp_filename
= test_support
.TESTFN
22 class NetrcTestCase(unittest
.TestCase
):
26 if sys
.platform
not in ['cygwin']:
28 fp
= open(temp_filename
, mode
)
31 self
.netrc
= netrc
.netrc(temp_filename
)
35 os
.unlink(temp_filename
)
37 def test_case_1(self
):
38 self
.assertTrue(self
.netrc
.macros
== {'macro1':['line1\n', 'line2\n'],
39 'macro2':['line3\n', 'line4\n']}
41 self
.assertTrue(self
.netrc
.hosts
['foo'] == ('log1', 'acct1', 'pass1'))
42 self
.assertTrue(self
.netrc
.hosts
['default'] == ('log2', None, 'pass2'))
45 test_support
.run_unittest(NetrcTestCase
)
47 if __name__
== "__main__":