diff --git a/rollbar/test/__init__.py b/rollbar/test/__init__.py index 2a8cdfda..a29edd85 100644 --- a/rollbar/test/__init__.py +++ b/rollbar/test/__init__.py @@ -1,11 +1,11 @@ -import unittest2 +import unittest SNOWMAN = b'\xe2\x98\x83' SNOWMAN_UNICODE = SNOWMAN.decode('utf8') -class BaseTest(unittest2.TestCase): +class BaseTest(unittest.TestCase): pass diff --git a/rollbar/test/test_lib.py b/rollbar/test/test_lib.py index 2793fab8..1facb933 100644 --- a/rollbar/test/test_lib.py +++ b/rollbar/test/test_lib.py @@ -2,6 +2,8 @@ from rollbar.test import BaseTest +import six + class RollbarLibTest(BaseTest): def test_dict_merge_not_dict(self): a = {'a': {'b': 42}} @@ -56,4 +58,4 @@ def test_dict_merge_dicts_select_poll(self): self.assertIn('b', result['a']) self.assertEqual(42, result['a']['b']) self.assertIn('y', result['a']) - self.assertRegex(result['a']['y'], r'Uncopyable obj') + six.assertRegex(self, result['a']['y'], r'Uncopyable obj') diff --git a/rollbar/test/test_rollbar.py b/rollbar/test/test_rollbar.py index 8cc2be29..d1b9ec46 100644 --- a/rollbar/test/test_rollbar.py +++ b/rollbar/test/test_rollbar.py @@ -17,6 +17,7 @@ import mock import unittest +import six import rollbar from rollbar.lib import python_major_version, string_types @@ -1189,7 +1190,7 @@ def test_args_lambda_with_star_args(self, send_payload): varargs = payload['data']['body']['trace']['frames'][-1]['varargspec'] self.assertEqual(1, len(payload['data']['body']['trace']['frames'][-1]['locals'][varargs])) - self.assertRegex(payload['data']['body']['trace']['frames'][-1]['locals'][varargs][0], r'\*+') + six.assertRegex(self, payload['data']['body']['trace']['frames'][-1]['locals'][varargs][0], r'\*+') @mock.patch('rollbar.send_payload') def test_args_lambda_with_star_args_and_args(self, send_payload): @@ -1216,8 +1217,8 @@ def test_args_lambda_with_star_args_and_args(self, send_payload): self.assertEqual('arg1-value', payload['data']['body']['trace']['frames'][-1]['locals']['arg1']) self.assertEqual(2, len(payload['data']['body']['trace']['frames'][-1]['locals'][varargs])) - self.assertRegex(payload['data']['body']['trace']['frames'][-1]['locals'][varargs][0], r'\*+') - self.assertRegex(payload['data']['body']['trace']['frames'][-1]['locals'][varargs][1], r'\*+') + six.assertRegex(self, payload['data']['body']['trace']['frames'][-1]['locals'][varargs][0], r'\*+') + six.assertRegex(self, payload['data']['body']['trace']['frames'][-1]['locals'][varargs][1], r'\*+') @mock.patch('rollbar.send_payload') def test_args_lambda_with_kwargs(self, send_payload): @@ -1437,7 +1438,7 @@ def _raise(**kwargs): self.assertEqual(2, len(payload['data']['body']['trace']['frames'][-1]['locals'][keywords])) self.assertIn('password', payload['data']['body']['trace']['frames'][-1]['locals'][keywords]) - self.assertRegex(payload['data']['body']['trace']['frames'][-1]['locals'][keywords]['password'], r'\*+') + six.assertRegex(self, payload['data']['body']['trace']['frames'][-1]['locals'][keywords]['password'], r'\*+') self.assertIn('clear', payload['data']['body']['trace']['frames'][-1]['locals'][keywords]) self.assertEqual('text', payload['data']['body']['trace']['frames'][-1]['locals'][keywords]['clear']) @@ -1468,8 +1469,8 @@ def _raise(): payload = send_payload.call_args[0][0] - self.assertRegex(payload['data']['body']['trace']['frames'][-1]['locals']['password'], r'\*+') - self.assertRegex(payload['data']['body']['trace']['frames'][-1]['locals']['Password'], r'\*+') + six.assertRegex(self, payload['data']['body']['trace']['frames'][-1]['locals']['password'], r'\*+') + six.assertRegex(self, payload['data']['body']['trace']['frames'][-1]['locals']['Password'], r'\*+') self.assertIn('_invalid', payload['data']['body']['trace']['frames'][-1]['locals']) binary_type_name = 'str' if python_major_version() < 3 else 'bytes' @@ -1786,19 +1787,19 @@ def test_scrub_webob_request_data(self): self.assertEqual('I am from NSA', unscrubbed['headers']['Authorization']) scrubbed = rollbar._transform(unscrubbed) - self.assertRegex(scrubbed['url'], r'http://example.com/the/path\?(q=hello&password=-+)|(password=-+&q=hello)') + six.assertRegex(self, scrubbed['url'], r'http://example.com/the/path\?(q=hello&password=-+)|(password=-+&q=hello)') self.assertEqual(scrubbed['GET']['q'], 'hello') - self.assertRegex(scrubbed['GET']['password'], r'\*+') + six.assertRegex(self, scrubbed['GET']['password'], r'\*+') self.assertEqual(scrubbed['POST']['foo'], 'bar') - self.assertRegex(scrubbed['POST']['confirm_password'], r'\*+') - self.assertRegex(scrubbed['POST']['token'], r'\*+') + six.assertRegex(self, scrubbed['POST']['confirm_password'], r'\*+') + six.assertRegex(self, scrubbed['POST']['token'], r'\*+') self.assertEqual('5.6.7.8', scrubbed['headers']['X-Real-Ip']) - self.assertRegex(scrubbed['headers']['Cookies'], r'\*+') - self.assertRegex(scrubbed['headers']['Authorization'], r'\*+') + six.assertRegex(self, scrubbed['headers']['Cookies'], r'\*+') + six.assertRegex(self, scrubbed['headers']['Authorization'], r'\*+') def test_filter_ip_no_user_ip(self): request_data = {'something': 'but no ip'} diff --git a/rollbar/test/test_scruburl_transform.py b/rollbar/test/test_scruburl_transform.py index cabeabe6..b0a63e08 100644 --- a/rollbar/test/test_scruburl_transform.py +++ b/rollbar/test/test_scruburl_transform.py @@ -1,4 +1,5 @@ import copy +import six from rollbar.lib import map, transforms, string_types, urlparse, parse_qs, python_major_version from rollbar.lib.transforms.scruburl import ScrubUrlTransform, _starts_with_auth_re @@ -146,5 +147,5 @@ def test_scrub_dict_nested_key_match_with_circular_ref(self): self.assertNotIn('secret', result['url'][0]['link']) self.assertNotIn('secr3t', result['link'][0]['url']) self.assertNotIn('secret', result['link'][0]['url']) - self.assertNotRegex(result['url'][0]['link'], r'^-+$') - self.assertNotRegex(result['link'][0]['url'], r'^-+$') + six.assertNotRegex(self, result['url'][0]['link'], r'^-+$') + six.assertNotRegex(self, result['link'][0]['url'], r'^-+$') diff --git a/rollbar/test/test_serializable_transform.py b/rollbar/test/test_serializable_transform.py index 4ae96248..3a2351f4 100644 --- a/rollbar/test/test_serializable_transform.py +++ b/rollbar/test/test_serializable_transform.py @@ -10,6 +10,8 @@ # Python 2.7 from collections import Mapping +import six + from rollbar.lib import transforms, python_major_version from rollbar.lib.transforms.serializable import SerializableTransform @@ -237,7 +239,7 @@ def __repr__(self): if python_major_version() < 3: self.assertEqual(result['custom'], b'hello') else: - self.assertRegex(result['custom'], "") + six.assertRegex(self, result['custom'], "") def test_encode_with_custom_repr_returns_object(self): class CustomRepr(object): @@ -248,7 +250,7 @@ def __repr__(self): serializable = SerializableTransform(safelist_types=[CustomRepr]) result = transforms.transform(start, serializable) - self.assertRegex(result['custom'], "") + six.assertRegex(self, result['custom'], "") def test_encode_with_custom_repr_returns_unicode(self): class CustomRepr(object): @@ -268,7 +270,7 @@ def __repr__(self): start = {'hello': 'world', 'custom': CustomRepr()} serializable = SerializableTransform(safelist_types=[CustomRepr]) result = transforms.transform(start, serializable) - self.assertRegex(result['custom'], "") + six.assertRegex(self, result['custom'], "") def test_encode_with_bad_str_doesnt_die(self): @@ -284,4 +286,4 @@ def __repr__(self): start = {'hello': 'world', 'custom': CustomRepr()} serializable = SerializableTransform(safelist_types=[CustomRepr]) result = transforms.transform(start, serializable) - self.assertRegex(result['custom'], "") + six.assertRegex(self, result['custom'], "") diff --git a/setup.py b/setup.py index 165391d5..e9f6178c 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,6 @@ tests_require = [ 'webob', 'blinker', - 'unittest2', 'mock<=3.0.5; python_version < "3.3"', 'enum34; python_version < "3.4"', 'httpx; python_version >= "3.6"', diff --git a/shell.nix b/shell.nix index edeea083..04ce7fb9 100644 --- a/shell.nix +++ b/shell.nix @@ -20,7 +20,7 @@ python = let }; in python36.override { inherit packageOverrides; }; pyrollbar = pkgs.callPackage ./. { inherit python; }; -pyenv = python.withPackages(ps: with ps; [ pyrollbar twine unittest2 mock pyramid ]); +pyenv = python.withPackages(ps: with ps; [ pyrollbar twine mock pyramid ]); in