Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11)

Side by Side Diff: Lib/packaging/tests/test_command_register.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 """Tests for packaging.command.register.""" 1 """Tests for packaging.command.register."""
2 import os 2 import os
3 import getpass 3 import getpass
4 import urllib.request 4 import urllib.request
5 import urllib.error 5 import urllib.error
6 import urllib.parse 6 import urllib.parse
7 7
8 try: 8 try:
9 import docutils 9 import docutils
10 DOCUTILS_SUPPORT = True 10 DOCUTILS_SUPPORT = True
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 cmd.show_response = True 145 cmd.show_response = True
146 cmd.ensure_finalized() 146 cmd.ensure_finalized()
147 cmd.run() 147 cmd.run()
148 148
149 # let's see what the server received : we should 149 # let's see what the server received : we should
150 # have 2 similar requests 150 # have 2 similar requests
151 self.assertEqual(len(self.conn.reqs), 2) 151 self.assertEqual(len(self.conn.reqs), 2)
152 req1 = dict(self.conn.reqs[0].headers) 152 req1 = dict(self.conn.reqs[0].headers)
153 req2 = dict(self.conn.reqs[1].headers) 153 req2 = dict(self.conn.reqs[1].headers)
154 self.assertEqual(req2['Content-length'], req1['Content-length']) 154 self.assertEqual(req2['Content-length'], req1['Content-length'])
155 self.assertIn(b'xxx', self.conn.reqs[1].data) 155 self.assertIn('xxx', self.conn.reqs[1].data)
156 156
157 def test_password_not_in_file(self): 157 def test_password_not_in_file(self):
158 158
159 self.write_file(self.rc, PYPIRC_NOPASSWORD) 159 self.write_file(self.rc, PYPIRC_NOPASSWORD)
160 cmd = self._get_cmd() 160 cmd = self._get_cmd()
161 cmd.finalize_options() 161 cmd.finalize_options()
162 cmd._set_config() 162 cmd._set_config()
163 cmd.send_metadata() 163 cmd.send_metadata()
164 164
165 # dist.password should be set 165 # dist.password should be set
166 # therefore used afterwards by other commands 166 # therefore used afterwards by other commands
167 self.assertEqual(cmd.distribution.password, 'password') 167 self.assertEqual(cmd.distribution.password, 'password')
168 168
169 def test_registration(self): 169 def test_registration(self):
170 # this test runs choice 2 170 # this test runs choice 2
171 cmd = self._get_cmd() 171 cmd = self._get_cmd()
172 inputs = Inputs('2', 'tarek', 'tarek@ziade.org') 172 inputs = Inputs('2', 'tarek', 'tarek@ziade.org')
173 register_module.input = inputs 173 register_module.input = inputs
174 # let's run the command 174 # let's run the command
175 # FIXME does this send a real request? use a mock server 175 # FIXME does this send a real request? use a mock server
176 cmd.ensure_finalized() 176 cmd.ensure_finalized()
177 cmd.run() 177 cmd.run()
178 178
179 # we should have send a request 179 # we should have send a request
180 self.assertEqual(len(self.conn.reqs), 1) 180 self.assertEqual(len(self.conn.reqs), 1)
181 req = self.conn.reqs[0] 181 req = self.conn.reqs[0]
182 headers = dict(req.headers) 182 headers = dict(req.headers)
183 self.assertEqual(headers['Content-length'], '628') 183 self.assertEqual(headers['Content-length'], '608')
184 self.assertIn(b'tarek', req.data) 184 self.assertIn('tarek', req.data)
185 185
186 def test_password_reset(self): 186 def test_password_reset(self):
187 # this test runs choice 3 187 # this test runs choice 3
188 cmd = self._get_cmd() 188 cmd = self._get_cmd()
189 inputs = Inputs('3', 'tarek@ziade.org') 189 inputs = Inputs('3', 'tarek@ziade.org')
190 register_module.input = inputs 190 register_module.input = inputs
191 cmd.ensure_finalized() 191 cmd.ensure_finalized()
192 cmd.run() 192 cmd.run()
193 193
194 # we should have send a request 194 # we should have send a request
195 self.assertEqual(len(self.conn.reqs), 1) 195 self.assertEqual(len(self.conn.reqs), 1)
196 req = self.conn.reqs[0] 196 req = self.conn.reqs[0]
197 headers = dict(req.headers) 197 headers = dict(req.headers)
198 self.assertEqual(headers['Content-length'], '298') 198 self.assertEqual(headers['Content-length'], '290')
199 self.assertIn(b'tarek', req.data) 199 self.assertIn('tarek', req.data)
200 200
201 @unittest.skipUnless(DOCUTILS_SUPPORT, 'needs docutils') 201 @unittest.skipUnless(DOCUTILS_SUPPORT, 'needs docutils')
202 def test_strict(self): 202 def test_strict(self):
203 # testing the script option 203 # testing the script option
204 # when on, the register command stops if 204 # when on, the register command stops if
205 # the metadata is incomplete or if 205 # the metadata is incomplete or if
206 # long_description is not reSt compliant 206 # long_description is not reSt compliant
207 207
208 # empty metadata 208 # empty metadata
209 cmd = self._get_cmd({'name': 'xxx', 'version': 'xxx'}) 209 cmd = self._get_cmd({'name': 'xxx', 'version': 'xxx'})
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 data = cmd.build_post_data('submit') 250 data = cmd.build_post_data('submit')
251 self.assertEqual(data['metadata_version'], '1.2') 251 self.assertEqual(data['metadata_version'], '1.2')
252 self.assertEqual(data['requires_dist'], ['lxml']) 252 self.assertEqual(data['requires_dist'], ['lxml'])
253 253
254 254
255 def test_suite(): 255 def test_suite():
256 return unittest.makeSuite(RegisterTestCase) 256 return unittest.makeSuite(RegisterTestCase)
257 257
258 if __name__ == "__main__": 258 if __name__ == "__main__":
259 unittest.main(defaultTest="test_suite") 259 unittest.main(defaultTest="test_suite")
OLDNEW
« no previous file with comments | « Lib/packaging/tests/test_command_build_ext.py ('k') | Lib/packaging/tests/test_command_upload_docs.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+