From b78cb872cb2435690244f62387420259503fe38e Mon Sep 17 00:00:00 2001 From: Pradeep Kumar Date: Tue, 9 Jan 2018 20:12:09 -0700 Subject: [PATCH] Fix test cases for Python 2.7 Added 'six' package for assertRaisesRegex shim for Python 2.7 --- setup.py | 3 ++- testapp/tests.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 00fb134..ba34796 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,8 @@ download_url='https://github.com/godaddy/django-snow/archive/master.tar.gz', install_requires=[ 'Django>=1.8', - 'pysnow>=0.6.4' + 'pysnow>=0.6.4', + 'six' ], classifiers=[ diff --git a/testapp/tests.py b/testapp/tests.py index b0dc0c2..2d1299b 100644 --- a/testapp/tests.py +++ b/testapp/tests.py @@ -1,5 +1,6 @@ import uuid +import six from django.test import TestCase, override_settings from requests.exceptions import HTTPError @@ -153,7 +154,7 @@ def test_create_change_request_raises_exception_for_http_error(self, mock_pysnow self.mock_pysnow_client.resource.return_value = fake_resource mock_pysnow.Client.return_value = self.mock_pysnow_client - with self.assertRaisesRegex(ChangeRequestException, 'Could not create change request due to.*'): + with six.assertRaisesRegex(self, ChangeRequestException, 'Could not create change request due to.*'): self.change_request_handler.create_change_request('Title', 'Description', None, payload={}) def test_create_change_request_raises_exception_when_error_in_result(self, mock_pysnow): @@ -167,7 +168,7 @@ def test_create_change_request_raises_exception_when_error_in_result(self, mock_ self.mock_pysnow_client.resource.return_value = fake_resource mock_pysnow.Client.return_value = self.mock_pysnow_client - with self.assertRaisesRegex(ChangeRequestException, 'Could not create change request due to.*'): + with six.assertRaisesRegex(self, ChangeRequestException, 'Could not create change request due to.*'): self.change_request_handler.create_change_request('Title', 'Description', None, payload={}) @mock.patch('django_snow.helpers.snow_request_handler.ChangeRequestHandler.update_change_request') @@ -228,7 +229,7 @@ def test_update_change_request_raises_exception_for_http_error(self, mock_pysnow self.mock_pysnow_client.resource.return_value = fake_resource mock_pysnow.Client.return_value = self.mock_pysnow_client - with self.assertRaisesRegex(ChangeRequestException, 'Could not update change request due to '): + with six.assertRaisesRegex(self, ChangeRequestException, 'Could not update change request due to '): self.change_request_handler.update_change_request(fake_change_order, payload='{"foo": "bar"}') def test_update_change_request_raises_exception_for_error_in_result(self, mock_pysnow): @@ -239,7 +240,7 @@ def test_update_change_request_raises_exception_for_error_in_result(self, mock_p self.mock_pysnow_client.resource.return_value = fake_resource mock_pysnow.Client.return_value = self.mock_pysnow_client - with self.assertRaisesRegex(ChangeRequestException, 'Could not update change request due to '): + with six.assertRaisesRegex(self, ChangeRequestException, 'Could not update change request due to '): self.change_request_handler.update_change_request(fake_change_order, payload='{"foo": "bar"}') def test_get_snow_group_guid_cached_result(self, mock_pysnow):