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
6032c250
Commit
6032c250
authored
Mar 30, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #8248: Add some tests for the bool type. Patch by Gregory Nofi.
parent
7e213255
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
0 deletions
+35
-0
Lib/test/test_bool.py
Lib/test/test_bool.py
+24
-0
Lib/test/test_decimal.py
Lib/test/test_decimal.py
+6
-0
Lib/test/test_index.py
Lib/test/test_index.py
+2
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_bool.py
View file @
6032c250
...
...
@@ -45,6 +45,18 @@ class BoolTest(unittest.TestCase):
self
.
assertEqual
(
int
(
True
),
1
)
self
.
assertIsNot
(
int
(
True
),
True
)
def
test_float
(
self
):
self
.
assertEqual
(
float
(
False
),
0.0
)
self
.
assertIsNot
(
float
(
False
),
False
)
self
.
assertEqual
(
float
(
True
),
1.0
)
self
.
assertIsNot
(
float
(
True
),
True
)
def
test_long
(
self
):
self
.
assertEqual
(
int
(
False
),
0L
)
self
.
assertIsNot
(
int
(
False
),
False
)
self
.
assertEqual
(
int
(
True
),
1L
)
self
.
assertIsNot
(
int
(
True
),
True
)
def
test_math
(
self
):
self
.
assertEqual
(
+
False
,
0
)
self
.
assertIsNot
(
+
False
,
False
)
...
...
@@ -157,6 +169,12 @@ class BoolTest(unittest.TestCase):
self
.
assertIs
(
bool
(
""
),
False
)
self
.
assertIs
(
bool
(),
False
)
def
test_format
(
self
):
self
.
assertEqual
(
"%d"
%
False
,
"0"
)
self
.
assertEqual
(
"%d"
%
True
,
"1"
)
self
.
assertEqual
(
"%x"
%
False
,
"0"
)
self
.
assertEqual
(
"%x"
%
True
,
"1"
)
def
test_hasattr
(
self
):
self
.
assertIs
(
hasattr
([],
"append"
),
True
)
self
.
assertIs
(
hasattr
([],
"wobble"
),
False
)
...
...
@@ -251,6 +269,12 @@ class BoolTest(unittest.TestCase):
finally
:
os
.
remove
(
test_support
.
TESTFN
)
def
test_types
(
self
):
# types are always true.
for
t
in
[
bool
,
complex
,
dict
,
file
,
float
,
int
,
list
,
long
,
object
,
set
,
str
,
tuple
,
type
]:
self
.
assertIs
(
bool
(
t
),
True
)
def
test_operator
(
self
):
import
operator
self
.
assertIs
(
operator
.
truth
(
0
),
False
)
...
...
Lib/test/test_decimal.py
View file @
6032c250
...
...
@@ -476,6 +476,12 @@ class DecimalExplicitConstructionTest(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
Decimal
,
(
1
,
(
4
,
10
,
4
,
9
,
1
),
2
)
)
self
.
assertRaises
(
ValueError
,
Decimal
,
(
1
,
(
4
,
3
,
4
,
'a'
,
1
),
2
)
)
def
test_explicit_from_bool
(
self
):
self
.
assertIs
(
bool
(
Decimal
(
0
)),
False
)
self
.
assertIs
(
bool
(
Decimal
(
1
)),
True
)
self
.
assertEqual
(
Decimal
(
False
),
Decimal
(
0
))
self
.
assertEqual
(
Decimal
(
True
),
Decimal
(
1
))
def
test_explicit_from_Decimal
(
self
):
#positive
...
...
Lib/test/test_index.py
View file @
6032c250
...
...
@@ -49,6 +49,8 @@ class BaseTestCase(unittest.TestCase):
self
.
assertEqual
(
-
7L
.
__index__
(),
-
7
)
self
.
assertEqual
(
self
.
o
.
__index__
(),
4
)
self
.
assertEqual
(
self
.
n
.
__index__
(),
5
)
self
.
assertEqual
(
True
.
__index__
(),
1
)
self
.
assertEqual
(
False
.
__index__
(),
0
)
def
test_subclasses
(
self
):
r
=
range
(
10
)
...
...
Misc/ACKS
View file @
6032c250
...
...
@@ -545,6 +545,7 @@ Samuel Nicolary
Gustavo Niemeyer
Oscar Nierstrasz
Hrvoje Niksic
Gregory Nofi
Jesse Noller
Bill Noon
Stefan Norberg
...
...
Misc/NEWS
View file @
6032c250
...
...
@@ -164,6 +164,8 @@ C-API
Tests
-----
- Issue #8248: Add some tests for the bool type. Patch by Gregory Nofi.
- Issue #8263: Now regrtest.py will report a failure if it receives a
KeyboardInterrupt (SIGINT).
...
...
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