diff --git a/src/plone/rest/tests/test_dexterity.py b/src/plone/rest/tests/test_dexterity.py index bb8e8b8..a31a730 100644 --- a/src/plone/rest/tests/test_dexterity.py +++ b/src/plone/rest/tests/test_dexterity.py @@ -116,11 +116,13 @@ def test_dexterity_news_item_get(self): 'text/html' ) image_file = os.path.join(os.path.dirname(__file__), u'image.png') + fd = open(image_file, 'rb') self.portal.newsitem.image = NamedBlobImage( - data=open(image_file, 'rb').read(), + data=fd.read(), contentType='image/png', filename=u'image.png' ) + fd.close() self.portal.newsitem.image_caption = u'This is an image caption.' import transaction transaction.commit() @@ -176,11 +178,13 @@ def test_dexterity_file_get(self): pdf_file = os.path.join( os.path.dirname(__file__), u'file.pdf' ) + fd = open(pdf_file, 'rb') self.portal.file.file = NamedBlobFile( - data=open(pdf_file, 'rb').read(), + data=fd.read(), contentType='application/pdf', filename=u'file.pdf' ) + fd.close() intids = getUtility(IIntIds) file_id = intids.getId(self.portal.file) self.portal.file.file = RelationValue(file_id) @@ -202,11 +206,13 @@ def test_dexterity_image_get(self): self.portal.image.title = 'My Image' self.portal.image.description = u'This is an image' image_file = os.path.join(os.path.dirname(__file__), u'image.png') + fd = open(image_file, 'rb') self.portal.image.image = NamedBlobImage( - data=open(image_file, 'rb').read(), + data=fd.read(), contentType='image/png', filename=u'image.png' ) + fd.close() import transaction transaction.commit() diff --git a/src/plone/rest/tests/test_error_handling.py b/src/plone/rest/tests/test_error_handling.py index ed3dc8d..2389dc7 100644 --- a/src/plone/rest/tests/test_error_handling.py +++ b/src/plone/rest/tests/test_error_handling.py @@ -116,6 +116,6 @@ def test_500_traceback_only_for_manager_users(self): traceback = response.json()[u'traceback'] self.assertIsInstance(traceback, list) - self.assertRegexpMatches( + self.assertRegex( traceback[0], r'^File "[^"]*", line \d*, in (publish|transaction_pubevents)') diff --git a/src/plone/rest/tests/test_redirects.py b/src/plone/rest/tests/test_redirects.py index 16f049d..ab9793c 100644 --- a/src/plone/rest/tests/test_redirects.py +++ b/src/plone/rest/tests/test_redirects.py @@ -174,4 +174,4 @@ def test_aborts_redirect_checks_early_for_app_root(self): def test_gracefully_deals_with_missing_request_url(self): error_view = ErrorHandling(self.portal, self.portal.REQUEST) self.portal.REQUEST['ACTUAL_URL'] = None - self.assertEquals(False, error_view.attempt_redirect()) + self.assertEqual(False, error_view.attempt_redirect()) diff --git a/src/plone/rest/tests/test_traversal.py b/src/plone/rest/tests/test_traversal.py index 80a97db..8f75971 100644 --- a/src/plone/rest/tests/test_traversal.py +++ b/src/plone/rest/tests/test_traversal.py @@ -61,18 +61,18 @@ def test_json_request_on_content_object_returns_service(self): def test_html_request_on_portal_root_returns_default_view(self): obj = self.traverse(accept='text/html') - self.assertEquals('listing_view', obj.__name__) + self.assertEqual('listing_view', obj.__name__) def test_html_request_on_portal_root_returns_dynamic_view(self): self.portal.setLayout('summary_view') obj = self.traverse(accept='text/html') - self.assertEquals('summary_view', obj.__name__) + self.assertEqual('summary_view', obj.__name__) def test_html_request_on_portal_root_returns_default_page(self): self.portal.invokeFactory('Document', id='doc1') self.portal.setDefaultPage('doc1') obj = self.traverse(accept='text/html') - self.assertEquals('document_view', obj.__name__) + self.assertEqual('document_view', obj.__name__) def test_json_request_on_object_with_multihook(self): doc1 = self.portal[self.portal.invokeFactory('Document', id='doc1')] @@ -86,7 +86,7 @@ def btr_test(container, request): obj = self.traverse(path='/plone/doc1') self.assertTrue(isinstance(obj, Service), 'Not a service') - self.assertEquals(1, self.request._btr_test_called) + self.assertEqual(1, self.request._btr_test_called) def test_json_request_on_existing_view_returns_named_service(self): obj = self.traverse('/plone/search')