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
38548ad0
Commit
38548ad0
authored
Apr 02, 2012
by
Stefan Krah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Whitespace.
parent
aae5c3a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
57 deletions
+57
-57
Lib/test/test_decimal.py
Lib/test/test_decimal.py
+57
-57
No files found.
Lib/test/test_decimal.py
View file @
38548ad0
...
...
@@ -59,63 +59,63 @@ sys.modules['decimal'] = orig_sys_decimal
############ RunFirst ############
class
RunFirst
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
save_default
=
self
.
decimal
.
DefaultContext
.
copy
()
def
tearDown
(
self
):
DefaultContext
=
self
.
decimal
.
DefaultContext
DefaultContext
.
prec
=
self
.
save_default
.
prec
DefaultContext
.
rounding
=
self
.
save_default
.
rounding
DefaultContext
.
Emax
=
self
.
save_default
.
Emax
DefaultContext
.
Emin
=
self
.
save_default
.
Emin
DefaultContext
.
capitals
=
self
.
save_default
.
capitals
DefaultContext
.
clamp
=
self
.
save_default
.
clamp
DefaultContext
.
flags
=
self
.
save_default
.
flags
DefaultContext
.
traps
=
self
.
save_default
.
traps
self
.
decimal
.
setcontext
(
self
.
decimal
.
DefaultContext
)
def
test_00default_context
(
self
):
# The test depends on the fact that getcontext() is called
# for the first time.
DefaultContext
=
self
.
decimal
.
DefaultContext
ROUND_05UP
=
self
.
decimal
.
ROUND_05UP
Clamped
=
self
.
decimal
.
Clamped
InvalidOperation
=
self
.
decimal
.
InvalidOperation
DefaultContext
.
prec
=
5001
DefaultContext
.
rounding
=
ROUND_05UP
DefaultContext
.
Emax
=
10025
DefaultContext
.
Emin
=
-
10025
DefaultContext
.
capitals
=
0
DefaultContext
.
clamp
=
1
DefaultContext
.
flags
[
InvalidOperation
]
=
True
DefaultContext
.
clear_traps
()
DefaultContext
.
traps
[
Clamped
]
=
True
# implicit initialization on first access
c
=
self
.
decimal
.
getcontext
()
self
.
assertEqual
(
c
.
prec
,
5001
)
self
.
assertEqual
(
c
.
rounding
,
ROUND_05UP
)
self
.
assertEqual
(
c
.
Emax
,
10025
)
self
.
assertEqual
(
c
.
Emin
,
-
10025
)
self
.
assertEqual
(
c
.
capitals
,
0
)
self
.
assertEqual
(
c
.
clamp
,
1
)
for
k
in
c
.
flags
:
self
.
assertFalse
(
c
.
flags
[
k
])
for
k
in
c
.
traps
:
if
k
is
Clamped
:
self
.
assertTrue
(
c
.
traps
[
k
])
else
:
self
.
assertFalse
(
c
.
traps
[
k
])
# explicit initialization
self
.
decimal
.
setcontext
(
DefaultContext
)
c
=
self
.
decimal
.
getcontext
()
for
k
in
c
.
flags
:
self
.
assertFalse
(
c
.
flags
[
k
])
def
setUp
(
self
):
self
.
save_default
=
self
.
decimal
.
DefaultContext
.
copy
()
def
tearDown
(
self
):
DefaultContext
=
self
.
decimal
.
DefaultContext
DefaultContext
.
prec
=
self
.
save_default
.
prec
DefaultContext
.
rounding
=
self
.
save_default
.
rounding
DefaultContext
.
Emax
=
self
.
save_default
.
Emax
DefaultContext
.
Emin
=
self
.
save_default
.
Emin
DefaultContext
.
capitals
=
self
.
save_default
.
capitals
DefaultContext
.
clamp
=
self
.
save_default
.
clamp
DefaultContext
.
flags
=
self
.
save_default
.
flags
DefaultContext
.
traps
=
self
.
save_default
.
traps
self
.
decimal
.
setcontext
(
self
.
decimal
.
DefaultContext
)
def
test_00default_context
(
self
):
# The test depends on the fact that getcontext() is called
# for the first time.
DefaultContext
=
self
.
decimal
.
DefaultContext
ROUND_05UP
=
self
.
decimal
.
ROUND_05UP
Clamped
=
self
.
decimal
.
Clamped
InvalidOperation
=
self
.
decimal
.
InvalidOperation
DefaultContext
.
prec
=
5001
DefaultContext
.
rounding
=
ROUND_05UP
DefaultContext
.
Emax
=
10025
DefaultContext
.
Emin
=
-
10025
DefaultContext
.
capitals
=
0
DefaultContext
.
clamp
=
1
DefaultContext
.
flags
[
InvalidOperation
]
=
True
DefaultContext
.
clear_traps
()
DefaultContext
.
traps
[
Clamped
]
=
True
# implicit initialization on first access
c
=
self
.
decimal
.
getcontext
()
self
.
assertEqual
(
c
.
prec
,
5001
)
self
.
assertEqual
(
c
.
rounding
,
ROUND_05UP
)
self
.
assertEqual
(
c
.
Emax
,
10025
)
self
.
assertEqual
(
c
.
Emin
,
-
10025
)
self
.
assertEqual
(
c
.
capitals
,
0
)
self
.
assertEqual
(
c
.
clamp
,
1
)
for
k
in
c
.
flags
:
self
.
assertFalse
(
c
.
flags
[
k
])
for
k
in
c
.
traps
:
if
k
is
Clamped
:
self
.
assertTrue
(
c
.
traps
[
k
])
else
:
self
.
assertFalse
(
c
.
traps
[
k
])
# explicit initialization
self
.
decimal
.
setcontext
(
DefaultContext
)
c
=
self
.
decimal
.
getcontext
()
for
k
in
c
.
flags
:
self
.
assertFalse
(
c
.
flags
[
k
])
class
CRunFirst
(
RunFirst
):
decimal
=
C
...
...
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