Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
79094119
Commit
79094119
authored
Feb 02, 2016
by
Martin Panter
Browse files
Options
Browse Files
Download
Plain Diff
Issue #19587: Merge test_bytes cleanup from 3.5
parents
9990cb09
275bd96a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
63 deletions
+6
-63
Lib/test/buffer_tests.py
Lib/test/buffer_tests.py
+2
-44
Lib/test/string_tests.py
Lib/test/string_tests.py
+4
-6
Lib/test/test_bytes.py
Lib/test/test_bytes.py
+0
-13
No files found.
Lib/test/buffer_tests.py
View file @
79094119
# Tests that work for b
oth bytes and buffer objec
ts.
# Tests that work for b
ytearray objects. Could be merged into string_tes
ts.
# See PEP 3137.
import
struct
import
sys
class
MixinBytesBufferCommonTests
(
object
):
"""Tests that work for b
oth bytes and buffer
objects.
"""Tests that work for b
ytearray
objects.
See PEP 3137.
"""
...
...
@@ -88,16 +85,6 @@ class MixinBytesBufferCommonTests(object):
self
.
assertRaises
(
TypeError
,
self
.
marshal
(
b'abc'
).
isdigit
,
42
)
def
test_lower
(
self
):
self
.
assertEqual
(
b'hello'
,
self
.
marshal
(
b'HeLLo'
).
lower
())
self
.
assertEqual
(
b'hello'
,
self
.
marshal
(
b'hello'
).
lower
())
self
.
assertRaises
(
TypeError
,
self
.
marshal
(
b'hello'
).
lower
,
42
)
def
test_upper
(
self
):
self
.
assertEqual
(
b'HELLO'
,
self
.
marshal
(
b'HeLLo'
).
upper
())
self
.
assertEqual
(
b'HELLO'
,
self
.
marshal
(
b'HELLO'
).
upper
())
self
.
assertRaises
(
TypeError
,
self
.
marshal
(
b'hello'
).
upper
,
42
)
def
test_capitalize
(
self
):
self
.
assertEqual
(
b' hello '
,
self
.
marshal
(
b' hello '
).
capitalize
())
self
.
assertEqual
(
b'Hello '
,
self
.
marshal
(
b'Hello '
).
capitalize
())
...
...
@@ -153,35 +140,6 @@ class MixinBytesBufferCommonTests(object):
self
.
assertRaises
(
TypeError
,
self
.
marshal
(
b'123'
).
zfill
)
def
test_expandtabs
(
self
):
self
.
assertEqual
(
b'abc
\
r
ab def
\
n
g hi'
,
self
.
marshal
(
b'abc
\
r
ab
\
t
def
\
n
g
\
t
hi'
).
expandtabs
())
self
.
assertEqual
(
b'abc
\
r
ab def
\
n
g hi'
,
self
.
marshal
(
b'abc
\
r
ab
\
t
def
\
n
g
\
t
hi'
).
expandtabs
(
8
))
self
.
assertEqual
(
b'abc
\
r
ab def
\
n
g hi'
,
self
.
marshal
(
b'abc
\
r
ab
\
t
def
\
n
g
\
t
hi'
).
expandtabs
(
4
))
self
.
assertEqual
(
b'abc
\
r
\
n
ab def
\
n
g hi'
,
self
.
marshal
(
b'abc
\
r
\
n
ab
\
t
def
\
n
g
\
t
hi'
).
expandtabs
())
self
.
assertEqual
(
b'abc
\
r
\
n
ab def
\
n
g hi'
,
self
.
marshal
(
b'abc
\
r
\
n
ab
\
t
def
\
n
g
\
t
hi'
).
expandtabs
(
8
))
self
.
assertEqual
(
b'abc
\
r
\
n
ab def
\
n
g hi'
,
self
.
marshal
(
b'abc
\
r
\
n
ab
\
t
def
\
n
g
\
t
hi'
).
expandtabs
(
4
))
self
.
assertEqual
(
b'abc
\
r
\
n
ab
\
r
\
n
def
\
n
g
\
r
\
n
hi'
,
self
.
marshal
(
b'abc
\
r
\
n
ab
\
r
\
n
def
\
n
g
\
r
\
n
hi'
).
expandtabs
(
4
))
# check keyword args
self
.
assertEqual
(
b'abc
\
r
ab def
\
n
g hi'
,
self
.
marshal
(
b'abc
\
r
ab
\
t
def
\
n
g
\
t
hi'
).
expandtabs
(
tabsize
=
8
))
self
.
assertEqual
(
b'abc
\
r
ab def
\
n
g hi'
,
self
.
marshal
(
b'abc
\
r
ab
\
t
def
\
n
g
\
t
hi'
).
expandtabs
(
tabsize
=
4
))
self
.
assertEqual
(
b' a
\
n
b'
,
self
.
marshal
(
b'
\
t
a
\
n
\
t
b'
).
expandtabs
(
1
))
self
.
assertRaises
(
TypeError
,
self
.
marshal
(
b'hello'
).
expandtabs
,
42
,
42
)
# This test is only valid when sizeof(int) == sizeof(void*) == 4.
if
sys
.
maxsize
<
(
1
<<
32
)
and
struct
.
calcsize
(
'P'
)
==
4
:
self
.
assertRaises
(
OverflowError
,
self
.
marshal
(
b'
\
t
a
\
n
\
t
b'
).
expandtabs
,
sys
.
maxsize
)
def
test_title
(
self
):
self
.
assertEqual
(
b' Hello '
,
self
.
marshal
(
b' hello '
).
title
())
self
.
assertEqual
(
b'Hello '
,
self
.
marshal
(
b'hello '
).
title
())
...
...
Lib/test/string_tests.py
View file @
79094119
"""
Common tests shared by test_unicode, test_userstring and test_
string
.
Common tests shared by test_unicode, test_userstring and test_
bytes
.
"""
import
unittest
,
string
,
sys
,
struct
...
...
@@ -686,8 +686,7 @@ class BaseTest:
class
CommonTest
(
BaseTest
):
# This testcase contains tests that can be used in all
# stringlike classes. Currently this is str, unicode
# UserString and the string module.
# stringlike classes. Currently this is str and UserString.
def
test_hash
(
self
):
# SF bug 1054139: += optimization was not invalidating cached hash value
...
...
@@ -857,8 +856,7 @@ class CommonTest(BaseTest):
class
MixinStrUnicodeUserStringTest
:
# additional tests that only work for
# stringlike objects, i.e. str, unicode, UserString
# (but not the string module)
# stringlike objects, i.e. str, UserString
def
test_islower
(
self
):
self
.
checkequal
(
False
,
''
,
'islower'
)
...
...
@@ -1343,7 +1341,7 @@ class MixinStrUnicodeUserStringTest:
class MixinStrUnicodeTest:
# Additional tests that only work with str
and unicode
.
# Additional tests that only work with str.
def test_bug1001011(self):
# Make sure join returns a NEW object for single item sequences
...
...
Lib/test/test_bytes.py
View file @
79094119
...
...
@@ -1562,24 +1562,11 @@ class BytearrayPEP3137Test(unittest.TestCase,
class FixedStringTest(test.string_tests.BaseTest):
def fixtype(self, obj):
if isinstance(obj, str):
return obj.encode("utf-8")
return super().fixtype(obj)
# Currently the bytes containment testing uses a single integer
# value. This may not be the final design, but until then the
# bytes section with in a bytes containment not valid
def test_contains(self):
pass
def test_expandtabs(self):
pass
def test_upper(self):
pass
def test_lower(self):
pass
class ByteArrayAsStringTest(FixedStringTest, unittest.TestCase):
type2test = bytearray
contains_bytes = True
...
...
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