Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
cb637c9e
Kaydet (Commit)
cb637c9e
authored
Mar 12, 2007
tarafından
Collin Winter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1670993: Refactor test_threadedtempfile.py to use unittest.
üst
f252c7b7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
46 deletions
+34
-46
test_threadedtempfile
Lib/test/output/test_threadedtempfile
+0
-5
test_threadedtempfile.py
Lib/test/test_threadedtempfile.py
+34
-41
No files found.
Lib/test/output/test_threadedtempfile
deleted
100644 → 0
Dosyayı görüntüle @
f252c7b7
test_threadedtempfile
Creating
Starting
Reaping
Done: errors 0 ok 1000
Lib/test/test_threadedtempfile.py
Dosyayı görüntüle @
cb637c9e
...
...
@@ -10,22 +10,20 @@ failures. A failure is a bug in tempfile, and may be due to:
By default, NUM_THREADS == 20 and FILES_PER_THREAD == 50. This is enough to
create about 150 failures per run under Win98SE in 2.0, and runs pretty
quickly. Guido reports needing to boost FILES_PER_THREAD to 500 before
provoking a 2.0 failure under Linux. Run the test alone to boost either
via cmdline switches:
-f FILES_PER_THREAD (int)
-t NUM_THREADS (int)
provoking a 2.0 failure under Linux.
"""
NUM_THREADS
=
20
# change w/ -t option
FILES_PER_THREAD
=
50
# change w/ -f option
NUM_THREADS
=
20
FILES_PER_THREAD
=
50
import
thread
# If this fails, we can't test this module
import
threading
from
test.test_support
import
TestFailed
,
threading_setup
,
threading_cleanup
import
tempfile
from
test.test_support
import
threading_setup
,
threading_cleanup
,
run_unittest
import
unittest
import
StringIO
from
traceback
import
print_exc
import
tempfile
startEvent
=
threading
.
Event
()
...
...
@@ -46,41 +44,36 @@ class TempFileGreedy(threading.Thread):
else
:
self
.
ok_count
+=
1
def
test_main
():
threads
=
[]
thread_info
=
threading_setup
()
print
"Creating"
for
i
in
range
(
NUM_THREADS
):
t
=
TempFileGreedy
()
threads
.
append
(
t
)
t
.
start
()
print
"Starting"
startEvent
.
set
()
class
ThreadedTempFileTest
(
unittest
.
TestCase
):
def
test_main
(
self
):
threads
=
[]
thread_info
=
threading_setup
()
for
i
in
range
(
NUM_THREADS
):
t
=
TempFileGreedy
()
threads
.
append
(
t
)
t
.
start
()
startEvent
.
set
()
ok
=
0
errors
=
[]
for
t
in
threads
:
t
.
join
()
ok
+=
t
.
ok_count
if
t
.
error_count
:
errors
.
append
(
str
(
t
.
getName
())
+
str
(
t
.
errors
.
getvalue
()))
print
"Reaping"
ok
=
errors
=
0
for
t
in
threads
:
t
.
join
()
ok
+=
t
.
ok_count
errors
+=
t
.
error_count
if
t
.
error_count
:
print
'
%
s errors:
\n
%
s'
%
(
t
.
getName
(),
t
.
errors
.
getvalue
())
threading_cleanup
(
*
thread_info
)
msg
=
"Errors: errors
%
d ok
%
d
\n
%
s"
%
(
len
(
errors
),
ok
,
'
\n
'
.
join
(
errors
))
self
.
assertEquals
(
errors
,
[],
msg
)
self
.
assertEquals
(
ok
,
NUM_THREADS
*
FILES_PER_THREAD
)
msg
=
"Done: errors
%
d ok
%
d"
%
(
errors
,
ok
)
print
msg
if
errors
:
raise
TestFailed
(
msg
)
threading_cleanup
(
*
thread_info
)
def
test_main
():
run_unittest
(
ThreadedTempFileTest
)
if
__name__
==
"__main__"
:
import
sys
,
getopt
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"t:f:"
)
for
o
,
v
in
opts
:
if
o
==
"-f"
:
FILES_PER_THREAD
=
int
(
v
)
elif
o
==
"-t"
:
NUM_THREADS
=
int
(
v
)
test_main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment