Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unittest2 #419

Merged
merged 2 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rollbar/test/__init__.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
4 changes: 3 additions & 1 deletion rollbar/test/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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')
25 changes: 13 additions & 12 deletions rollbar/test/test_rollbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import mock

import unittest
import six

import rollbar
from rollbar.lib import python_major_version, string_types
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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'])

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'}
Expand Down
5 changes: 3 additions & 2 deletions rollbar/test/test_scruburl_transform.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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'^-+$')
10 changes: 6 additions & 4 deletions rollbar/test/test_serializable_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -237,7 +239,7 @@ def __repr__(self):
if python_major_version() < 3:
self.assertEqual(result['custom'], b'hello')
else:
self.assertRegex(result['custom'], "<class '.*CustomRepr'>")
six.assertRegex(self, result['custom'], "<class '.*CustomRepr'>")

def test_encode_with_custom_repr_returns_object(self):
class CustomRepr(object):
Expand All @@ -248,7 +250,7 @@ def __repr__(self):

serializable = SerializableTransform(safelist_types=[CustomRepr])
result = transforms.transform(start, serializable)
self.assertRegex(result['custom'], "<class '.*CustomRepr'>")
six.assertRegex(self, result['custom'], "<class '.*CustomRepr'>")

def test_encode_with_custom_repr_returns_unicode(self):
class CustomRepr(object):
Expand All @@ -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'], "<AssertionError.*CustomRepr.*>")
six.assertRegex(self, result['custom'], "<AssertionError.*CustomRepr.*>")

def test_encode_with_bad_str_doesnt_die(self):

Expand All @@ -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'], "<UnStringableException.*Exception.*str.*>")
six.assertRegex(self, result['custom'], "<UnStringableException.*Exception.*str.*>")
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"',
Expand Down
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down