194 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
194 self.assertEqual(r.advertisedbaseurl, b'http://testserver') |
195 self.assertEqual(r.apppath, b'/script') |
195 self.assertEqual(r.apppath, b'/script') |
196 self.assertEqual(r.dispatchparts, [b'pathinfo']) |
196 self.assertEqual(r.dispatchparts, [b'pathinfo']) |
197 self.assertEqual(r.dispatchpath, b'pathinfo') |
197 self.assertEqual(r.dispatchpath, b'pathinfo') |
198 |
198 |
|
199 if not getattr(unittest.TestCase, 'assertRaisesRegex', False): |
|
200 # Python 3.7 deprecates the regex*p* version, but 2.7 lacks |
|
201 # the regex version. |
|
202 assertRaisesRegex = (# camelcase-required |
|
203 unittest.TestCase.assertRaisesRegexp) |
|
204 |
199 def testreponame(self): |
205 def testreponame(self): |
200 """repository path components get stripped from URL.""" |
206 """repository path components get stripped from URL.""" |
201 |
207 |
202 with self.assertRaisesRegexp(error.ProgrammingError, |
208 with self.assertRaisesRegex(error.ProgrammingError, |
203 b'reponame requires PATH_INFO'): |
209 b'reponame requires PATH_INFO'): |
204 parse(DEFAULT_ENV, reponame=b'repo') |
210 parse(DEFAULT_ENV, reponame=b'repo') |
205 |
211 |
206 with self.assertRaisesRegexp(error.ProgrammingError, |
212 with self.assertRaisesRegex(error.ProgrammingError, |
207 b'PATH_INFO does not begin with repo ' |
213 b'PATH_INFO does not begin with repo ' |
208 b'name'): |
214 b'name'): |
209 parse(DEFAULT_ENV, reponame=b'repo', extra={ |
215 parse(DEFAULT_ENV, reponame=b'repo', extra={ |
210 r'PATH_INFO': r'/pathinfo', |
216 r'PATH_INFO': r'/pathinfo', |
211 }) |
217 }) |
212 |
218 |
213 with self.assertRaisesRegexp(error.ProgrammingError, |
219 with self.assertRaisesRegex(error.ProgrammingError, |
214 b'reponame prefix of PATH_INFO'): |
220 b'reponame prefix of PATH_INFO'): |
215 parse(DEFAULT_ENV, reponame=b'repo', extra={ |
221 parse(DEFAULT_ENV, reponame=b'repo', extra={ |
216 r'PATH_INFO': r'/repoextra/path', |
222 r'PATH_INFO': r'/repoextra/path', |
217 }) |
223 }) |
218 |
224 |