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
3a20a5de
Commit
3a20a5de
authored
Feb 08, 2014
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #20546: Use specific asserts in int tests.
parent
016a3f33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
Lib/test/test_long.py
Lib/test/test_long.py
+24
-24
No files found.
Lib/test/test_long.py
View file @
3a20a5de
...
...
@@ -130,7 +130,7 @@ class LongTest(unittest.TestCase):
# The sign of the number is also random.
def
getran
(
self
,
ndigits
):
self
.
assert
True
(
ndigits
>
0
)
self
.
assert
Greater
(
ndigits
,
0
)
nbits_hi
=
ndigits
*
SHIFT
nbits_lo
=
nbits_hi
-
SHIFT
+
1
answer
=
0
...
...
@@ -865,21 +865,21 @@ class LongTest(unittest.TestCase):
def
test_small_ints
(
self
):
for
i
in
range
(
-
5
,
257
):
self
.
assert
True
(
i
is
i
+
0
)
self
.
assert
True
(
i
is
i
*
1
)
self
.
assert
True
(
i
is
i
-
0
)
self
.
assert
True
(
i
is
i
//
1
)
self
.
assert
True
(
i
is
i
&
-
1
)
self
.
assert
True
(
i
is
i
|
0
)
self
.
assert
True
(
i
is
i
^
0
)
self
.
assert
True
(
i
is
~~
i
)
self
.
assert
True
(
i
is
i
**
1
)
self
.
assert
True
(
i
is
int
(
str
(
i
)))
self
.
assert
True
(
i
is
i
<<
2
>>
2
,
str
(
i
))
self
.
assert
Is
(
i
,
i
+
0
)
self
.
assert
Is
(
i
,
i
*
1
)
self
.
assert
Is
(
i
,
i
-
0
)
self
.
assert
Is
(
i
,
i
//
1
)
self
.
assert
Is
(
i
,
i
&
-
1
)
self
.
assert
Is
(
i
,
i
|
0
)
self
.
assert
Is
(
i
,
i
^
0
)
self
.
assert
Is
(
i
,
~~
i
)
self
.
assert
Is
(
i
,
i
**
1
)
self
.
assert
Is
(
i
,
int
(
str
(
i
)))
self
.
assert
Is
(
i
,
i
<<
2
>>
2
,
str
(
i
))
# corner cases
i
=
1
<<
70
self
.
assert
True
(
i
-
i
is
0
)
self
.
assert
True
(
0
*
i
is
0
)
self
.
assert
Is
(
i
-
i
,
0
)
self
.
assert
Is
(
0
*
i
,
0
)
def
test_bit_length
(
self
):
tiny
=
1e-10
...
...
@@ -926,7 +926,7 @@ class LongTest(unittest.TestCase):
got
=
round
(
k
+
offset
,
-
1
)
expected
=
v
+
offset
self
.
assertEqual
(
got
,
expected
)
self
.
assert
True
(
type
(
got
)
is
int
)
self
.
assert
Is
(
type
(
got
),
int
)
# larger second argument
self
.
assertEqual
(
round
(
-
150
,
-
2
),
-
200
)
...
...
@@ -965,7 +965,7 @@ class LongTest(unittest.TestCase):
got
=
round
(
10
**
k
+
324678
,
-
3
)
expect
=
10
**
k
+
325000
self
.
assertEqual
(
got
,
expect
)
self
.
assert
True
(
type
(
got
)
is
int
)
self
.
assert
Is
(
type
(
got
),
int
)
# nonnegative second argument: round(x, n) should just return x
for
n
in
range
(
5
):
...
...
@@ -973,7 +973,7 @@ class LongTest(unittest.TestCase):
x
=
random
.
randrange
(
-
10000
,
10000
)
got
=
round
(
x
,
n
)
self
.
assertEqual
(
got
,
x
)
self
.
assert
True
(
type
(
got
)
is
int
)
self
.
assert
Is
(
type
(
got
),
int
)
for
huge_n
in
2
**
31
-
1
,
2
**
31
,
2
**
63
-
1
,
2
**
63
,
2
**
100
,
10
**
100
:
self
.
assertEqual
(
round
(
8979323
,
huge_n
),
8979323
)
...
...
@@ -982,7 +982,7 @@ class LongTest(unittest.TestCase):
x
=
random
.
randrange
(
-
10000
,
10000
)
got
=
round
(
x
)
self
.
assertEqual
(
got
,
x
)
self
.
assert
True
(
type
(
got
)
is
int
)
self
.
assert
Is
(
type
(
got
),
int
)
# bad second argument
bad_exponents
=
(
'brian'
,
2.0
,
0j
,
None
)
...
...
@@ -1187,15 +1187,15 @@ class LongTest(unittest.TestCase):
class
myint
(
int
):
pass
self
.
assert
True
(
type
(
myint
.
from_bytes
(
b'
\
x00
'
,
'big'
))
is
myint
)
self
.
assert
Is
(
type
(
myint
.
from_bytes
(
b'
\
x00
'
,
'big'
)),
myint
)
self
.
assertEqual
(
myint
.
from_bytes
(
b'
\
x01
'
,
'big'
),
1
)
self
.
assert
True
(
type
(
myint
.
from_bytes
(
b'
\
x00
'
,
'big'
,
signed
=
False
))
is
myint
)
self
.
assert
Is
(
type
(
myint
.
from_bytes
(
b'
\
x00
'
,
'big'
,
signed
=
False
))
,
myint
)
self
.
assertEqual
(
myint
.
from_bytes
(
b'
\
x01
'
,
'big'
,
signed
=
False
),
1
)
self
.
assert
True
(
type
(
myint
.
from_bytes
(
b'
\
x00
'
,
'little'
))
is
myint
)
self
.
assert
Is
(
type
(
myint
.
from_bytes
(
b'
\
x00
'
,
'little'
)),
myint
)
self
.
assertEqual
(
myint
.
from_bytes
(
b'
\
x01
'
,
'little'
),
1
)
self
.
assert
True
(
type
(
myint
.
from_bytes
(
b'
\
x00
'
,
'little'
,
signed
=
False
))
is
myint
)
self
.
assert
Is
(
type
(
myint
.
from_bytes
(
b'
\
x00
'
,
'little'
,
signed
=
False
))
,
myint
)
self
.
assertEqual
(
myint
.
from_bytes
(
b'
\
x01
'
,
'little'
,
signed
=
False
),
1
)
self
.
assertEqual
(
int
.
from_bytes
([
255
,
0
,
0
],
'big'
,
signed
=
True
),
-
65536
)
...
...
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