-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
bpo-25872: Add unit tests for linecache and threading #25913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
5143e74
fc1f92d
fc4df5d
a977922
759de2b
5666a1d
4513859
8376d21
708e348
f021de2
a396fad
833c9b9
bcc20ab
ba62b83
420a638
2c8269b
8efe040
240eb9a
f66a050
78897e7
ac550ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
import subprocess | ||
import signal | ||
import textwrap | ||
import traceback | ||
|
||
from unittest import mock | ||
from test import lock_tests | ||
|
@@ -1338,6 +1339,24 @@ def run(self): | |
# explicitly break the reference cycle to not leak a dangling thread | ||
thread.exc = None | ||
|
||
def test_multithread_modify_file_noerror(self): | ||
uniocto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def modify_file(): | ||
with open(__file__, 'a') as fp: | ||
iritkatriel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fp.write(' ') | ||
iritkatriel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
traceback.format_stack() | ||
|
||
threads = [ | ||
threading.Thread(target=modify_file) | ||
for i in range(100) | ||
] | ||
try: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which exceptions are you trying to ignore here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing, sorry. I removed |
||
for t in threads: | ||
t.start() | ||
for t in threads: | ||
t.join() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why you don't do
? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing, sorry. |
||
finally: | ||
pass | ||
|
||
|
||
class ThreadRunFail(threading.Thread): | ||
def run(self): | ||
|
There was a pro 8000 blem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better. Now let's see how it should be organized. I have several comments:
You could create a new test class , say
class LineCacheInvalidationTests(unittest.TestCase):
Put the initialization code (what you called _oserror_helper) in this class's setUp.
Then add test functions for each test case.