bpo-25872: Add unit tests for linecache and threading (GH-25913) (GH-26211)

(cherry picked from commit 115dea9e26)

Co-authored-by: uniocto <serit142sa33go@gmail.com>
This commit is contained in:
Irit Katriel 2021-05-18 15:25:38 +01:00 committed by GitHub
parent 049c4125f8
commit c05d8a6b67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 1 deletions

View file

@ -3,7 +3,7 @@ Tests for the threading module.
"""
import test.support
from test.support import verbose, import_module, cpython_only
from test.support import verbose, import_module, cpython_only, unlink
from test.support.script_helper import assert_python_ok, assert_python_failure
import random
@ -17,6 +17,7 @@ import os
import subprocess
import signal
import textwrap
import traceback
from test import lock_tests
from test import support
@ -1243,6 +1244,22 @@ class ThreadingExceptionTests(BaseTestCase):
# explicitly break the reference cycle to not leak a dangling thread
thread.exc = None
def test_multithread_modify_file_noerror(self):
# See issue25872
def modify_file():
with open(test.support.TESTFN, 'w', encoding='utf-8') as fp:
fp.write(' ')
traceback.format_stack()
self.addCleanup(unlink, test.support.TESTFN)
threads = [
threading.Thread(target=modify_file)
for i in range(100)
]
for t in threads:
t.start()
t.join()
class ThreadRunFail(threading.Thread):
def run(self):