|
3 | 3 | from __future__ import print_function, absolute_import, division
|
4 | 4 |
|
5 | 5 | import unittest
|
| 6 | +import re |
6 | 7 |
|
7 | 8 | from pusher import Pusher
|
8 | 9 | from pusher.http import Request
|
@@ -49,6 +50,20 @@ def test_post_signature_generation(self):
|
49 | 50 |
|
50 | 51 | json_dumps_mock.assert_called_once_with({u"foo": u"bar"})
|
51 | 52 |
|
| 53 | + # Copied wholesale from https://github.com/python/cpython/blob/2d305e1c46abfcd609bf8b2dff8d2065e6af8ab2/Lib/unittest/case.py#L1279-L1289 |
| 54 | + # This can be removed when we no longer support Python 2.6 |
| 55 | + def assertRegexpMatches(self, text, expected_regex, msg=None): |
| 56 | + """Fail the test unless the text matches the regular expression.""" |
| 57 | + if isinstance(expected_regex, (str, bytes)): |
| 58 | + assert expected_regex, "expected_regex must not be empty." |
| 59 | + expected_regex = re.compile(expected_regex) |
| 60 | + if not expected_regex.search(text): |
| 61 | + standardMsg = "Regex didn't match: %r not found in %r" % ( |
| 62 | + expected_regex.pattern, text) |
| 63 | + # _formatMessage ensures the longMessage option is respected |
| 64 | + msg = self._formatMessage(msg, standardMsg) |
| 65 | + raise self.failureException(msg) |
| 66 | + |
52 | 67 | def test_x_pusher_library_header(self):
|
53 | 68 | conf = Pusher.from_url(u'http://key:secret@somehost/apps/4')
|
54 | 69 | req = Request(conf, u'GET', u'/some/obscure/api', {u'foo': u'bar'})
|
|
0 commit comments