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
eb38367f
Kaydet (Commit)
eb38367f
authored
Kas 15, 2017
tarafından
Miss Islington (bot)
Kaydeden (comit)
Serhiy Storchaka
Kas 15, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-32032: Test both implementations of module-level pickle API. (GH-4401) (#4403)
(cherry picked from commit
6545256d
)
üst
42336def
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
18 deletions
+25
-18
pickletester.py
Lib/test/pickletester.py
+12
-12
test_pickle.py
Lib/test/test_pickle.py
+12
-4
test_pickletools.py
Lib/test/test_pickletools.py
+1
-2
No files found.
Lib/test/pickletester.py
Dosyayı görüntüle @
eb38367f
...
@@ -2534,7 +2534,7 @@ class AbstractPickleModuleTests(unittest.TestCase):
...
@@ -2534,7 +2534,7 @@ class AbstractPickleModuleTests(unittest.TestCase):
f
=
open
(
TESTFN
,
"wb"
)
f
=
open
(
TESTFN
,
"wb"
)
try
:
try
:
f
.
close
()
f
.
close
()
self
.
assertRaises
(
ValueError
,
pickle
.
dump
,
123
,
f
)
self
.
assertRaises
(
ValueError
,
self
.
dump
,
123
,
f
)
finally
:
finally
:
os
.
remove
(
TESTFN
)
os
.
remove
(
TESTFN
)
...
@@ -2543,16 +2543,16 @@ class AbstractPickleModuleTests(unittest.TestCase):
...
@@ -2543,16 +2543,16 @@ class AbstractPickleModuleTests(unittest.TestCase):
f
=
open
(
TESTFN
,
"wb"
)
f
=
open
(
TESTFN
,
"wb"
)
try
:
try
:
f
.
close
()
f
.
close
()
self
.
assertRaises
(
ValueError
,
pickle
.
dump
,
123
,
f
)
self
.
assertRaises
(
ValueError
,
self
.
dump
,
123
,
f
)
finally
:
finally
:
os
.
remove
(
TESTFN
)
os
.
remove
(
TESTFN
)
def
test_load_from_and_dump_to_file
(
self
):
def
test_load_from_and_dump_to_file
(
self
):
stream
=
io
.
BytesIO
()
stream
=
io
.
BytesIO
()
data
=
[
123
,
{},
124
]
data
=
[
123
,
{},
124
]
pickle
.
dump
(
data
,
stream
)
self
.
dump
(
data
,
stream
)
stream
.
seek
(
0
)
stream
.
seek
(
0
)
unpickled
=
pickle
.
load
(
stream
)
unpickled
=
self
.
load
(
stream
)
self
.
assertEqual
(
unpickled
,
data
)
self
.
assertEqual
(
unpickled
,
data
)
def
test_highest_protocol
(
self
):
def
test_highest_protocol
(
self
):
...
@@ -2562,20 +2562,20 @@ class AbstractPickleModuleTests(unittest.TestCase):
...
@@ -2562,20 +2562,20 @@ class AbstractPickleModuleTests(unittest.TestCase):
def
test_callapi
(
self
):
def
test_callapi
(
self
):
f
=
io
.
BytesIO
()
f
=
io
.
BytesIO
()
# With and without keyword arguments
# With and without keyword arguments
pickle
.
dump
(
123
,
f
,
-
1
)
self
.
dump
(
123
,
f
,
-
1
)
pickle
.
dump
(
123
,
file
=
f
,
protocol
=-
1
)
self
.
dump
(
123
,
file
=
f
,
protocol
=-
1
)
pickle
.
dumps
(
123
,
-
1
)
self
.
dumps
(
123
,
-
1
)
pickle
.
dumps
(
123
,
protocol
=-
1
)
self
.
dumps
(
123
,
protocol
=-
1
)
pickle
.
Pickler
(
f
,
-
1
)
self
.
Pickler
(
f
,
-
1
)
pickle
.
Pickler
(
f
,
protocol
=-
1
)
self
.
Pickler
(
f
,
protocol
=-
1
)
def
test_bad_init
(
self
):
def
test_bad_init
(
self
):
# Test issue3664 (pickle can segfault from a badly initialized Pickler).
# Test issue3664 (pickle can segfault from a badly initialized Pickler).
# Override initialization without calling __init__() of the superclass.
# Override initialization without calling __init__() of the superclass.
class
BadPickler
(
pickle
.
Pickler
):
class
BadPickler
(
self
.
Pickler
):
def
__init__
(
self
):
pass
def
__init__
(
self
):
pass
class
BadUnpickler
(
pickle
.
Unpickler
):
class
BadUnpickler
(
self
.
Unpickler
):
def
__init__
(
self
):
pass
def
__init__
(
self
):
pass
self
.
assertRaises
(
pickle
.
PicklingError
,
BadPickler
()
.
dump
,
0
)
self
.
assertRaises
(
pickle
.
PicklingError
,
BadPickler
()
.
dump
,
0
)
...
...
Lib/test/test_pickle.py
Dosyayı görüntüle @
eb38367f
...
@@ -26,8 +26,13 @@ except ImportError:
...
@@ -26,8 +26,13 @@ except ImportError:
has_c_implementation
=
False
has_c_implementation
=
False
class
PickleTests
(
AbstractPickleModuleTests
):
class
PyPickleTests
(
AbstractPickleModuleTests
):
pass
dump
=
staticmethod
(
pickle
.
_dump
)
dumps
=
staticmethod
(
pickle
.
_dumps
)
load
=
staticmethod
(
pickle
.
_load
)
loads
=
staticmethod
(
pickle
.
_loads
)
Pickler
=
pickle
.
_Pickler
Unpickler
=
pickle
.
_Unpickler
class
PyUnpicklerTests
(
AbstractUnpickleTests
):
class
PyUnpicklerTests
(
AbstractUnpickleTests
):
...
@@ -136,6 +141,9 @@ class PyChainDispatchTableTests(AbstractDispatchTableTests):
...
@@ -136,6 +141,9 @@ class PyChainDispatchTableTests(AbstractDispatchTableTests):
if
has_c_implementation
:
if
has_c_implementation
:
class
CPickleTests
(
AbstractPickleModuleTests
):
from
_pickle
import
dump
,
dumps
,
load
,
loads
,
Pickler
,
Unpickler
class
CUnpicklerTests
(
PyUnpicklerTests
):
class
CUnpicklerTests
(
PyUnpicklerTests
):
unpickler
=
_pickle
.
Unpickler
unpickler
=
_pickle
.
Unpickler
bad_stack_errors
=
(
pickle
.
UnpicklingError
,)
bad_stack_errors
=
(
pickle
.
UnpicklingError
,)
...
@@ -426,12 +434,12 @@ class CompatPickleTests(unittest.TestCase):
...
@@ -426,12 +434,12 @@ class CompatPickleTests(unittest.TestCase):
def
test_main
():
def
test_main
():
tests
=
[
PickleTests
,
PyUnpicklerTests
,
PyPicklerTests
,
tests
=
[
P
yP
ickleTests
,
PyUnpicklerTests
,
PyPicklerTests
,
PyPersPicklerTests
,
PyIdPersPicklerTests
,
PyPersPicklerTests
,
PyIdPersPicklerTests
,
PyDispatchTableTests
,
PyChainDispatchTableTests
,
PyDispatchTableTests
,
PyChainDispatchTableTests
,
CompatPickleTests
]
CompatPickleTests
]
if
has_c_implementation
:
if
has_c_implementation
:
tests
.
extend
([
CUnpicklerTests
,
CPicklerTests
,
tests
.
extend
([
C
PickleTests
,
C
UnpicklerTests
,
CPicklerTests
,
CPersPicklerTests
,
CIdPersPicklerTests
,
CPersPicklerTests
,
CIdPersPicklerTests
,
CDumpPickle_LoadPickle
,
DumpPickle_CLoadPickle
,
CDumpPickle_LoadPickle
,
DumpPickle_CLoadPickle
,
PyPicklerUnpicklerObjectTests
,
PyPicklerUnpicklerObjectTests
,
...
...
Lib/test/test_pickletools.py
Dosyayı görüntüle @
eb38367f
...
@@ -2,10 +2,9 @@ import pickle
...
@@ -2,10 +2,9 @@ import pickle
import
pickletools
import
pickletools
from
test
import
support
from
test
import
support
from
test.pickletester
import
AbstractPickleTests
from
test.pickletester
import
AbstractPickleTests
from
test.pickletester
import
AbstractPickleModuleTests
import
unittest
import
unittest
class
OptimizedPickleTests
(
AbstractPickleTests
,
AbstractPickleModuleTests
):
class
OptimizedPickleTests
(
AbstractPickleTests
):
def
dumps
(
self
,
arg
,
proto
=
None
):
def
dumps
(
self
,
arg
,
proto
=
None
):
return
pickletools
.
optimize
(
pickle
.
dumps
(
arg
,
proto
))
return
pickletools
.
optimize
(
pickle
.
dumps
(
arg
,
proto
))
...
...
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