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
2a30b21f
Kaydet (Commit)
2a30b21f
authored
Şub 18, 2003
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Three test cases for __reduce_ex__. This fails for cPickle, until Tim
checks in his changes to support this in cPickle.c.
üst
d6cfccf4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
pickletester.py
Lib/test/pickletester.py
+52
-0
No files found.
Lib/test/pickletester.py
Dosyayı görüntüle @
2a30b21f
...
...
@@ -739,6 +739,58 @@ class AbstractPickleTests(unittest.TestCase):
self
.
assertEqual
(
x
.
foo
,
y
.
foo
)
self
.
assertEqual
(
x
.
bar
,
y
.
bar
)
def
test_reduce_overrides_default_reduce_ex
(
self
):
for
proto
in
0
,
1
,
2
:
x
=
REX_one
()
self
.
assertEqual
(
x
.
_reduce_called
,
0
)
s
=
self
.
dumps
(
x
,
proto
)
self
.
assertEqual
(
x
.
_reduce_called
,
1
)
y
=
self
.
loads
(
s
)
self
.
assertEqual
(
y
.
_reduce_called
,
0
)
def
test_reduce_ex_called
(
self
):
for
proto
in
0
,
1
,
2
:
x
=
REX_two
()
self
.
assertEqual
(
x
.
_proto
,
None
)
s
=
self
.
dumps
(
x
,
proto
)
self
.
assertEqual
(
x
.
_proto
,
proto
)
y
=
self
.
loads
(
s
)
self
.
assertEqual
(
y
.
_proto
,
None
)
def
test_reduce_ex_overrides_reduce
(
self
):
for
proto
in
0
,
1
,
2
:
x
=
REX_three
()
self
.
assertEqual
(
x
.
_proto
,
None
)
s
=
self
.
dumps
(
x
,
proto
)
self
.
assertEqual
(
x
.
_proto
,
proto
)
y
=
self
.
loads
(
s
)
self
.
assertEqual
(
y
.
_proto
,
None
)
# Test classes for reduce_ex
class
REX_one
(
object
):
_reduce_called
=
0
def
__reduce__
(
self
):
self
.
_reduce_called
=
1
return
REX_one
,
()
# No __reduce_ex__ here, but inheriting it from object
class
REX_two
(
object
):
_proto
=
None
def
__reduce_ex__
(
self
,
proto
):
self
.
_proto
=
proto
return
REX_two
,
()
# No __reduce__ here, but inheriting it from object
class
REX_three
(
object
):
_proto
=
None
def
__reduce_ex__
(
self
,
proto
):
self
.
_proto
=
proto
return
REX_two
,
()
def
__reduce__
(
self
):
raise
TestFailed
,
"This __reduce__ shouldn't be called"
# Test classes for newobj
class
MyInt
(
int
):
sample
=
1
...
...
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