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
e78592d4
Kaydet (Commit)
e78592d4
authored
May 12, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make bytes and bytearray subclass tests compatible with base types tests.
üst
ea36c941
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
+17
-15
test_bytes.py
Lib/test/test_bytes.py
+17
-15
No files found.
Lib/test/test_bytes.py
Dosyayı görüntüle @
e78592d4
...
...
@@ -1425,11 +1425,11 @@ class BytesAsStringTest(FixedStringTest, unittest.TestCase):
class
SubclassTest
:
def
test_basic
(
self
):
self
.
assertTrue
(
issubclass
(
self
.
subclass2test
,
self
.
type2test
))
self
.
assertIsInstance
(
self
.
subclass2test
(),
self
.
type2test
)
self
.
assertTrue
(
issubclass
(
self
.
type2test
,
self
.
basetype
))
self
.
assertIsInstance
(
self
.
type2test
(),
self
.
basetype
)
a
,
b
=
b
"abcd"
,
b
"efgh"
_a
,
_b
=
self
.
subclass2test
(
a
),
self
.
subclass
2test
(
b
)
_a
,
_b
=
self
.
type2test
(
a
),
self
.
type
2test
(
b
)
# test comparison operators with subclass instances
self
.
assertTrue
(
_a
==
_a
)
...
...
@@ -1452,19 +1452,19 @@ class SubclassTest:
# Make sure join returns a NEW object for single item sequences
# involving a subclass.
# Make sure that it is of the appropriate type.
s1
=
self
.
subclass
2test
(
b
"abcd"
)
s2
=
self
.
type2test
()
.
join
([
s1
])
s1
=
self
.
type
2test
(
b
"abcd"
)
s2
=
self
.
basetype
()
.
join
([
s1
])
self
.
assertTrue
(
s1
is
not
s2
)
self
.
assertTrue
(
type
(
s2
)
is
self
.
type2test
,
type
(
s2
))
self
.
assertTrue
(
type
(
s2
)
is
self
.
basetype
,
type
(
s2
))
# Test reverse, calling join on subclass
s3
=
s1
.
join
([
b
"abcd"
])
self
.
assertTrue
(
type
(
s3
)
is
self
.
type2test
)
self
.
assertTrue
(
type
(
s3
)
is
self
.
basetype
)
def
test_pickle
(
self
):
a
=
self
.
subclass
2test
(
b
"abcd"
)
a
=
self
.
type
2test
(
b
"abcd"
)
a
.
x
=
10
a
.
y
=
self
.
subclass
2test
(
b
"efgh"
)
a
.
y
=
self
.
type
2test
(
b
"efgh"
)
for
proto
in
range
(
pickle
.
HIGHEST_PROTOCOL
+
1
):
b
=
pickle
.
loads
(
pickle
.
dumps
(
a
,
proto
))
self
.
assertNotEqual
(
id
(
a
),
id
(
b
))
...
...
@@ -1475,9 +1475,9 @@ class SubclassTest:
self
.
assertEqual
(
type
(
a
.
y
),
type
(
b
.
y
))
def
test_copy
(
self
):
a
=
self
.
subclass
2test
(
b
"abcd"
)
a
=
self
.
type
2test
(
b
"abcd"
)
a
.
x
=
10
a
.
y
=
self
.
subclass
2test
(
b
"efgh"
)
a
.
y
=
self
.
type
2test
(
b
"efgh"
)
for
copy_method
in
(
copy
.
copy
,
copy
.
deepcopy
):
b
=
copy_method
(
a
)
self
.
assertNotEqual
(
id
(
a
),
id
(
b
))
...
...
@@ -1487,6 +1487,8 @@ class SubclassTest:
self
.
assertEqual
(
type
(
a
),
type
(
b
))
self
.
assertEqual
(
type
(
a
.
y
),
type
(
b
.
y
))
test_fromhex
=
BaseBytesTest
.
test_fromhex
class
ByteArraySubclass
(
bytearray
):
pass
...
...
@@ -1498,8 +1500,8 @@ class OtherBytesSubclass(bytes):
pass
class
ByteArraySubclassTest
(
SubclassTest
,
unittest
.
TestCase
):
type2test
=
bytearray
subclass
2test
=
ByteArraySubclass
basetype
=
bytearray
type
2test
=
ByteArraySubclass
def
test_init_override
(
self
):
class
subclass
(
bytearray
):
...
...
@@ -1513,8 +1515,8 @@ class ByteArraySubclassTest(SubclassTest, unittest.TestCase):
class
BytesSubclassTest
(
SubclassTest
,
unittest
.
TestCase
):
type2test
=
bytes
subclass
2test
=
BytesSubclass
basetype
=
bytes
type
2test
=
BytesSubclass
if
__name__
==
"__main__"
:
...
...
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