]> granicus.if.org Git - python/commitdiff
remove jython support from unittest.mock (GH#13033)
authorChris Withers <chris@withers.org>
Wed, 1 May 2019 07:48:44 +0000 (08:48 +0100)
committerGitHub <noreply@github.com>
Wed, 1 May 2019 07:48:44 +0000 (08:48 +0100)
Lib/unittest/mock.py
Lib/unittest/test/testmock/testmock.py
Lib/unittest/test/testmock/testpatch.py

index 997af717256646127bc44df23f3843b479b853d4..721e91f8cbcbae4427af2dcd7d0e7304f87b8cf0 100644 (file)
@@ -36,13 +36,6 @@ from functools import wraps, partial
 
 _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
@@ -57,8 +50,8 @@ def _is_instance_mock(obj):
 
 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)
     )
 
 
index 0e7e4a1d8c93fd5b0bbe7bf94d8c57b90a6782ec..9bef51abd87f51aa409763d6594d140d251a81aa 100644 (file)
@@ -184,21 +184,6 @@ class MockTest(unittest.TestCase):
         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()
index 51c66fec67fc45695d747a8a0eab577511701ea9..e5abd9bda489fcc0fbd9c61ae845d383933a12e3 100644 (file)
@@ -1312,7 +1312,6 @@ class PatchTest(unittest.TestCase):
 
 
     def test_patch_multiple_create_mocks_different_order(self):
-        # bug revealed by Jython!
         original_f = Foo.f
         original_g = Foo.g