Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Fix test cases for Python 2.7
Browse files Browse the repository at this point in the history
Added 'six' package for assertRaisesRegex shim for Python 2.7
  • Loading branch information
pradeepsixer committed Jan 10, 2018
1 parent 56e7c45 commit b78cb87
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down
9 changes: 5 additions & 4 deletions testapp/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import uuid

import six
from django.test import TestCase, override_settings
from requests.exceptions import HTTPError

Expand Down Expand Up @@ -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):
Expand All @@ -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')
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit b78cb87

Please sign in to comment.