Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
my2to3
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bryton Lacquement
my2to3
Commits
a9abdb90
Commit
a9abdb90
authored
Jul 17, 2020
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
round_trace: don't trace ndigits if it's the default value
parent
6f0132db
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
my2to3/fixes/fix_round_trace.py
my2to3/fixes/fix_round_trace.py
+1
-1
my2to3/tests/testFixRoundTrace.py
my2to3/tests/testFixRoundTrace.py
+29
-0
No files found.
my2to3/fixes/fix_round_trace.py
View file @
a9abdb90
...
...
@@ -18,7 +18,7 @@ class FixRoundTrace(BaseDynamicTraceFix):
def
_dynamic_trace
(
number
,
ndigits
=
0
):
return
(
round
(
number
,
ndigits
),
(
parse_type
(
type
(
number
)),
parse_type
(
type
(
ndigits
)))
(
parse_type
(
type
(
number
)),
None
if
ndigits
==
0
else
parse_type
(
type
(
ndigits
)))
)
# Inspired by https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/lib2to3/fixes/fix_xrange.py#L14
...
...
my2to3/tests/testFixRoundTrace.py
0 → 100644
View file @
a9abdb90
import
unittest
from
.
import
FixerTestCase
class
testFixRoundTrace
(
FixerTestCase
):
fixer
=
"round_trace"
def
test_single_parameter
(
self
):
b
=
"""round(1.23)"""
a
=
"""round_traced("<string>",1,0,1.23)"""
self
.
check
(
b
,
a
)
self
.
exec_code
(
a
)
self
.
assertDataEqual
(
"round_modified"
,
[(
u'<string>'
,
1
,
0
)])
self
.
assertDataEqual
(
"round_trace"
,
[(
u'<string>'
,
1
,
0
,
u'float'
,
None
)])
def
test_both_parameters
(
self
):
b
=
"""round(1.23, 4)"""
a
=
"""round_traced("<string>",1,0,1.23, 4)"""
self
.
check
(
b
,
a
)
self
.
exec_code
(
a
)
self
.
assertDataEqual
(
"round_modified"
,
[(
u'<string>'
,
1
,
0
)])
self
.
assertDataEqual
(
"round_trace"
,
[(
u'<string>'
,
1
,
0
,
u'float'
,
u'int'
)])
if
__name__
==
'__main__'
:
unittest
.
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