]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/tests/test_config.py
1 """Tests for distutils.pypirc.pypirc."""
8 from distutils
.core
import PyPIRCCommand
9 from distutils
.core
import Distribution
10 from distutils
.log
import set_threshold
11 from distutils
.log
import WARN
13 from distutils
.tests
import support
14 from test
.test_support
import run_unittest
31 repository:http://another.pypi/
51 class PyPIRCCommandTestCase(support
.TempdirManager
,
52 support
.LoggingSilencer
,
57 """Patches the environment."""
58 super(PyPIRCCommandTestCase
, self
).setUp()
59 self
.tmp_dir
= self
.mkdtemp()
60 os
.environ
['HOME'] = self
.tmp_dir
61 self
.rc
= os
.path
.join(self
.tmp_dir
, '.pypirc')
62 self
.dist
= Distribution()
64 class command(PyPIRCCommand
):
65 def __init__(self
, dist
):
66 PyPIRCCommand
.__init
__(self
, dist
)
67 def initialize_options(self
):
69 finalize_options
= initialize_options
72 self
.old_threshold
= set_threshold(WARN
)
75 """Removes the patch."""
76 set_threshold(self
.old_threshold
)
77 super(PyPIRCCommandTestCase
, self
).tearDown()
79 def test_server_registration(self
):
80 # This test makes sure PyPIRCCommand knows how to:
81 # 1. handle several sections in .pypirc
82 # 2. handle the old format
85 self
.write_file(self
.rc
, PYPIRC
)
86 cmd
= self
._cmd
(self
.dist
)
87 config
= cmd
._read
_pypirc
()
89 config
= config
.items()
91 waited
= [('password', 'secret'), ('realm', 'pypi'),
92 ('repository', 'http://pypi.python.org/pypi'),
93 ('server', 'server1'), ('username', 'me')]
94 self
.assertEqual(config
, waited
)
97 self
.write_file(self
.rc
, PYPIRC_OLD
)
98 config
= cmd
._read
_pypirc
()
99 config
= config
.items()
101 waited
= [('password', 'secret'), ('realm', 'pypi'),
102 ('repository', 'http://pypi.python.org/pypi'),
103 ('server', 'server-login'), ('username', 'tarek')]
104 self
.assertEqual(config
, waited
)
106 def test_server_empty_registration(self
):
107 cmd
= self
._cmd
(self
.dist
)
108 rc
= cmd
._get
_rc
_file
()
109 self
.assertTrue(not os
.path
.exists(rc
))
110 cmd
._store
_pypirc
('tarek', 'xxx')
111 self
.assertTrue(os
.path
.exists(rc
))
115 self
.assertEqual(content
, WANTED
)
120 return unittest
.makeSuite(PyPIRCCommandTestCase
)
122 if __name__
== "__main__":
123 run_unittest(test_suite())