Lines Matching refs:self

48     def __init__(self, url, msg=None, code=None):
49 self.url = url
51 self.req = url
53 self.req = None
54 self.msg = msg or 'OK'
55 self.code = code or 200
57 def getheader(self, name, default=None):
62 def read(self):
65 def getcode(self):
66 return self.code
71 def setUp(self):
72 super(uploadTestCase, self).setUp()
73 self.old_open = upload_mod.urlopen
74 upload_mod.urlopen = self._urlopen
75 self.last_open = None
76 self.next_msg = None
77 self.next_code = None
79 def tearDown(self):
80 upload_mod.urlopen = self.old_open
81 super(uploadTestCase, self).tearDown()
83 def _urlopen(self, url):
84 self.last_open = FakeOpen(url, msg=self.next_msg, code=self.next_code)
85 return self.last_open
87 def test_finalize_options(self):
90 self.write_file(self.rc, PYPIRC)
97 self.assertEqual(getattr(cmd, attr), waited)
99 def test_saved_password(self):
101 self.write_file(self.rc, PYPIRC_NOPASSWORD)
107 self.assertEqual(cmd.password, None)
114 self.assertEqual(cmd.password, 'xxx')
116 def test_upload(self):
117 tmp = self.mkdtemp()
119 self.write_file(path)
122 self.write_file(self.rc, PYPIRC_LONG_PASSWORD)
125 pkg_dir, dist = self.create_dist(dist_files=dist_files)
132 headers = dict(self.last_open.req.headers)
133 self.assertGreaterEqual(int(headers['Content-length']), 2162)
135 self.assertTrue(content_type.startswith('multipart/form-data'))
136 self.assertEqual(self.last_open.req.get_method(), 'POST')
138 self.assertEqual(self.last_open.req.get_full_url(), expected_url)
139 data = self.last_open.req.data
140 self.assertIn(b'xxx',data)
141 self.assertIn(b'protocol_version', data)
142 self.assertIn(b'sha256_digest', data)
143 self.assertIn(
149 self.assertIn(b'f561aaf6ef0bf14d4208bb46a4ccb3ad', data)
151 self.assertIn(
159 results = self.get_logs(INFO)
160 self.assertEqual(results[-1], 75 * '-' + '\nxyzzy\n' + 75 * '-')
164 def test_upload_correct_cr(self):
166 tmp = self.mkdtemp()
168 self.write_file(path, content='yy\r')
171 self.write_file(self.rc, PYPIRC_LONG_PASSWORD)
175 pkg_dir, dist = self.create_dist(
184 headers = dict(self.last_open.req.headers)
185 self.assertGreaterEqual(int(headers['Content-length']), 2172)
186 self.assertIn(b'long description\r', self.last_open.req.data)
188 def test_upload_fails(self):
189 self.next_msg = "Not Found"
190 self.next_code = 404
191 self.assertRaises(DistutilsError, self.test_upload)
193 def test_wrong_exception_order(self):
194 tmp = self.mkdtemp()
196 self.write_file(path)
198 self.write_file(self.rc, PYPIRC_LONG_PASSWORD)
200 pkg_dir, dist = self.create_dist(dist_files=dist_files)
207 with self.subTest(exception=type(exception).__name__):
210 with self.assertRaises(raised_exception):
214 results = self.get_logs(ERROR)
215 self.assertIn(expected, results[-1])
216 self.clear_logs()