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
f39c0ac6
Kaydet (Commit)
f39c0ac6
authored
Mar 30, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #26492: Added additional tests for exhausted iterators of mutable sequences.
üst
ab479c49
8dc2ec15
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 deletions
+24
-0
list_tests.py
Lib/test/list_tests.py
+11
-0
test_bytes.py
Lib/test/test_bytes.py
+2
-0
test_iter.py
Lib/test/test_iter.py
+11
-0
No files found.
Lib/test/list_tests.py
Dosyayı görüntüle @
f39c0ac6
...
...
@@ -593,3 +593,14 @@ class CommonTest(seq_tests.CommonTest):
def
__iter__
(
self
):
raise
KeyboardInterrupt
self
.
assertRaises
(
KeyboardInterrupt
,
list
,
F
())
def
test_exhausted_iterator
(
self
):
a
=
self
.
type2test
([
1
,
2
,
3
])
exhit
=
iter
(
a
)
empit
=
iter
(
a
)
for
x
in
exhit
:
# exhaust the iterator
next
(
empit
)
# not exhausted
a
.
append
(
9
)
self
.
assertEqual
(
list
(
exhit
),
[])
self
.
assertEqual
(
list
(
empit
),
[
9
])
self
.
assertEqual
(
a
,
self
.
type2test
([
1
,
2
,
3
,
9
]))
Lib/test/test_bytes.py
Dosyayı görüntüle @
f39c0ac6
...
...
@@ -17,6 +17,7 @@ import unittest
import
test.support
import
test.string_tests
import
test.buffer_tests
import
test.list_tests
from
test.support
import
bigaddrspacetest
,
MAX_Py_ssize_t
...
...
@@ -1418,6 +1419,7 @@ class ByteArrayTest(BaseBytesTest, unittest.TestCase):
b
[:]
=
data
self
.
assertEqual
(
list
(
it
),
[])
test_exhausted_iterator
=
test
.
list_tests
.
CommonTest
.
test_exhausted_iterator
class
AssortedBytesTest
(
unittest
.
TestCase
):
#
...
...
Lib/test/test_iter.py
Dosyayı görüntüle @
f39c0ac6
...
...
@@ -190,6 +190,17 @@ class TestCase(unittest.TestCase):
self
.
assertTrue
(
isinstance
(
it
,
collections
.
abc
.
Iterator
))
self
.
assertEqual
(
list
(
it
),
[])
def
test_mutating_seq_class_exhausted_iter
(
self
):
a
=
SequenceClass
(
5
)
exhit
=
iter
(
a
)
empit
=
iter
(
a
)
for
x
in
exhit
:
# exhaust the iterator
next
(
empit
)
# not exhausted
a
.
n
=
7
self
.
assertEqual
(
list
(
exhit
),
[])
self
.
assertEqual
(
list
(
empit
),
[
5
,
6
])
self
.
assertEqual
(
list
(
a
),
[
0
,
1
,
2
,
3
,
4
,
5
,
6
])
# Test a new_style class with __iter__ but no next() method
def
test_new_style_iter_class
(
self
):
class
IterClass
(
object
):
...
...
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