8000 remove jython support from unittest.mock (GH#13033) · python/cpython@49e27f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 49e27f0

Browse files
authored
remove jython support from unittest.mock (GH#13033)
1 parent db71975 commit 49e27f0

File tree

3 files changed

+2
-25
lines changed

3 files changed

+2
-25
lines changed

Lib/unittest/mock.py

Lines changed: 2 additions & 9 deletions
< 10000 /tr>
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@
3636

3737
_builtins = {name for name in dir(builtins) if not name.startswith('_')}
3838

39-
BaseExceptions = (BaseException,)
40-
if 'java' in sys.platform:
41-
# jython
42-
import java
43-
BaseExceptions = (BaseException, java.lang.Throwable)
44-
45-
4639
FILTER_DIR = True
4740

4841
# Workaround for issue #12370
@@ -57,8 +50,8 @@ def _is_instance_mock(obj):
5750

5851
def _is_exception(obj):
5952
return (
60-
isinstance(obj, BaseExceptions) or
61-
isinstance(obj, type) and issubclass(obj, BaseExceptions)
53+
isinstance(obj, BaseException) or
54+
isinstance(obj, type) and issubclass(obj, BaseException)
6255
)
6356

6457

Lib/unittest/test/testmock/testmock.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,6 @@ def f():
184184
mock.side_effect = ValueError('Bazinga!')
185185
self.assertRaisesRegex(ValueError, 'Bazinga!', mock)
186186

187-
@unittest.skipUnless('java' in sys.platform,
188-
'This test only applies to Jython')
189-
def test_java_exception_side_effect(self):
190-
import java
191-
mock = Mock(side_effect=java.lang.RuntimeException("Boom!"))
192-
193-
# can't use assertRaises with java exceptions
194-
try:
195-
mock(1, 2, fish=3)
196-
except java.lang.RuntimeException:
197-
pass
198-
else:
199-
self.fail('java exception not raised')
200-
mock.assert_called_with(1,2, fish=3)
201-
202187

203188
def test_reset_mock(self):
204189
parent = Mock()

Lib/unittest/test/testmock/testpatch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,6 @@ def test(f, foo):
13121312

13131313

13141314
def test_patch_multiple_create_mocks_different_order(self):
1315-
# bug revealed by Jython!
13161315
original_f = Foo.f
13171316
original_g = Foo.g
13181317

0 commit comments

Comments
 (0)
0