OLD | NEW |
1 """Tests for distutils.command.register.""" | 1 """Tests for distutils.command.register.""" |
2 # -*- encoding: utf8 -*- | 2 # -*- encoding: utf8 -*- |
3 import sys | 3 import sys |
4 import os | 4 import os |
5 import unittest | 5 import unittest |
6 import getpass | 6 import getpass |
7 import urllib2 | 7 import urllib2 |
8 import warnings | 8 import warnings |
9 | 9 |
10 from test.test_support import check_warnings | 10 from test.test_support import check_warnings |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 self.write_file(self.rc, PYPIRC_NOPASSWORD) | 145 self.write_file(self.rc, PYPIRC_NOPASSWORD) |
146 cmd = self._get_cmd() | 146 cmd = self._get_cmd() |
147 cmd._set_config() | 147 cmd._set_config() |
148 cmd.finalize_options() | 148 cmd.finalize_options() |
149 cmd.send_metadata() | 149 cmd.send_metadata() |
150 | 150 |
151 # dist.password should be set | 151 # dist.password should be set |
152 # therefore used afterwards by other commands | 152 # therefore used afterwards by other commands |
153 self.assertEquals(cmd.distribution.password, 'password') | 153 self.assertEquals(cmd.distribution.password, 'password') |
154 | 154 |
| 155 def test_password_set_with_no_config(self): |
| 156 # check credentials are saved in dist if user chooses not to save them |
| 157 # in config file. they are used afterwards by other commands |
| 158 cmd = self._get_cmd() |
| 159 |
| 160 # patching raw_input and getpass.getpass. We are faking: |
| 161 # use your existing login (choice 1.) |
| 162 # Username : 'tarek' |
| 163 # Password : 'password' |
| 164 # Save your login (y/N)? : 'y' |
| 165 inputs = RawInputs('1', 'tarek', 'n') |
| 166 register_module.raw_input = inputs.__call__ |
| 167 try: |
| 168 cmd.run() |
| 169 finally: |
| 170 del register_module.raw_input |
| 171 |
| 172 self.assertEquals(cmd.distribution.username, 'tarek') |
| 173 self.assertEquals(cmd.distribution.password, 'password') |
| 174 |
155 def test_registering(self): | 175 def test_registering(self): |
156 # this test runs choice 2 | 176 # this test runs choice 2 |
157 cmd = self._get_cmd() | 177 cmd = self._get_cmd() |
158 inputs = RawInputs('2', 'tarek', 'tarek@ziade.org') | 178 inputs = RawInputs('2', 'tarek', 'tarek@ziade.org') |
159 register_module.raw_input = inputs.__call__ | 179 register_module.raw_input = inputs.__call__ |
160 try: | 180 try: |
161 # let's run the command | 181 # let's run the command |
162 cmd.run() | 182 cmd.run() |
163 finally: | 183 finally: |
164 del register_module.raw_input | 184 del register_module.raw_input |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 with check_warnings() as w: | 268 with check_warnings() as w: |
249 warnings.simplefilter("always") | 269 warnings.simplefilter("always") |
250 cmd.check_metadata() | 270 cmd.check_metadata() |
251 self.assertEquals(len(w.warnings), 1) | 271 self.assertEquals(len(w.warnings), 1) |
252 | 272 |
253 def test_suite(): | 273 def test_suite(): |
254 return unittest.makeSuite(RegisterTestCase) | 274 return unittest.makeSuite(RegisterTestCase) |
255 | 275 |
256 if __name__ == "__main__": | 276 if __name__ == "__main__": |
257 unittest.main(defaultTest="test_suite") | 277 unittest.main(defaultTest="test_suite") |
OLD | NEW |