Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_netrc.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 19c0f817cb47 |
| children | e5c4eb6b8e05 6768b2350c57 4bb6a0c353ab |
| rev | line source |
|---|---|
|
22542
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
1 |
|
30120
19c0f817cb47
Unconditionally opening the temp file in text mode causes this test to fail
Jason Tishler <jason@tishler.net>
parents:
27912
diff
changeset
|
2 import netrc, os, unittest, sys |
|
24364
aa0d2d51fbde
Get rid of relative imports in all unittests. Now anything that
Barry Warsaw <barry@python.org>
parents:
23075
diff
changeset
|
3 from test import test_support |
|
22542
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
4 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
5 TEST_NETRC = """ |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
6 machine foo login log1 password pass1 account acct1 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
7 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
8 macdef macro1 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
9 line1 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
10 line2 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
11 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
12 macdef macro2 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
13 line3 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
14 line4 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
15 |
|
23075
b7e87732f6ab
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
22542
diff
changeset
|
16 default login log2 password pass2 |
|
22542
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
17 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
18 """ |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
19 |
|
24710
11c701038805
Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Guido van Rossum <guido@python.org>
parents:
24364
diff
changeset
|
20 temp_filename = test_support.TESTFN |
|
22542
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
21 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
22 class NetrcTestCase(unittest.TestCase): |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
23 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
24 def setUp (self): |
|
30120
19c0f817cb47
Unconditionally opening the temp file in text mode causes this test to fail
Jason Tishler <jason@tishler.net>
parents:
27912
diff
changeset
|
25 mode = 'w' |
|
19c0f817cb47
Unconditionally opening the temp file in text mode causes this test to fail
Jason Tishler <jason@tishler.net>
parents:
27912
diff
changeset
|
26 if sys.platform not in ['cygwin']: |
|
19c0f817cb47
Unconditionally opening the temp file in text mode causes this test to fail
Jason Tishler <jason@tishler.net>
parents:
27912
diff
changeset
|
27 mode += 't' |
|
19c0f817cb47
Unconditionally opening the temp file in text mode causes this test to fail
Jason Tishler <jason@tishler.net>
parents:
27912
diff
changeset
|
28 fp = open(temp_filename, mode) |
|
22542
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
29 fp.write(TEST_NETRC) |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
30 fp.close() |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
31 self.netrc = netrc.netrc(temp_filename) |
|
23075
b7e87732f6ab
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
22542
diff
changeset
|
32 |
|
22542
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
33 def tearDown (self): |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
34 del self.netrc |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
35 os.unlink(temp_filename) |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
36 |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
37 def test_case_1(self): |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
38 self.assert_(self.netrc.macros == {'macro1':['line1\n', 'line2\n'], |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
39 'macro2':['line3\n', 'line4\n']} |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
40 ) |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
41 self.assert_(self.netrc.hosts['foo'] == ('log1', 'acct1', 'pass1')) |
|
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
42 self.assert_(self.netrc.hosts['default'] == ('log2', None, 'pass2')) |
|
23075
b7e87732f6ab
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
22542
diff
changeset
|
43 |
|
27912
c5ebacbba0be
Actually run these tests from regrtest.py.
Neal Norwitz <nnorwitz@gmail.com>
parents:
24710
diff
changeset
|
44 def test_main(): |
|
c5ebacbba0be
Actually run these tests from regrtest.py.
Neal Norwitz <nnorwitz@gmail.com>
parents:
24710
diff
changeset
|
45 test_support.run_unittest(NetrcTestCase) |
|
23075
b7e87732f6ab
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
22542
diff
changeset
|
46 |
|
22542
16e542af2c45
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
diff
changeset
|
47 if __name__ == "__main__": |
|
27912
c5ebacbba0be
Actually run these tests from regrtest.py.
Neal Norwitz <nnorwitz@gmail.com>
parents:
24710
diff
changeset
|
48 test_main() |
