if not _is_subtype(self.expected, self._base_type):
raise TypeError('%s() arg 1 must be %s' %
(name, self._base_type_str))
- if args and args[0] is None:
- warnings.warn("callable is None",
- DeprecationWarning, 3)
- args = ()
if not args:
self.msg = kwargs.pop('msg', None)
if kwargs:
- warnings.warn('%r is an invalid keyword argument for '
- 'this function' % next(iter(kwargs)),
- DeprecationWarning, 3)
+ raise TypeError('%r is an invalid keyword argument for '
+ 'this function' % (next(iter(kwargs)),))
return self
callable_obj, *args = args
with self.assertRaises(self.failureException):
self.assertRaises(ExceptionMock, lambda: 0)
# Failure when the function is None
- with self.assertWarns(DeprecationWarning):
+ with self.assertRaises(TypeError):
self.assertRaises(ExceptionMock, None)
# Failure when another exception is raised
with self.assertRaises(ExceptionMock):
with self.assertRaises(ExceptionMock, msg='foobar'):
pass
# Invalid keyword argument
- with self.assertWarnsRegex(DeprecationWarning, 'foobar'), \
- self.assertRaises(AssertionError):
+ with self.assertRaisesRegex(TypeError, 'foobar'):
with self.assertRaises(ExceptionMock, foobar=42):
pass
# Failure when another exception is raised
self.assertRaisesRegex(ExceptionMock, re.compile('expect$'), Stub)
self.assertRaisesRegex(ExceptionMock, 'expect$', Stub)
- with self.assertWarns(DeprecationWarning):
+ with self.assertRaises(TypeError):
self.assertRaisesRegex(ExceptionMock, 'expect$', None)
def testAssertNotRaisesRegex(self):
with self.assertRaisesRegex(Exception, 'expect', msg='foobar'):
pass
# Invalid keyword argument
- with self.assertWarnsRegex(DeprecationWarning, 'foobar'), \
- self.assertRaises(AssertionError):
+ with self.assertRaisesRegex(TypeError, 'foobar'):
with self.assertRaisesRegex(Exception, 'expect', foobar=42):
pass
with self.assertRaises(self.failureException):
self.assertWarns(RuntimeWarning, lambda: 0)
# Failure when the function is None
- with self.assertWarns(DeprecationWarning):
+ with self.assertRaises(TypeError):
self.assertWarns(RuntimeWarning, None)
# Failure when another warning is triggered
with warnings.catch_warnings():
with self.assertWarns(RuntimeWarning, msg='foobar'):
pass
# Invalid keyword argument
- with self.assertWarnsRegex(DeprecationWarning, 'foobar'), \
- self.assertRaises(AssertionError):
+ with self.assertRaisesRegex(TypeError, 'foobar'):
with self.assertWarns(RuntimeWarning, foobar=42):
pass
# Failure when another warning is triggered
self.assertWarnsRegex(RuntimeWarning, "o+",
lambda: 0)
# Failure when the function is None
- with self.assertWarns(DeprecationWarning):
+ with self.assertRaises(TypeError):
self.assertWarnsRegex(RuntimeWarning, "o+", None)
# Failure when another warning is triggered
with warnings.catch_warnings():
with self.assertWarnsRegex(RuntimeWarning, 'o+', msg='foobar'):
pass
# Invalid keyword argument
- with self.assertWarnsRegex(DeprecationWarning, 'foobar'), \
- self.assertRaises(AssertionError):
+ with self.assertRaisesRegex(TypeError, 'foobar'):
with self.assertWarnsRegex(RuntimeWarning, 'o+', foobar=42):
pass
# Failure when another warning is triggered