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
f567ca3e
Kaydet (Commit)
f567ca3e
authored
Mar 12, 2007
tarafından
Collin Winter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1678088: convert test_operations to use unittest, fold the result into test_dict.
üst
7b9c5555
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
100 deletions
+72
-100
test_operations
Lib/test/output/test_operations
+0
-21
regrtest.py
Lib/test/regrtest.py
+1
-1
test_dict.py
Lib/test/test_dict.py
+71
-0
test_operations.py
Lib/test/test_operations.py
+0
-78
No files found.
Lib/test/output/test_operations
deleted
100644 → 0
Dosyayı görüntüle @
7b9c5555
test_operations
3. Operations
XXX Mostly not yet implemented
3.1 Dictionary lookups fail if __cmp__() raises an exception
raising error
d[x2] = 2: caught the RuntimeError outside
raising error
z = d[x2]: caught the RuntimeError outside
raising error
x2 in d: caught the RuntimeError outside
raising error
d.has_key(x2): caught the RuntimeError outside
raising error
d.get(x2): caught the RuntimeError outside
raising error
d.setdefault(x2, 42): caught the RuntimeError outside
raising error
d.pop(x2): caught the RuntimeError outside
raising error
d.update({x2: 2}): caught the RuntimeError outside
resize bugs not triggered.
Lib/test/regrtest.py
Dosyayı görüntüle @
f567ca3e
...
@@ -470,7 +470,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
...
@@ -470,7 +470,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
STDTESTS
=
[
STDTESTS
=
[
'test_grammar'
,
'test_grammar'
,
'test_opcodes'
,
'test_opcodes'
,
'test_
operations
'
,
'test_
dict
'
,
'test_builtin'
,
'test_builtin'
,
'test_exceptions'
,
'test_exceptions'
,
'test_types'
,
'test_types'
,
...
...
Lib/test/test_dict.py
Dosyayı görüntüle @
f567ca3e
...
@@ -461,6 +461,77 @@ class DictTest(unittest.TestCase):
...
@@ -461,6 +461,77 @@ class DictTest(unittest.TestCase):
self
.
assertEqual
(
e
.
args
,
((
1
,),))
self
.
assertEqual
(
e
.
args
,
((
1
,),))
else
:
else
:
self
.
fail
(
"missing KeyError"
)
self
.
fail
(
"missing KeyError"
)
def
test_bad_key
(
self
):
# Dictionary lookups should fail if __cmp__() raises an exception.
class
CustomException
(
Exception
):
pass
class
BadDictKey
:
def
__hash__
(
self
):
return
hash
(
self
.
__class__
)
def
__cmp__
(
self
,
other
):
if
isinstance
(
other
,
self
.
__class__
):
raise
CustomException
return
other
d
=
{}
x1
=
BadDictKey
()
x2
=
BadDictKey
()
d
[
x1
]
=
1
for
stmt
in
[
'd[x2] = 2'
,
'z = d[x2]'
,
'x2 in d'
,
'd.has_key(x2)'
,
'd.get(x2)'
,
'd.setdefault(x2, 42)'
,
'd.pop(x2)'
,
'd.update({x2: 2})'
]:
try
:
exec
stmt
in
locals
()
except
CustomException
:
pass
else
:
self
.
fail
(
"Statement didn't raise exception"
)
def
test_resize1
(
self
):
# Dict resizing bug, found by Jack Jansen in 2.2 CVS development.
# This version got an assert failure in debug build, infinite loop in
# release build. Unfortunately, provoking this kind of stuff requires
# a mix of inserts and deletes hitting exactly the right hash codes in
# exactly the right order, and I can't think of a randomized approach
# that would be *likely* to hit a failing case in reasonable time.
d
=
{}
for
i
in
range
(
5
):
d
[
i
]
=
i
for
i
in
range
(
5
):
del
d
[
i
]
for
i
in
range
(
5
,
9
):
# i==8 was the problem
d
[
i
]
=
i
def
test_resize2
(
self
):
# Another dict resizing bug (SF bug #1456209).
# This caused Segmentation faults or Illegal instructions.
class
X
(
object
):
def
__hash__
(
self
):
return
5
def
__eq__
(
self
,
other
):
if
resizing
:
d
.
clear
()
return
False
d
=
{}
resizing
=
False
d
[
X
()]
=
1
d
[
X
()]
=
2
d
[
X
()]
=
3
d
[
X
()]
=
4
d
[
X
()]
=
5
# now trigger a resize
resizing
=
True
d
[
9
]
=
6
from
test
import
mapping_tests
from
test
import
mapping_tests
...
...
Lib/test/test_operations.py
deleted
100644 → 0
Dosyayı görüntüle @
7b9c5555
# Python test set -- part 3, built-in operations.
print
'3. Operations'
print
'XXX Mostly not yet implemented'
print
'3.1 Dictionary lookups fail if __cmp__() raises an exception'
class
BadDictKey
:
def
__hash__
(
self
):
return
hash
(
self
.
__class__
)
def
__cmp__
(
self
,
other
):
if
isinstance
(
other
,
self
.
__class__
):
print
"raising error"
raise
RuntimeError
,
"gotcha"
return
other
d
=
{}
x1
=
BadDictKey
()
x2
=
BadDictKey
()
d
[
x1
]
=
1
for
stmt
in
[
'd[x2] = 2'
,
'z = d[x2]'
,
'x2 in d'
,
'd.has_key(x2)'
,
'd.get(x2)'
,
'd.setdefault(x2, 42)'
,
'd.pop(x2)'
,
'd.update({x2: 2})'
]:
try
:
exec
stmt
except
RuntimeError
:
print
"
%
s: caught the RuntimeError outside"
%
(
stmt
,)
else
:
print
"
%
s: No exception passed through!"
# old CPython behavior
# Dict resizing bug, found by Jack Jansen in 2.2 CVS development.
# This version got an assert failure in debug build, infinite loop in
# release build. Unfortunately, provoking this kind of stuff requires
# a mix of inserts and deletes hitting exactly the right hash codes in
# exactly the right order, and I can't think of a randomized approach
# that would be *likely* to hit a failing case in reasonable time.
d
=
{}
for
i
in
range
(
5
):
d
[
i
]
=
i
for
i
in
range
(
5
):
del
d
[
i
]
for
i
in
range
(
5
,
9
):
# i==8 was the problem
d
[
i
]
=
i
# Another dict resizing bug (SF bug #1456209).
# This caused Segmentation faults or Illegal instructions.
class
X
(
object
):
def
__hash__
(
self
):
return
5
def
__eq__
(
self
,
other
):
if
resizing
:
d
.
clear
()
return
False
d
=
{}
resizing
=
False
d
[
X
()]
=
1
d
[
X
()]
=
2
d
[
X
()]
=
3
d
[
X
()]
=
4
d
[
X
()]
=
5
# now trigger a resize
resizing
=
True
d
[
9
]
=
6
print
'resize bugs not triggered.'
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