Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / lib / python2.4 / test / test_netrc.py
CommitLineData
920dae64
AT
1
2import netrc, os, unittest, sys
3from test import test_support
4
5TEST_NETRC = """
6machine foo login log1 password pass1 account acct1
7
8macdef macro1
9line1
10line2
11
12macdef macro2
13line3
14line4
15
16default login log2 password pass2
17
18"""
19
20temp_filename = test_support.TESTFN
21
22class NetrcTestCase(unittest.TestCase):
23
24 def setUp (self):
25 mode = 'w'
26 if sys.platform not in ['cygwin']:
27 mode += 't'
28 fp = open(temp_filename, mode)
29 fp.write(TEST_NETRC)
30 fp.close()
31 self.netrc = netrc.netrc(temp_filename)
32
33 def tearDown (self):
34 del self.netrc
35 os.unlink(temp_filename)
36
37 def test_case_1(self):
38 self.assert_(self.netrc.macros == {'macro1':['line1\n', 'line2\n'],
39 'macro2':['line3\n', 'line4\n']}
40 )
41 self.assert_(self.netrc.hosts['foo'] == ('log1', 'acct1', 'pass1'))
42 self.assert_(self.netrc.hosts['default'] == ('log2', None, 'pass2'))
43
44def test_main():
45 test_support.run_unittest(NetrcTestCase)
46
47if __name__ == "__main__":
48 test_main()