convert tests asserts to pytest style (#4696)

This commit is contained in:
Asif Saifuddin Auvi 2016-11-23 19:17:00 +06:00 committed by Tom Christie
parent 3e1b31bb9b
commit 4b59ec27fa
2 changed files with 13 additions and 13 deletions

View File

@ -71,8 +71,8 @@ class ClassBasedViewIntegrationTests(TestCase):
expected = {
'detail': JSON_ERROR
}
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(sanitise_json_error(response.data), expected)
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert sanitise_json_error(response.data) == expected
class FunctionBasedViewIntegrationTests(TestCase):
@ -85,8 +85,8 @@ class FunctionBasedViewIntegrationTests(TestCase):
expected = {
'detail': JSON_ERROR
}
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(sanitise_json_error(response.data), expected)
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert sanitise_json_error(response.data) == expected
class TestCustomExceptionHandler(TestCase):
@ -107,8 +107,8 @@ class TestCustomExceptionHandler(TestCase):
request = factory.get('/', content_type='application/json')
response = view(request)
expected = 'Error!'
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.data, expected)
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert response.data == expected
def test_function_based_view_exception_handler(self):
view = error_view
@ -116,5 +116,5 @@ class TestCustomExceptionHandler(TestCase):
request = factory.get('/', content_type='application/json')
response = view(request)
expected = 'Error!'
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.data, expected)
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert response.data == expected

View File

@ -21,14 +21,14 @@ class InitializeViewSetsTestCase(TestCase):
})
response = my_view(request)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data, {'ACTION': 'LIST'})
assert response.status_code == status.HTTP_200_OK
assert response.data == {'ACTION': 'LIST'}
def test_initialize_view_set_with_empty_actions(self):
try:
BasicViewSet.as_view()
except TypeError as e:
self.assertEqual(str(e), "The `actions` argument must be provided "
assert str(e) == ("The `actions` argument must be provided "
"when calling `.as_view()` on a ViewSet. "
"For example `.as_view({'get': 'list'})`")
else: