Skip to content

Commit

Permalink
Fix tests and DeprecationWarnings.
Browse files Browse the repository at this point in the history
Fixes #55
  • Loading branch information
jamadden committed Oct 19, 2018
1 parent 8b941a3 commit d4a6617
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
21 changes: 12 additions & 9 deletions src/zope/security/tests/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class AbstractProxyTestBase(object):

# pylint:disable=no-member,blacklisted-name

assertRaisesRegex = getattr(unittest.TestCase, 'assertRaisesRegex',
unittest.TestCase.assertRaisesRegexp)

# The names of attributes that are spelled different on Py2
# vs Py3
itruediv = '__itruediv__' if not PYTHON2 else '__idiv__'
Expand Down Expand Up @@ -97,7 +100,7 @@ def __getattr__(self, name):
checker = DummyChecker()
proxy = self._makeOne(target, checker)

with self.assertRaisesRegexp(AttributeError, "name"):
with self.assertRaisesRegex(AttributeError, "name"):
getattr(proxy, 'name')
self.assertEqual(1, target.count)

Expand Down Expand Up @@ -1320,8 +1323,8 @@ def __getslice__(self, start, stop):
target = Get()
checker = DummyChecker()
proxy = self._makeOne(target, checker)
with self.assertRaisesRegexp(Missing,
self.getslice):
with self.assertRaisesRegex(Missing,
self.getslice):
proxy[1:2]

self.assertEqual(checker._checked, self.getslice)
Expand All @@ -1336,8 +1339,8 @@ def __getitem__(self, x):
target = Get()
checker = DummyChecker()
proxy = self._makeOne(target, checker)
with self.assertRaisesRegexp(Missing,
'__getitem__'):
with self.assertRaisesRegex(Missing,
'__getitem__'):
proxy[1:2]

self.assertEqual(checker._checked, self.getslice)
Expand Down Expand Up @@ -1382,8 +1385,8 @@ def __setslice__(self, start, stop, value):
target = Set()
checker = DummyChecker()
proxy = self._makeOne(target, checker)
with self.assertRaisesRegexp(Missing,
self.setslice):
with self.assertRaisesRegex(Missing,
self.setslice):
proxy[1:2] = 1

self.assertEqual(checker._checked, self.setslice)
Expand All @@ -1398,8 +1401,8 @@ def __setitem__(self, k, v):
target = Set()
checker = DummyChecker()
proxy = self._makeOne(target, checker)
with self.assertRaisesRegexp(Missing,
'__setitem__'):
with self.assertRaisesRegex(Missing,
'__setitem__'):
proxy[1:2] = 1

self.assertEqual(checker._checked, self.setslice)
Expand Down
9 changes: 4 additions & 5 deletions src/zope/security/tests/test_zcml_functest.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def testFactory(self):
def testFactoryNoId(self):
from zope.component import getUtility
from zope.component.interfaces import IFactory
from zope.component.interfaces import ComponentLookupError
from zope.interface.interfaces import ComponentLookupError
from zope.configuration.xmlconfig import xmlconfig
self._meta()
f = configfile("""
Expand Down Expand Up @@ -481,15 +481,14 @@ def testMultipleInterface(self):

def testCompositeNoPerm(self):
# Establish rejection of declarations lacking a permission spec.
from zope.configuration.xmlconfig import ZopeXMLConfigurationError
from zope.configuration.exceptions import ConfigurationError
declaration = ('''<class class="%s">
<require
attributes="m1"/>
</class>'''
% (_pfx("test_class")))
self.assertRaises(ZopeXMLConfigurationError,
self.assertDeclaration,
declaration)
with self.assertRaises(ConfigurationError):
self.assertDeclaration(declaration)


def testCompositeMethodsPluralElementPerm(self):
Expand Down

0 comments on commit d4a6617

Please sign in to comment.