Skip to content

Commit

Permalink
Fix deprecation warnings and good practices
Browse files Browse the repository at this point in the history
  • Loading branch information
frapell committed Oct 3, 2018
1 parent 396d16a commit 587b3a6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
12 changes: 9 additions & 3 deletions src/plone/rest/tests/test_dexterity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion src/plone/rest/tests/test_error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)')
2 changes: 1 addition & 1 deletion src/plone/rest/tests/test_redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
8 changes: 4 additions & 4 deletions src/plone/rest/tests/test_traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand All @@ -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')
Expand Down

0 comments on commit 587b3a6

Please sign in to comment.