summaryrefslogtreecommitdiffstats
path: root/Lib/test/support
diff options
context:
space:
mode:
authorJack DeVries <58614260+jdevries3133@users.noreply.github.com>2021-08-06 12:50:56 (GMT)
committerGitHub <noreply@github.com>2021-08-06 12:50:56 (GMT)
commit15d3c14df32a35ac69898a7852115722e30d7857 (patch)
treebd8fb96915ef0dcf7959139dd9460829f417ffc0 /Lib/test/support
parent4d77691172aae81bdcbb0ea75839d0e896c43781 (diff)
downloadcpython-15d3c14df32a35ac69898a7852115722e30d7857.zip
cpython-15d3c14df32a35ac69898a7852115722e30d7857.tar.gz
cpython-15d3c14df32a35ac69898a7852115722e30d7857.tar.bz2
bpo-40928: notify users running test_decimal on macOS of malloc warnings (GH-26783)
* When trying to allocate very large regions on macOS, malloc does not fail silently. It sends a noisy error out to STDERR * This provides a helper function to warn the user, and provides the warning for test_decimal, which consistently generates these warnings on macOS. Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/test/support')
-rw-r--r--Lib/test/support/__init__.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index e2847d5..b380271 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -467,6 +467,24 @@ TEST_HOME_DIR = os.path.dirname(TEST_SUPPORT_DIR)
TEST_DATA_DIR = os.path.join(TEST_HOME_DIR, "data")
+def darwin_malloc_err_warning(test_name):
+ """Assure user that loud errors generated by macOS libc's malloc are
+ expected."""
+ if sys.platform != 'darwin':
+ return
+
+ import shutil
+ msg = ' NOTICE '
+ detail = (f'{test_name} may generate "malloc can\'t allocate region"\n'
+ 'warnings on macOS systems. This behavior is known. Do not\n'
+ 'report a bug unless tests are also failing. See bpo-40928.')
+
+ padding, _ = shutil.get_terminal_size()
+ print(msg.center(padding, '-'))
+ print(detail)
+ print('-' * padding)
+
+
def findfile(filename, subdir=None):
"""Try to find a file on sys.path or in the test directory. If it is not
found the argument passed to the function is returned (this does not