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
671153db
Kaydet (Commit)
671153db
authored
Tem 23, 2010
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add queue tests for empty, full, put_nowait, and get_nowait.
Closes issue 9357. Thanks to Brian Brazil for the patch.
üst
6b0e0e41
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
test_queue.py
Lib/test/test_queue.py
+23
-0
No files found.
Lib/test/test_queue.py
Dosyayı görüntüle @
671153db
...
@@ -90,6 +90,8 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
...
@@ -90,6 +90,8 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
def
simple_queue_test
(
self
,
q
):
def
simple_queue_test
(
self
,
q
):
if
q
.
qsize
():
if
q
.
qsize
():
raise
RuntimeError
(
"Call this function with an empty queue"
)
raise
RuntimeError
(
"Call this function with an empty queue"
)
self
.
assertTrue
(
q
.
empty
())
self
.
assertFalse
(
q
.
full
())
# I guess we better check things actually queue correctly a little :)
# I guess we better check things actually queue correctly a little :)
q
.
put
(
111
)
q
.
put
(
111
)
q
.
put
(
333
)
q
.
put
(
333
)
...
@@ -108,6 +110,8 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
...
@@ -108,6 +110,8 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
full
=
3
*
2
*
QUEUE_SIZE
full
=
3
*
2
*
QUEUE_SIZE
q
.
put
(
last
)
q
.
put
(
last
)
self
.
assertTrue
(
qfull
(
q
),
"Queue should be full"
)
self
.
assertTrue
(
qfull
(
q
),
"Queue should be full"
)
self
.
assertFalse
(
q
.
empty
())
self
.
assertTrue
(
q
.
full
())
try
:
try
:
q
.
put
(
full
,
block
=
0
)
q
.
put
(
full
,
block
=
0
)
self
.
fail
(
"Didn't appear to block with a full queue"
)
self
.
fail
(
"Didn't appear to block with a full queue"
)
...
@@ -193,6 +197,25 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
...
@@ -193,6 +197,25 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
self
.
simple_queue_test
(
q
)
self
.
simple_queue_test
(
q
)
self
.
simple_queue_test
(
q
)
self
.
simple_queue_test
(
q
)
def
test_negative_timeout_raises_exception
(
self
):
q
=
self
.
type2test
(
QUEUE_SIZE
)
with
self
.
assertRaises
(
ValueError
):
q
.
put
(
1
,
timeout
=-
1
)
with
self
.
assertRaises
(
ValueError
):
q
.
get
(
1
,
timeout
=-
1
)
def
test_nowait
(
self
):
q
=
self
.
type2test
(
QUEUE_SIZE
)
for
i
in
range
(
QUEUE_SIZE
):
q
.
put_nowait
(
1
)
with
self
.
assertRaises
(
queue
.
Full
):
q
.
put_nowait
(
1
)
for
i
in
range
(
QUEUE_SIZE
):
q
.
get_nowait
()
with
self
.
assertRaises
(
queue
.
Empty
):
q
.
get_nowait
()
class
QueueTest
(
BaseQueueTest
):
class
QueueTest
(
BaseQueueTest
):
type2test
=
queue
.
Queue
type2test
=
queue
.
Queue
...
...
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