_builtins = {name for name in dir(builtins) if not name.startswith('_')}
-BaseExceptions = (BaseException,)
-if 'java' in sys.platform:
- # jython
- import java
- BaseExceptions = (BaseException, java.lang.Throwable)
-
-
FILTER_DIR = True
# Workaround for issue #12370
def _is_exception(obj):
return (
- isinstance(obj, BaseExceptions) or
- isinstance(obj, type) and issubclass(obj, BaseExceptions)
+ isinstance(obj, BaseException) or
+ isinstance(obj, type) and issubclass(obj, BaseException)
)
mock.side_effect = ValueError('Bazinga!')
self.assertRaisesRegex(ValueError, 'Bazinga!', mock)
- @unittest.skipUnless('java' in sys.platform,
- 'This test only applies to Jython')
- def test_java_exception_side_effect(self):
- import java
- mock = Mock(side_effect=java.lang.RuntimeException("Boom!"))
-
- # can't use assertRaises with java exceptions
- try:
- mock(1, 2, fish=3)
- except java.lang.RuntimeException:
- pass
- else:
- self.fail('java exception not raised')
- mock.assert_called_with(1,2, fish=3)
-
def test_reset_mock(self):
parent = Mock()
def test_patch_multiple_create_mocks_different_order(self):
- # bug revealed by Jython!
original_f = Foo.f
original_g = Foo.g