Skip to content

Commit 20307d0

Browse files
committed
Merge branch 'main' of github.com:python/cpython into gh-102251
2 parents 2ee60e2 + d14eb34 commit 20307d0

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

Lib/test/test_tkinter/__init__.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
import os.path
22
import unittest
3-
from test import support
4-
from test.support import import_helper
53

4+
from test.support import (
5+
check_sanitizer,
6+
import_helper,
7+
load_package_tests,
8+
requires,
9+
)
610

7-
if support.check_sanitizer(address=True, memory=True):
11+
12+
if check_sanitizer(address=True, memory=True):
813
raise unittest.SkipTest("Tests involving libX11 can SEGFAULT on ASAN/MSAN builds")
914

1015
# Skip test if _tkinter wasn't built.
1116
import_helper.import_module('_tkinter')
1217

1318
# Skip test if tk cannot be initialized.
14-
support.requires('gui')
19+
requires('gui')
1520

1621

1722
def load_tests(*args):
18-
return support.load_package_tests(os.path.dirname(__file__), *args)
23+
return load_package_tests(os.path.dirname(__file__), *args)

Lib/test/test_unittest/testmock/testmock.py

+8
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,14 @@ class B(object):
245245
with mock.patch('builtins.open', mock.mock_open()):
246246
mock.mock_open() # should still be valid with open() mocked
247247

248+
def test_explicit_parent(self):
249+
parent = Mock()
250+
mock1 = Mock(parent=parent, return_value=None)
251+
mock1(1, 2, 3)
252+
mock2 = Mock(parent=parent, return_value=None)
253+
mock2(4, 5, 6)
254+
255+
self.assertEqual(parent.mock_calls, [call(1, 2, 3), call(4, 5, 6)])
248256

249257
def test_reset_mock(self):
250258
parent = Mock()

Modules/_testsinglephase.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ init_module(PyObject *module, module_state *state)
140140
if (initialized == NULL) {
141141
return -1;
142142
}
143-
if (PyModule_AddObjectRef(module, "_module_initialized", initialized) != 0) {
143+
int rc = PyModule_AddObjectRef(module, "_module_initialized", initialized);
144+
Py_DECREF(initialized);
145+
if (rc < 0) {
144146
return -1;
145147
}
146148

0 commit comments

Comments
 (0)